Re: [RFC PATCH 1/2] Adding string_list_sort_u which sorts a list then deduplicates it.
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 22, 2026, 22:07 UTC
- Message-ID
- <xmqqcy31l2s2.fsf@gitster.g>
- In-Reply-To
- <20260122171523.94234-2-amishhhaaaa@gmail.com>
Amisha Chhajed <amishhhaaaa@gmail.com> writes:
> string_list_remove_duplicates is almost always preceeded by > string_list_sort, hence adding string_list_sort_u which dedupliactes > post sorting.
The usual way to compose a log message of this project is to
- Give an observation on how the current system works in the present tense (so no need to say "Currently X is Y", or "Previously X was Y" to describe the state before your change; just "X is Y" is enough), and discuss what you perceive as a problem in it.
- Propose a solution (optional---often, problem description trivially leads to an obvious solution in reader's minds).
- Give commands to somebody editing the codebase to "make it so", instead of saying "This commit does X".
in this order.
To those who have been intimately following the discussion, it often is understandable without some of the above, but we are not writing for those who review the patches. We are primarily writing for future readers of "git log" who are not aware of the review discussion we have on list, so we should give something to prepare them by setting the stage and stating the objective first, before going into how the patch solved it.
With that in mind, perhaps something along this line ...
Subject: string-list: add string_list_sort_u() that mimics "sort -u"
Many callsites of string_list_remove_duplicates() call it
immediately after calling string_list_sort(). It is
understandable because the former requires the string-list to be
sorted, but at the same time, 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 help simplify
these callsites.... probably?
The same comment applies to the way the other patch is explained.
Thanks.