Re: [PATCH v10 4/4] hook: introduce the receive-report hook
- From
Karthik Nayak <karthik.188@gmail.com>
- Date
- Sep 11, 2026, 21:58 UTC
- Message-ID
- <CAOLa=ZS0PT4bb+k3HR4F_aOoJ5uUuMFx+Dnte4LpPEekFxs9uA@mail.gmail.com>
- In-Reply-To
- <xmqq33vfa2ny.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 15 quoted lines
> Karthik Nayak <karthik.188@gmail.com> writes:
>
>> +static void override_cmds_error(struct command *commands, const char *err)
>> +{
>> + for (struct command *cmd = commands; cmd; cmd = cmd->next) {
>> + if (cmd->error_string_owned)
>> + FREE_AND_NULL(cmd->error_string_owned);
>> + cmd->error_string = err;
>> + }
>> +}
>
> This is my fault, but like free(), FREE_AND_NULL() can safely be
> called on a variable that already is NULL so we may want to fix up
> after the dust settles, perhaps?
>I didn't really think too much about the change. I'll avoid a re-roll for this.
Show 32 quoted lines
> builtin/receive-pack.c | 3 +--
> tools/coccinelle/free.cocci | 6 ++++++
> 2 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git c/builtin/receive-pack.c w/builtin/receive-pack.c
> index 9ac7717096..1d5b050beb 100644
> --- c/builtin/receive-pack.c
> +++ w/builtin/receive-pack.c
> @@ -2452,8 +2452,7 @@ static void update_shallow_info(struct command *commands,
> static void override_cmds_error(struct command *commands, const char *err)
> {
> for (struct command *cmd = commands; cmd; cmd = cmd->next) {
> - if (cmd->error_string_owned)
> - FREE_AND_NULL(cmd->error_string_owned);
> + FREE_AND_NULL(cmd->error_string_owned);
> cmd->error_string = err;
> }
> }
> diff --git c/tools/coccinelle/free.cocci w/tools/coccinelle/free.cocci
> index 03799e1908..c95ffa2a07 100644
> --- c/tools/coccinelle/free.cocci
> +++ w/tools/coccinelle/free.cocci
> @@ -43,3 +43,9 @@ statement S;
> S
> commit_list_free(E);
> - }
> +@@
> +expression E;
> +@@
> +- if (E)
> +- FREE_AND_NULL(E);
> ++ FREE_AND_NULL(E);I could send in this patch for coccinelle with the fixup if that's okay with you.