[PATCH 0/5] string_list_split*() updates
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 31, 2025, 06:39 UTC
- Message-ID
- <20250731063949.1601669-1-gitster@pobox.com>
Two related string-list API functions, string_list_split() and string_list_split_in_place(), more or less duplicates their implementations. They both take a single string, and split the string at the delimiter and stuff the result into a string list.
However, there is one subtle and unnecessary difference. The non "in-place" variant only allows a single byte value as delimiter, while the "in-place" variant can take multiple delimiters (e.g., "split at either a comma or a space").
This series first updates the string_list_split() to allow multiple delimiters like string_list_split_in_place() does, unifies their implementations into one. This refactoring allows us to give new feature to these two functions with a single chnage.
Then these functions learn to optionally trim the split string pieces before placing them in the resulting string list.
An existing caller of string_list_split() in diff.c trims the elements in the resulting string list before it uses them, which is simplified by taking advantage of this new feature.
Junio C Hamano (5):
string-list: report programming error with BUG
string-list: align string_list_split() with its _in_place()
counterpart
string-list: unify string_list_split* functions
string-list: optionally trim string pieces split by
string_list_split()
diff: simplify parsing of diff.colormovedwsbuiltin/blame.c | 2 +- builtin/merge.c | 2 +- builtin/var.c | 2 +- connect.c | 2 +- diff.c | 20 +++---- fetch-pack.c | 2 +- notes.c | 2 +- parse-options.c | 2 +- pathspec.c | 2 +- protocol.c | 2 +- ref-filter.c | 4 +- setup.c | 3 +- string-list.c | 113 +++++++++++++++++++++++------------ string-list.h | 26 +++++--- t/helper/test-path-utils.c | 3 +- t/helper/test-ref-store.c | 2 +- t/unit-tests/u-string-list.c | 80 ++++++++++++++++++++++--- transport.c | 2 +- upload-pack.c | 2 +- 19 files changed, 190 insertions(+), 83 deletions(-)
-- 2.50.1-612-g4756c59422