Subject: Re: [PATCH 01/10] hook: move unsorted_string_list_remove() to string-list.[ch]

From: SZEDER Gábor <[email-masked]>
Date: Tue, 10 Mar 2026 20:56:07 +0100

On Mon, Mar 09, 2026 at 02:54:07AM +0200, Adrian Ratiu wrote:
> Move the convenience wrapper from hook to string-list since
> it's a more suitable place. Add a doc comment to the header.

unsorted_string_list_remove() in string-list has a 'free_util'
parameter that didn't exist in its original version in 'hook.c', but
it's not mentioned in the commit message.
Furthermore, none of the function's callsites are adjusted to the new
parameter, and the build fails with:

  hook.c: In function ‘hook_config_lookup_all’:
  hook.c:151:33: error: too few arguments to function ‘unsorted_string_list_remove’
    151 |                                 unsorted_string_list_remove(e->value, hook_name);
        |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  In file included from hook.h:5,
                   from hook.c:5:
  string-list.h:273:6: note: declared here
    273 | void unsorted_string_list_remove(struct string_list *list, const char *str,
        |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  hook.c:163:25: error: too few arguments to function ‘unsorted_string_list_remove’
    163 |                         unsorted_string_list_remove(hooks, hook_name);
        |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  string-list.h:273:6: note: declared here
    273 | void unsorted_string_list_remove(struct string_list *list, const char *str,
        |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  hook.c:180:25: error: too few arguments to function ‘unsorted_string_list_remove’
    180 |                         unsorted_string_list_remove(&data->disabled_hooks,
        |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  string-list.h:273:6: note: declared here
    273 | void unsorted_string_list_remove(struct string_list *list, const char *str,
        |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  make: *** [Makefile:2917: hook.o] Error 1

> Suggested-by: Patrick Steinhardt <[email-masked]>
> Signed-off-by: Adrian Ratiu <[email-masked]>
> ---
>  hook.c        | 8 --------
>  string-list.c | 9 +++++++++
>  string-list.h | 8 ++++++++
>  3 files changed, 17 insertions(+), 8 deletions(-)
> 
> diff --git a/hook.c b/hook.c
> index 2c8252b2c4..313a6b9937 100644
> --- a/hook.c
> +++ b/hook.c
> @@ -110,14 +110,6 @@ static void list_hooks_add_default(struct repository *r, const char *hookname,
>  	string_list_append(hook_list, hook_path)->util = h;
>  }
>  
> -static void unsorted_string_list_remove(struct string_list *list,
> -					const char *str)
> -{
> -	struct string_list_item *item = unsorted_string_list_lookup(list, str);
> -	if (item)
> -		unsorted_string_list_delete_item(list, item - list->items, 0);
> -}
> -
>  /*
>   * Callback struct to collect all hook.* keys in a single config pass.
>   * commands: friendly-name to command map.
> diff --git a/string-list.c b/string-list.c
> index fffa2ad4b6..d260b873c8 100644
> --- a/string-list.c
> +++ b/string-list.c
> @@ -281,6 +281,15 @@ void unsorted_string_list_delete_item(struct string_list *list, int i, int free_
>  	list->nr--;
>  }
>  
> +void unsorted_string_list_remove(struct string_list *list, const char *str,
> +				 int free_util)
> +{
> +	struct string_list_item *item = unsorted_string_list_lookup(list, str);
> +	if (item)
> +		unsorted_string_list_delete_item(list, item - list->items,
> +						 free_util);
> +}
> +
>  /*
>   * append a substring [p..end] to list; return number of things it
>   * appended to the list.
> diff --git a/string-list.h b/string-list.h
> index 3ad862a187..b86ee7c099 100644
> --- a/string-list.h
> +++ b/string-list.h
> @@ -265,6 +265,14 @@ struct string_list_item *unsorted_string_list_lookup(struct string_list *list,
>   */
>  void unsorted_string_list_delete_item(struct string_list *list, int i, int free_util);
>  
> +/**
> + * Remove the first item matching `str` from an unsorted string_list.
> + * No-op if `str` is not found. If `free_util` is non-zero, the `util`
> + * pointer of the removed item is freed before deletion.
> + */
> +void unsorted_string_list_remove(struct string_list *list, const char *str,
> +				 int free_util);
> +
>  /**
>   * Split string into substrings on characters in `delim` and append the
>   * substrings to `list`.  The input string is not modified.
> -- 
> 2.52.0.732.gb351b5166d.dirty
>