Subject: Re: [PATCH 05/10] hook: replace hook_list_clear() -> string_list_clear_func()

From: Adrian Ratiu <[email-masked]>
Date: Tue, 10 Mar 2026 16:20:52 +0200

On Sun, 08 Mar 2026, Eric Sunshine <[email-masked]> wrote:
> On Sun, Mar 8, 2026 at 8:55 PM Adrian Ratiu <[email-masked]> wrote:
>> Replace the custom function with string_list_clear_func() which
>> is a more common pattern for clearing a string_list.
>>
>> To be able to do this, rework hook_clear() into hook_free(), so
>> it can be passed to string_list_clear_func().
>>
>> A slight complication is the need to keep a copy of the internal
>> cb data free() pointer, however I think it's worth it since the
>> API becomes cleaner, e.g. no more calls with NULL function args
>> like hook_list_clear(hooks, NULL).
>>
>> Suggested-by: Patrick Steinhardt <[email-masked]>
>> Signed-off-by: Adrian Ratiu <[email-masked]>
>> ---
>> diff --git a/hook.h b/hook.h
>> @@ -186,10 +194,10 @@ struct string_list *list_hooks(struct repository *r, const char *hookname,
>>  /**
>> + * Frees a struct hook stored as the util pointer of a string_list_item.
>> + * Suitable for use as a string_list_clear_func_t callback.
>>   */
>> +void hook_free(void *p, const char *str UNUSED);
>
> See [*] regarding UNUSED in header file.
>
> [*]: https://lore.kernel.org/git/[email-masked]/

Thank you for pointing this out!

I will fix it in v2 together with your other suggestion.