public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: Amisha Chhajed <amishhhaaaa@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
	Derrick Stolee <stolee@gmail.com>,
	Elijah Newren <newren@gmail.com>, Jeff King <peff@peff.net>,
	amisha <amishhhaaaa@gmail.com>
Subject: [RFC PATCH 1/2] Adding string_list_sort_u which sorts a list then deduplicates it.
Date: Thu, 22 Jan 2026 22:45:22 +0530	[thread overview]
Message-ID: <20260122171523.94234-2-amishhhaaaa@gmail.com> (raw)
In-Reply-To: <20260122171523.94234-1-amishhhaaaa@gmail.com>

string_list_remove_duplicates is almost always preceeded by
string_list_sort, hence adding string_list_sort_u which dedupliactes
post sorting.

Signed-off-by: Amisha Chhajed <amishhhaaaa@gmail.com>
---
 string-list.c | 6 ++++++
 string-list.h | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/string-list.c b/string-list.c
index 08dc00984c..020ed8fef7 100644
--- a/string-list.c
+++ b/string-list.c
@@ -247,6 +247,12 @@ void string_list_sort(struct string_list *list)
 	QSORT_S(list->items, list->nr, cmp_items, &sort_ctx);
 }
 
+void string_list_sort_u(struct string_list *list, int free_util)
+{
+	string_list_sort(list);
+	string_list_remove_duplicates(list, free_util);
+}
+
 struct string_list_item *unsorted_string_list_lookup(struct string_list *list,
 						     const char *string)
 {
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.
-- 
2.51.0


  reply	other threads:[~2026-01-22 17:15 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-22 17:15 [RFC PATCH 0/2] Adding string_list_sort_u to replace combined calls of string_list_sort and string_list_remove_duplicates calls Amisha Chhajed
2026-01-22 17:15 ` Amisha Chhajed [this message]
2026-01-22 22:07   ` [RFC PATCH 1/2] Adding string_list_sort_u which sorts a list then deduplicates it Junio C Hamano
2026-01-25 20:23     ` Amisha Chhajed
2026-01-22 17:15 ` [RFC PATCH 2/2] Replacing calls of string_list_sort and string_list_remove_duplicates with the combined variant string_list_u Amisha Chhajed
2026-01-22 22:19   ` Junio C Hamano
2026-01-22 22:09 ` [RFC PATCH 0/2] Adding string_list_sort_u to replace combined calls of string_list_sort and string_list_remove_duplicates calls Junio C Hamano
2026-01-25 20:14 ` [PATCH 1/2] u-string-list: add unit tests for string-list methods Amisha Chhajed
2026-01-25 20:15   ` [PATCH 2/2] string-list: add string_list_sort_u() that mimics "sort -u" Amisha Chhajed
2026-01-29 12:12     ` [PATCH v3 1/2] u-string-list: add unit tests for string-list methods Amisha Chhajed
2026-01-29 12:12       ` [PATCH v3 2/2] string-list: add string_list_sort_u() that mimics "sort -u" Amisha Chhajed
2026-01-29 12:14       ` [PATCH v3 1/2] u-string-list: add unit tests for string-list methods Amisha Chhajed
2026-01-30 19:51     ` [PATCH 2/2] string-list: add string_list_sort_u() that mimics "sort -u" Kristoffer Haugsbakk
2026-01-30 21:45       ` Junio C Hamano
2026-01-26  7:12   ` [PATCH 1/2] u-string-list: add unit tests for string-list methods Junio C Hamano
2026-01-26 18:57     ` Amisha Chhajed
2026-01-26 19:12       ` Junio C Hamano
2026-01-25 20:17 ` Amisha Chhajed
2026-01-25 20:17   ` [PATCH 2/2] string-list: add string_list_sort_u() that mimics "sort -u" Amisha Chhajed
2026-01-26 18:56 ` [PATCH v2 1/2] u-string-list: add unit tests for string-list methods Amisha Chhajed
2026-01-26 18:56   ` [PATCH v2 2/2] string-list: add string_list_sort_u() that mimics "sort -u" Amisha Chhajed
2026-01-26 20:11     ` Junio C Hamano
2026-01-27  1:27       ` Amisha Chhajed
2026-01-26 19:50   ` [PATCH v2 1/2] u-string-list: add unit tests for string-list methods Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260122171523.94234-2-amishhhaaaa@gmail.com \
    --to=amishhhaaaa@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=newren@gmail.com \
    --cc=peff@peff.net \
    --cc=stolee@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox