Re: [PATCH 05/10] hook: replace hook_list_clear() -> string_list_clear_func() On Sun, Mar 8, 2026 at 8:55 PM Adrian Ratiu <adrian.ratiu@collabora.com> wrote: Show 21 quoted lines > 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 <ps@pks.im>
> Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
> ---
> 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/xmqqcy1g25fl.fsf@gitster.g/ Message 13 of 71 in “config-hook cleanups and two small 'git hook list' features” 00/10 config-hook cleanups and two small 'git hook list' featuresAdrian Ratiu, Mar 9, 2026 01/10 hook: move unsorted_string_list_remove() to string-list.[ch]Adrian Ratiu, Mar 9, 2026 02/10 hook: fix minor style issuesAdrian Ratiu, Mar 9, 2026 03/10 hook: rename cb_data_free/alloc -> hook_data_free/allocAdrian Ratiu, Mar 9, 2026 04/10 hook: detect & emit two more bugsAdrian Ratiu, Mar 9, 2026 05/10 hook: replace hook_list_clear() -> string_list_clear_func()Adrian Ratiu, Mar 9, 2026 06/10 hook: make consistent use of friendly-name in docsAdrian Ratiu, Mar 9, 2026 08/10 hook: refactor hook_config_cache from strmap to named structAdrian Ratiu, Mar 9, 2026 07/10 t1800: add test to verify hook execution orderingAdrian Ratiu, Mar 9, 2026 09/10 hook: show config scope in git hook listAdrian Ratiu, Mar 9, 2026 10/10 hook: show disabled hooks in "git hook list"Adrian Ratiu, Mar 9, 2026 Eric Sunshine Mar 9, 2026 Eric Sunshine Mar 9, 2026 Junio C Hamano Mar 9, 2026 Junio C Hamano Mar 9, 2026 Junio C Hamano Mar 9, 2026 Junio C Hamano Mar 9, 2026 Adrian Ratiu Mar 10, 2026 Adrian Ratiu Mar 10, 2026 Adrian Ratiu Mar 10, 2026 Adrian Ratiu Mar 10, 2026 SZEDER Gábor Mar 10, 2026 Patrick Steinhardt Mar 11, 2026 Patrick Steinhardt Mar 11, 2026 Patrick Steinhardt Mar 11, 2026 Adrian Ratiu Mar 11, 2026 Adrian Ratiu Mar 11, 2026 Adrian Ratiu Mar 11, 2026 Adrian Ratiu Mar 11, 2026 Patrick Steinhardt Mar 11, 2026 00/10 config-hook cleanups and two small 'git hook list' featuresAdrian Ratiu, Mar 20, 2026 01/10 hook: move unsorted_string_list_remove() to string-list.[ch]Adrian Ratiu, Mar 20, 2026 03/10 hook: rename cb_data_free/alloc -> hook_data_free/allocAdrian Ratiu, Mar 20, 2026 04/10 hook: detect & emit two more bugsAdrian Ratiu, Mar 20, 2026 05/10 hook: replace hook_list_clear() -> string_list_clear_func()Adrian Ratiu, Mar 20, 2026 06/10 hook: make consistent use of friendly-name in docsAdrian Ratiu, Mar 20, 2026 07/10 t1800: add test to verify hook execution orderingAdrian Ratiu, Mar 20, 2026 08/10 hook: introduce hook_config_cache_entry for per-hook dataAdrian Ratiu, Mar 20, 2026 02/10 hook: fix minor style issuesAdrian Ratiu, Mar 20, 2026 09/10 hook: show config scope in git hook listAdrian Ratiu, Mar 20, 2026 10/10 hook: show disabled hooks in "git hook list"Adrian Ratiu, Mar 20, 2026 Junio C Hamano Mar 23, 2026 Patrick Steinhardt Mar 24, 2026 Patrick Steinhardt Mar 24, 2026 Patrick Steinhardt Mar 24, 2026 Patrick Steinhardt Mar 24, 2026 Patrick Steinhardt Mar 24, 2026 Junio C Hamano Mar 24, 2026 Adrian Ratiu Mar 24, 2026 Adrian Ratiu Mar 24, 2026 Adrian Ratiu Mar 24, 2026 Adrian Ratiu Mar 24, 2026 Patrick Steinhardt Mar 25, 2026 Adrian Ratiu Mar 25, 2026 00/12 config-hook cleanups and three small git-hook featuresAdrian Ratiu, Mar 25, 2026 01/12 hook: move unsorted_string_list_remove() to string-list.[ch]Adrian Ratiu, Mar 25, 2026 02/12 builtin/receive-pack: properly init receive_hook strbufAdrian Ratiu, Mar 25, 2026 04/12 hook: rename cb_data_free/alloc -> hook_data_free/allocAdrian Ratiu, Mar 25, 2026 03/12 hook: fix minor style issuesAdrian Ratiu, Mar 25, 2026 05/12 hook: detect & emit two more bugsAdrian Ratiu, Mar 25, 2026 06/12 hook: replace hook_list_clear() -> string_list_clear_func()Adrian Ratiu, Mar 25, 2026 07/12 hook: make consistent use of friendly-name in docsAdrian Ratiu, Mar 25, 2026 08/12 t1800: add test to verify hook execution orderingAdrian Ratiu, Mar 25, 2026 09/12 hook: introduce hook_config_cache_entry for per-hook dataAdrian Ratiu, Mar 25, 2026 10/12 hook: show config scope in git hook listAdrian Ratiu, Mar 25, 2026 11/12 hook: show disabled hooks in "git hook list"Adrian Ratiu, Mar 25, 2026 12/12 hook: reject unknown hook names in git-hook(1)Adrian Ratiu, Mar 25, 2026 Junio C Hamano Mar 25, 2026 Adrian Ratiu Mar 26, 2026 Patrick Steinhardt Mar 27, 2026 Junio C Hamano Mar 27, 2026 Read the whole thread , see it on lore , or plain text .