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 --- builtin/pack-objects.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'builtin/pack-objects.c') diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 5846b6a293..9807dd0eff 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -3855,10 +3855,8 @@ static void read_packs_list_from_stdin(struct rev_info *revs) strbuf_reset(&buf); } - string_list_sort(&include_packs); - string_list_remove_duplicates(&include_packs, 0); - string_list_sort(&exclude_packs); - string_list_remove_duplicates(&exclude_packs, 0); + string_list_sort_u(&include_packs, 0); + string_list_sort_u(&exclude_packs, 0); repo_for_each_pack(the_repository, p) { const char *pack_name = pack_basename(p); -- cgit v1.3