Subject: Re: [PATCH v2 02/10] hook: fix minor style issues

From: Adrian Ratiu <[email-masked]>
Date: Tue, 24 Mar 2026 21:19:27 +0200

On Tue, 24 Mar 2026, Patrick Steinhardt <[email-masked]> wrote:
> On Fri, Mar 20, 2026 at 01:52:03PM +0200, Adrian Ratiu wrote:
>> diff --git a/builtin/hook.c b/builtin/hook.c
>> index 83020dfb4f..e641614b84 100644
>> --- a/builtin/hook.c
>> +++ b/builtin/hook.c
>> @@ -5,8 +5,6 @@
>>  #include "gettext.h"
>>  #include "hook.h"
>>  #include "parse-options.h"
>> -#include "strvec.h"
>> -#include "abspath.h"
>pp
> Another thing we could address while at it is to sort the headers
> (except "builtin.h" of course). Feel free to ignore though.
>

I'll fix all the nits you pointed out in v3, no worries. :)

<snip>

>> @@ -928,7 +929,11 @@ static int run_receive_hook(struct command *commands,
>>  {
>>  	struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT;
>>  	struct command *iter = commands;
>> -	struct receive_hook_feed_state feed_init_state = { 0 };
>> +	struct receive_hook_feed_state feed_init_state = {
>> +		.cmd = commands,
>> +		.skip_broken = skip_broken,
>> +		.buf = STRBUF_INIT,
>> +	};
>
> Interesting. The buffer here isn't only a style fix, but an actual bug
> fix, isn't it?

In theory yes, it's a bug. I'll fix it in a separate commit.

In practice there is no difference because this is passed to
receive_hook_feed_state_alloc() which creates "copies" for each hook and
properly initializes each copy with strbuf_init(&data->buf, 0);

(The differnce is between .buf being NULL vs pointing to a static array
strbuf_slopbuf with one element containing NULL )

I'll fix it anyway and explain in a separate commit to avoid confusion.

Thanks for spotting this!