Skip to content

Commit cc80bac

Browse files
committed
string-list: align string_list_split() with its _in_place() counterpart
For some unknown reason, unlike string_list_split_in_place(), string_list_split() took only a single character as a field delimiter. Before giving both functions more features in future commits, allow string_list_split() to take more than one delimiter characters to make them closer to each other. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 442ed67 commit cc80bac

19 files changed

+37
-35
lines changed

builtin/blame.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ static void parse_color_fields(const char *s)
420420
colorfield_nr = 0;
421421

422422
/* Ideally this would be stripped and split at the same time? */
423-
string_list_split(&l, s, ',', -1);
423+
string_list_split(&l, s, ",", -1);
424424
ALLOC_GROW(colorfield, colorfield_nr + 1, colorfield_alloc);
425425

426426
for_each_string_list_item(item, &l) {

builtin/merge.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ static void add_strategies(const char *string, unsigned attr)
875875
if (string) {
876876
struct string_list list = STRING_LIST_INIT_DUP;
877877
struct string_list_item *item;
878-
string_list_split(&list, string, ' ', -1);
878+
string_list_split(&list, string, " ", -1);
879879
for_each_string_list_item(item, &list)
880880
append_strategy(get_strategy(item->string));
881881
string_list_clear(&list, 0);

builtin/var.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ static void list_vars(void)
181181
if (ptr->multivalued && *val) {
182182
struct string_list list = STRING_LIST_INIT_DUP;
183183

184-
string_list_split(&list, val, '\n', -1);
184+
string_list_split(&list, val, "\n", -1);
185185
for (size_t i = 0; i < list.nr; i++)
186186
printf("%s=%s\n", ptr->name, list.items[i].string);
187187
string_list_clear(&list, 0);

connect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ static int process_ref_v2(struct packet_reader *reader, struct ref ***list,
407407
* name. Subsequent fields (symref-target and peeled) are optional and
408408
* don't have a particular order.
409409
*/
410-
if (string_list_split(&line_sections, line, ' ', -1) < 2) {
410+
if (string_list_split(&line_sections, line, " ", -1) < 2) {
411411
ret = 0;
412412
goto out;
413413
}

diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ static unsigned parse_color_moved_ws(const char *arg)
327327
struct string_list l = STRING_LIST_INIT_DUP;
328328
struct string_list_item *i;
329329

330-
string_list_split(&l, arg, ',', -1);
330+
string_list_split(&l, arg, ",", -1);
331331

332332
for_each_string_list_item(i, &l) {
333333
struct strbuf sb = STRBUF_INIT;

fetch-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1914,7 +1914,7 @@ static void fetch_pack_config(void)
19141914
char *str;
19151915

19161916
if (!git_config_get_string("fetch.uriprotocols", &str) && str) {
1917-
string_list_split(&uri_protocols, str, ',', -1);
1917+
string_list_split(&uri_protocols, str, ",", -1);
19181918
free(str);
19191919
}
19201920
}

notes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ static int string_list_add_note_lines(struct string_list *list,
892892
* later, along with any empty strings that came from empty
893893
* lines within the file.
894894
*/
895-
string_list_split(list, data, '\n', -1);
895+
string_list_split(list, data, "\n", -1);
896896
free(data);
897897
return 0;
898898
}

parse-options.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,7 @@ static enum parse_opt_result usage_with_options_internal(struct parse_opt_ctx_t
13381338
if (!saw_empty_line && !*str)
13391339
saw_empty_line = 1;
13401340

1341-
string_list_split(&list, str, '\n', -1);
1341+
string_list_split(&list, str, "\n", -1);
13421342
for (j = 0; j < list.nr; j++) {
13431343
const char *line = list.items[j].string;
13441344

pathspec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ static void parse_pathspec_attr_match(struct pathspec_item *item, const char *va
201201
if (!value || !*value)
202202
die(_("attr spec must not be empty"));
203203

204-
string_list_split(&list, value, ' ', -1);
204+
string_list_split(&list, value, " ", -1);
205205
string_list_remove_empty_items(&list, 0);
206206

207207
item->attr_check = attr_check_alloc();

protocol.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ enum protocol_version determine_protocol_version_server(void)
6161
if (git_protocol) {
6262
struct string_list list = STRING_LIST_INIT_DUP;
6363
const struct string_list_item *item;
64-
string_list_split(&list, git_protocol, ':', -1);
64+
string_list_split(&list, git_protocol, ":", -1);
6565

6666
for_each_string_list_item(item, &list) {
6767
const char *value;

0 commit comments

Comments
 (0)