Re: [PATCH v2 02/10] hook: fix minor style issues
- From
Adrian Ratiu <adrian.ratiu@collabora.com>
- Date
- Mar 24, 2026, 19:19 UTC
- Message-ID
- <87h5q5c9xc.fsf@collabora.com>
- In-Reply-To
- <acJNW0m2wHfRStqY@pks.im>
On Tue, 24 Mar 2026, Patrick Steinhardt <ps@pks.im> wrote:
Show 15 quoted lines
> 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>
Show 13 quoted lines
>> @@ -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!