Re: [PATCH v2 1/8] hook: add internal state alloc/free callbacks
Adrian Ratiu <adrian.ratiu@collabora.com> writes:
Show 24 quoted lines
> On Thu, 19 Feb 2026, Junio C Hamano <gitster@pobox.com> wrote:
>> Adrian Ratiu <adrian.ratiu@collabora.com> writes:
>>
>>> + /*
>>> + * 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.