Re: [PATCH v2 1/8] hook: add internal state alloc/free callbacks
- From
Adrian Ratiu <adrian.ratiu@collabora.com>
- Date
- Feb 20, 2026, 12:35 UTC
- Message-ID
- <87ldgny4mm.fsf@collabora.com>
- In-Reply-To
- <xmqq4inc2yom.fsf@gitster.g>
On Thu, 19 Feb 2026, Junio C Hamano <gitster@pobox.com> wrote:
Show 20 quoted lines
> 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.