From 2e711acfbdfc0fedf631688d78cde153ba835c93 Mon Sep 17 00:00:00 2001 From: Amisha Chhajed Date: Thu, 29 Jan 2026 17:42:20 +0530 Subject: string-list: add string_list_sort_u() that mimics "sort -u" Many callsites of string_list_remove_duplicates() call it immdediately after calling string_list_sort(), understandably as the former requires string-list to be sorted, it is clear that these places are sorting only to remove duplicates and for no other reason. Introduce a helper function string_list_sort_u that combines these two calls that often appear together, to simplify these callsites. Replace the current calls of those methods with string_list_sort_u(). Signed-off-by: Amisha Chhajed Signed-off-by: Junio C Hamano --- string-list.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'string-list.h') diff --git a/string-list.h b/string-list.h index fa6ba07853..3ad862a187 100644 --- a/string-list.h +++ b/string-list.h @@ -239,6 +239,12 @@ struct string_list_item *string_list_append_nodup(struct string_list *list, char */ void string_list_sort(struct string_list *list); +/** + * Sort the list and then remove duplicate entries. If free_util is true, + * call free() on the util members of any items that have to be deleted. + */ +void string_list_sort_u(struct string_list *list, int free_util); + /** * Like `string_list_has_string()` but for unsorted lists. Linear in * size of the list. -- cgit v1.3