<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/string-list.c, branch jch</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=jch</id>
<link rel='self' href='https://git.shady.money/git/atom?h=jch'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2026-03-25T21:00:45Z</updated>
<entry>
<title>hook: move unsorted_string_list_remove() to string-list.[ch]</title>
<updated>2026-03-25T21:00:45Z</updated>
<author>
<name>Adrian Ratiu</name>
<email>adrian.ratiu@collabora.com</email>
</author>
<published>2026-03-25T19:54:52Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=add3564d2f2804ad37b9af773ec6420b497a1725'/>
<id>urn:sha1:add3564d2f2804ad37b9af773ec6420b497a1725</id>
<content type='text'>
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 &lt;ps@pks.im&gt;
Signed-off-by: Adrian Ratiu &lt;adrian.ratiu@collabora.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'cf/c23-const-preserving-strchr-updates-0'</title>
<updated>2026-02-13T21:39:25Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2026-02-13T21:39:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=7855effc952777f2fac284e4461743cf5aa20ee6'/>
<id>urn:sha1:7855effc952777f2fac284e4461743cf5aa20ee6</id>
<content type='text'>
ISO C23 redefines strchr and friends that tradiotionally took
a const pointer and returned a non-const pointer derived from it to
preserve constness (i.e., if you ask for a substring in a const
string, you get a const pointer to the substring).  Update code
paths that used non-const pointer to receive their results that did
not have to be non-const to adjust.

* cf/c23-const-preserving-strchr-updates-0:
  gpg-interface: remove an unnecessary NULL initialization
  global: constify some pointers that are not written to
</content>
</entry>
<entry>
<title>global: constify some pointers that are not written to</title>
<updated>2026-02-06T01:52:49Z</updated>
<author>
<name>Collin Funk</name>
<email>collin.funk1@gmail.com</email>
</author>
<published>2026-02-06T01:46:09Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=4ac4705afa3ab660e206c2b870bfae2ddb647ffa'/>
<id>urn:sha1:4ac4705afa3ab660e206c2b870bfae2ddb647ffa</id>
<content type='text'>
The recent glibc 2.43 release had the following change listed in its
NEWS file:

    For ISO C23, the functions bsearch, memchr, strchr, strpbrk, strrchr,
    strstr, wcschr, wcspbrk, wcsrchr, wcsstr and wmemchr that return
    pointers into their input arrays now have definitions as macros that
    return a pointer to a const-qualified type when the input argument is
    a pointer to a const-qualified type.

When compiling with GCC 15, which defaults to -std=gnu23, this causes
many warnings like this:

    merge-ort.c: In function ‘apply_directory_rename_modifications’:
    merge-ort.c:2734:36: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
     2734 |                 char *last_slash = strrchr(cur_path, '/');
          |                                    ^~~~~~~

This patch fixes the more obvious ones by making them const when we do
not write to the returned pointer.

Signed-off-by: Collin Funk &lt;collin.funk1@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>string-list: add string_list_sort_u() that mimics "sort -u"</title>
<updated>2026-01-29T17:32:50Z</updated>
<author>
<name>Amisha Chhajed</name>
<email>amishhhaaaa@gmail.com</email>
</author>
<published>2026-01-29T12:12:20Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2e711acfbdfc0fedf631688d78cde153ba835c93'/>
<id>urn:sha1:2e711acfbdfc0fedf631688d78cde153ba835c93</id>
<content type='text'>
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 &lt;amishhhaaaa@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>string-list: change "string_list_find_insert_index" return type to "size_t"</title>
<updated>2025-10-06T16:11:07Z</updated>
<author>
<name>shejialuo</name>
<email>shejialuo@gmail.com</email>
</author>
<published>2025-10-06T06:32:40Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=51c3385e3736aeb5f78cc9ed193779e2cb4a2a29'/>
<id>urn:sha1:51c3385e3736aeb5f78cc9ed193779e2cb4a2a29</id>
<content type='text'>
As "string_list_find_insert_index" is a simple wrapper of
"get_entry_index" and the return type of "get_entry_index" is already
"size_t", we could simply change its return type to "size_t".

Update all callers to use size_t variables for storing the return value.
The tricky fix is the loop condition in "mailmap.c" to properly handle
"size_t" underflow by changing from `0 &lt;= --i` to `i--`.

