Re: [PATCH v2 1/8] hook: add internal state alloc/free callbacks
From: Junio C Hamano <hidden>
Date: 2026-02-20 17:21:32
Adrian Ratiu [off-list ref] writes:
On Thu, 19 Feb 2026, Junio C Hamano [off-list ref] wrote:quoted
Adrian Ratiu [off-list ref] writes:quoted
+ /* + * Ensure cb_data copy and free functions are either provided together, + * or neither one is provided. + */ + if ((options->feed_pipe_cb_data_alloc && !options->feed_pipe_cb_data_free) || + (!options->feed_pipe_cb_data_alloc && options->feed_pipe_cb_data_free)) + BUG("feed_pipe_cb_data_alloc and feed_pipe_cb_data_free must be set together");A way to avoid being repetitious may be to say if (!!options->feed_pipe_cb_data_alloc != !!options->feed_pipe_cb_data_free) or if (!!options->feed_pipe_cb_data_alloc ^ !!options->feed_pipe_cb_data_free) but it (especially the latter) might be a bit too cute for some people's taste.Thanks for suggesting this. I was actually thinking of ways to simplify this and the double negation didn't occur to me. Will do in v3.
Embarrassed. You do not need !!; (!A != !B) would suffice.