aboutsummaryrefslogtreecommitdiff
path: root/string-list.c
diff options
context:
space:
mode:
authorAdrian Ratiu <adrian.ratiu@collabora.com>2026-03-25 21:54:52 +0200
committerJunio C Hamano <gitster@pobox.com>2026-03-25 14:00:45 -0700
commitadd3564d2f2804ad37b9af773ec6420b497a1725 (patch)
tree2637f0fe3da8c03b33cd7071c6324655038dc4ae /string-list.c
parent83677335aea701658b4377ce09b9fe586fad1620 (diff)
downloadgit-add3564d2f2804ad37b9af773ec6420b497a1725.tar.xz
hook: move unsorted_string_list_remove() to string-list.[ch]
Move the convenience wrapper from hook to string-list since it's a more suitable place. Add a doc comment to the header. Also add a free_util arg to make the function more generic and make the API similar to other functions in string-list.h. Update the existing call-sites. Suggested-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'string-list.c')
-rw-r--r--string-list.c9
1 files changed, 9 insertions, 0 deletions
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.