Remove "DISABLE_SIGN_COMPARE_WARNINGS" from "mailmap.c" as it's no
longer needed with the proper unsigned types.

Signed-off-by: shejialuo &lt;shejialuo@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>string-list: replace negative index encoding with "exact_match" parameter</title>
<updated>2025-10-06T16:11:07Z</updated>
<author>
<name>shejialuo</name>
<email>shejialuo@gmail.com</email>
</author>
<published>2025-10-06T06:32:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e8a32e766fe3f5e40fb8918a4d825e6d0b9aa272'/>
<id>urn:sha1:e8a32e766fe3f5e40fb8918a4d825e6d0b9aa272</id>
<content type='text'>
The "string_list_find_insert_index()" function is used to determine
the correct insertion index for a new string within the string list.
The function also doubles up to convey if the string is already
existing in the list, this is done by returning a negative index
"-1 -index". Users are expected to decode this information. This
approach has several limitations:

1. It requires the callers to look into the detail of the function to
   understand how to decode the negative index encoding.
2. Using int for indices can cause overflow issues when dealing with
   large string lists.

To address these limitations, change the function to return size_t for
the index value and use a separate bool parameter to indicate whether
the index refers to an existing entry or an insertion point.

In some cases, the callers of "string_list_find_insert_index" only need
the index position and don't care whether an exact match is found.
However, "get_entry_index" currently requires a non-NULL "exact_match"
parameter, forcing these callers to declare unnecessary variables.
Let's allow callers to pass NULL for the "exact_match" parameter when
they don't need this information, reducing unnecessary variable
declarations in calling code.

Signed-off-by: shejialuo &lt;shejialuo@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>string-list: use bool instead of int for "exact_match"</title>
<updated>2025-10-06T16:11:07Z</updated>
<author>
<name>shejialuo</name>
<email>shejialuo@gmail.com</email>
</author>
<published>2025-10-06T06:32:23Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=03ef7762ea12f3b034a2281040bd61c74fd36386'/>
<id>urn:sha1:03ef7762ea12f3b034a2281040bd61c74fd36386</id>
<content type='text'>
The "exact_match" parameter in "get_entry_index" is used to indicate
whether a string is found or not, which is fundamentally a true/false
value. As we allow the use of bool, let's use bool instead of int to
make the function more semantically clear.

Signed-off-by: shejialuo &lt;shejialuo@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>string-list: optionally omit empty string pieces in string_list_split*()</title>
<updated>2025-08-03T05:34:45Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2025-08-01T22:04:22Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=27531efa41cfa882473513dd93e696a16f6eb87b'/>
<id>urn:sha1:27531efa41cfa882473513dd93e696a16f6eb87b</id>
<content type='text'>
Teach the unified split_string() machinery a new flag bit,
STRING_LIST_SPLIT_NONEMPTY, to cause empty split pieces to be
omitted from the resulting string list.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>string-list: optionally trim string pieces split by string_list_split*()</title>
<updated>2025-08-03T05:34:32Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2025-08-01T22:04:20Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=576454974165d51b7e39c0608cde1c84978f1a8a'/>
<id>urn:sha1:576454974165d51b7e39c0608cde1c84978f1a8a</id>
<content type='text'>
Teach the unified split_string() to take an optional "flags" word,
and define the first flag STRING_LIST_SPLIT_TRIM to cause the split
pieces to be trimmed before they are placed in the string list.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>string-list: unify string_list_split* functions</title>
<updated>2025-08-03T05:33:12Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2025-08-01T22:04:19Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=527535fcdd2d9dec56877435f609852d0f2bf163'/>
<id>urn:sha1:527535fcdd2d9dec56877435f609852d0f2bf163</id>
<content type='text'>
Thanks to the previous step, the only difference between these two
related functions is that string_list_split() works on a string
without modifying its contents (i.e. taking "const char *") and the
resulting pieces of strings are their own copies in a string list,
while string_list_split_in_place() works on a mutable string and the
resulting pieces of strings come from the original string.

Consolidate their implementations into a single helper function, and
make them a thin wrapper around it.  We can later add an extra flags
parameter to extend both of these functions by updating only the
internal helper function.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
