Subject: Re: [PATCH v2 1/8] hook: add internal state alloc/free callbacks

From: Adrian Ratiu <[email-masked]>
Date: Fri, 20 Feb 2026 14:35:29 +0200

On Thu, 19 Feb 2026, Junio C Hamano <[email-masked]> wrote:
> Adrian Ratiu <[email-masked]> 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.