Skip to content

Commit a53deac

Browse files
committed
Merge branch 'jp/string-list-api-cleanup'
* jp/string-list-api-cleanup: string_list: Fix argument order for string_list_append string_list: Fix argument order for string_list_lookup string_list: Fix argument order for string_list_insert_at_index string_list: Fix argument order for string_list_insert string_list: Fix argument order for for_each_string_list string_list: Fix argument order for print_string_list
2 parents 6296062 + 1d2f80f commit a53deac

29 files changed

+147
-147
lines changed

Documentation/technical/api-string-list.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ struct string_list list;
3838
int i;
3939

4040
memset(&list, 0, sizeof(struct string_list));
41-
string_list_append("foo", &list);
42-
string_list_append("bar", &list);
41+
string_list_append(&list, "foo");
42+
string_list_append(&list, "bar");
4343
for (i = 0; i < list.nr; i++)
4444
printf("%s\n", list.items[i].string)
4545
----

builtin/apply.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2628,7 +2628,7 @@ static struct patch *in_fn_table(const char *name)
26282628
if (name == NULL)
26292629
return NULL;
26302630

2631-
item = string_list_lookup(name, &fn_table);
2631+
item = string_list_lookup(&fn_table, name);
26322632
if (item != NULL)
26332633
return (struct patch *)item->util;
26342634

@@ -2664,7 +2664,7 @@ static void add_to_fn_table(struct patch *patch)
26642664
* file creations and copies
26652665
*/
26662666
if (patch->new_name != NULL) {
2667-
item = string_list_insert(patch->new_name, &fn_table);
2667+
item = string_list_insert(&fn_table, patch->new_name);
26682668
item->util = patch;
26692669
}
26702670

@@ -2673,7 +2673,7 @@ static void add_to_fn_table(struct patch *patch)
26732673
* later chunks shouldn't patch old names
26742674
*/
26752675
if ((patch->new_name == NULL) || (patch->is_rename)) {
2676-
item = string_list_insert(patch->old_name, &fn_table);
2676+
item = string_list_insert(&fn_table, patch->old_name);
26772677
item->util = PATH_WAS_DELETED;
26782678
}
26792679
}
@@ -2686,7 +2686,7 @@ static void prepare_fn_table(struct patch *patch)
26862686
while (patch) {
26872687
if ((patch->new_name == NULL) || (patch->is_rename)) {
26882688
struct string_list_item *item;
2689-
item = string_list_insert(patch->old_name, &fn_table);
2689+
item = string_list_insert(&fn_table, patch->old_name);
26902690
item->util = PATH_TO_BE_DELETED;
26912691
}
26922692
patch = patch->next;
@@ -3394,7 +3394,7 @@ static void add_name_limit(const char *name, int exclude)
33943394
{
33953395
struct string_list_item *it;
33963396

3397-
it = string_list_append(name, &limit_by_name);
3397+
it = string_list_append(&limit_by_name, name);
33983398
it->util = exclude ? NULL : (void *) 1;
33993399
}
34003400

builtin/commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ static int list_paths(struct string_list *list, const char *with_tree,
219219
continue;
220220
if (!match_pathspec(pattern, ce->name, ce_namelen(ce), 0, m))
221221
continue;
222-
item = string_list_insert(ce->name, list);
222+
item = string_list_insert(list, ce->name);
223223
if (ce_skip_worktree(ce))
224224
item->util = item; /* better a valid pointer than a fake one */
225225
}

builtin/fast-export.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ static void get_tags_and_duplicates(struct object_array *pending,
438438
/* handle nested tags */
439439
while (tag && tag->object.type == OBJ_TAG) {
440440
parse_object(tag->object.sha1);
441-
string_list_append(full_name, extra_refs)->util = tag;
441+
string_list_append(extra_refs, full_name)->util = tag;
442442
tag = (struct tag *)tag->tagged;
443443
}
444444
if (!tag)
@@ -464,7 +464,7 @@ static void get_tags_and_duplicates(struct object_array *pending,
464464
}
465465
if (commit->util)
466466
/* more than one name for the same object */
467-
string_list_append(full_name, extra_refs)->util = commit;
467+
string_list_append(extra_refs, full_name)->util = commit;
468468
else
469469
commit->util = full_name;
470470
}

builtin/fetch.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ static int add_existing(const char *refname, const unsigned char *sha1,
528528
int flag, void *cbdata)
529529
{
530530
struct string_list *list = (struct string_list *)cbdata;
531-
struct string_list_item *item = string_list_insert(refname, list);
531+
struct string_list_item *item = string_list_insert(list, refname);
532532
item->util = (void *)sha1;
533533
return 0;
534534
}
@@ -617,7 +617,7 @@ static void find_non_local_tags(struct transport *transport,
617617
string_list_has_string(&existing_refs, ref->name))
618618
continue;
619619

620-
item = string_list_insert(ref->name, &remote_refs);
620+
item = string_list_insert(&remote_refs, ref->name);
621621
item->util = (void *)ref->old_sha1;
622622
}
623623
string_list_clear(&existing_refs, 0);
@@ -634,7 +634,7 @@ static void find_non_local_tags(struct transport *transport,
634634
* For all the tags in the remote_refs string list, call
635635
* add_to_tail to add them to the list of refs to be fetched
636636
*/
637-
for_each_string_list(add_to_tail, &remote_refs, &data);
637+
for_each_string_list(&remote_refs, add_to_tail, &data);
638638

639639
string_list_clear(&remote_refs, 0);
640640
}
@@ -696,8 +696,8 @@ static int do_fetch(struct transport *transport,
696696

697697
for (rm = ref_map; rm; rm = rm->next) {
698698
if (rm->peer_ref) {
699-
peer_item = string_list_lookup(rm->peer_ref->name,
700-
&existing_refs);
699+
peer_item = string_list_lookup(&existing_refs,
700+
rm->peer_ref->name);
701701
if (peer_item)
702702
hashcpy(rm->peer_ref->old_sha1,
703703
peer_item->util);
@@ -746,7 +746,7 @@ static int get_one_remote_for_fetch(struct remote *remote, void *priv)
746746
{
747747
struct string_list *list = priv;
748748
if (!remote->skip_default_update)
749-
string_list_append(remote->name, list);
749+
string_list_append(list, remote->name);
750750
return 0;
751751
}
752752

@@ -765,8 +765,8 @@ static int get_remote_group(const char *key, const char *value, void *priv)
765765
int space = strcspn(value, " \t\n");
766766
while (*value) {
767767
if (space > 1) {
768-
string_list_append(xstrndup(value, space),
769-
g->list);
768+
string_list_append(g->list,
769+
xstrndup(value, space));
770770
}
771771
value += space + (value[space] != '\0');
772772
space = strcspn(value, " \t\n");
@@ -788,7 +788,7 @@ static int add_remote_or_group(const char *name, struct string_list *list)
788788
if (!remote_is_configured(name))
789789
return 0;
790790
remote = remote_get(name);
791-
string_list_append(remote->name, list);
791+
string_list_append(list, remote->name);
792792
}
793793
return 1;
794794
}

builtin/fmt-merge-msg.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static int handle_line(char *line)
8282

8383
item = unsorted_string_list_lookup(&srcs, src);
8484
if (!item) {
85-
item = string_list_append(src, &srcs);
85+
item = string_list_append(&srcs, src);
8686
item->util = xcalloc(1, sizeof(struct src_data));
8787
init_src_data(item->util);
8888
}
@@ -93,19 +93,19 @@ static int handle_line(char *line)
9393
src_data->head_status |= 1;
9494
} else if (!prefixcmp(line, "branch ")) {
9595
origin = line + 7;
96-
string_list_append(origin, &src_data->branch);
96+
string_list_append(&src_data->branch, origin);
9797
src_data->head_status |= 2;
9898
} else if (!prefixcmp(line, "tag ")) {
9999
origin = line;
100-
string_list_append(origin + 4, &src_data->tag);
100+
string_list_append(&src_data->tag, origin + 4);
101101
src_data->head_status |= 2;
102102
} else if (!prefixcmp(line, "remote branch ")) {
103103
origin = line + 14;
104-
string_list_append(origin, &src_data->r_branch);
104+
string_list_append(&src_data->r_branch, origin);
105105
src_data->head_status |= 2;
106106
} else {
107107
origin = src;
108-
string_list_append(line, &src_data->generic);
108+
string_list_append(&src_data->generic, line);
109109
src_data->head_status |= 2;
110110
}
111111

@@ -118,7 +118,7 @@ static int handle_line(char *line)
118118
sprintf(new_origin, "%s of %s", origin, src);
119119
origin = new_origin;
120120
}
121-
string_list_append(origin, &origins)->util = sha1;
121+
string_list_append(&origins, origin)->util = sha1;
122122
return 0;
123123
}
124124

@@ -176,10 +176,10 @@ static void shortlog(const char *name, unsigned char *sha1,
176176
strbuf_ltrim(&sb);
177177

178178
if (!sb.len)
179-
string_list_append(sha1_to_hex(commit->object.sha1),
180-
&subjects);
179+
string_list_append(&subjects,
180+
sha1_to_hex(commit->object.sha1));
181181
else
182-
string_list_append(strbuf_detach(&sb, NULL), &subjects);
182+
string_list_append(&subjects, strbuf_detach(&sb, NULL));
183183
}
184184

185185
if (count > limit)

builtin/log.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -535,13 +535,13 @@ static void add_header(const char *value)
535535
len--;
536536

537537
if (!strncasecmp(value, "to: ", 4)) {
538-
item = string_list_append(value + 4, &extra_to);
538+
item = string_list_append(&extra_to, value + 4);
539539
len -= 4;
540540
} else if (!strncasecmp(value, "cc: ", 4)) {
541-
item = string_list_append(value + 4, &extra_cc);
541+
item = string_list_append(&extra_cc, value + 4);
542542
len -= 4;
543543
} else {
544-
item = string_list_append(value, &extra_hdr);
544+
item = string_list_append(&extra_hdr, value);
545545
}
546546

547547
item->string[len] = '\0';
@@ -566,13 +566,13 @@ static int git_format_config(const char *var, const char *value, void *cb)
566566
if (!strcmp(var, "format.to")) {
567567
if (!value)
568568
return config_error_nonbool(var);
569-
string_list_append(value, &extra_to);
569+
string_list_append(&extra_to, value);
570570
return 0;
571571
}
572572
if (!strcmp(var, "format.cc")) {
573573
if (!value)
574574
return config_error_nonbool(var);
575-
string_list_append(value, &extra_cc);
575+
string_list_append(&extra_cc, value);
576576
return 0;
577577
}
578578
if (!strcmp(var, "diff.color") || !strcmp(var, "color.diff")) {
@@ -959,7 +959,7 @@ static int to_callback(const struct option *opt, const char *arg, int unset)
959959
if (unset)
960960
string_list_clear(&extra_to, 0);
961961
else
962-
string_list_append(arg, &extra_to);
962+
string_list_append(&extra_to, arg);
963963
return 0;
964964
}
965965

@@ -968,7 +968,7 @@ static int cc_callback(const struct option *opt, const char *arg, int unset)
968968
if (unset)
969969
string_list_clear(&extra_cc, 0);
970970
else
971-
string_list_append(arg, &extra_cc);
971+
string_list_append(&extra_cc, arg);
972972
return 0;
973973
}
974974

@@ -1251,7 +1251,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
12511251
rev.ref_message_ids = xcalloc(1, sizeof(struct string_list));
12521252
if (in_reply_to) {
12531253
const char *msgid = clean_message_id(in_reply_to);
1254-
string_list_append(msgid, rev.ref_message_ids);
1254+
string_list_append(rev.ref_message_ids, msgid);
12551255
}
12561256
rev.numbered_files = numbered_files;
12571257
rev.patch_suffix = fmt_patch_suffix;
@@ -1298,8 +1298,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
12981298
&& (!cover_letter || rev.nr > 1))
12991299
free(rev.message_id);
13001300
else
1301-
string_list_append(rev.message_id,
1302-
rev.ref_message_ids);
1301+
string_list_append(rev.ref_message_ids,
1302+
rev.message_id);
13031303
}
13041304
gen_message_id(&rev, sha1_to_hex(commit->object.sha1));
13051305
}

builtin/ls-files.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ static void show_ru_info(void)
190190
{
191191
if (!the_index.resolve_undo)
192192
return;
193-
for_each_string_list(show_one_ru, the_index.resolve_undo, NULL);
193+
for_each_string_list(the_index.resolve_undo, show_one_ru, NULL);
194194
}
195195

196196
static void show_files(struct dir_struct *dir)

builtin/mailsplit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ static int populate_maildir_list(struct string_list *list, const char *path)
121121
if (dent->d_name[0] == '.')
122122
continue;
123123
snprintf(name, sizeof(name), "%s/%s", *sub, dent->d_name);
124-
string_list_insert(name, list);
124+
string_list_insert(list, name);
125125
}
126126

127127
closedir(dir);

builtin/mv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
180180
} else if (string_list_has_string(&src_for_dst, dst))
181181
bad = "multiple sources for the same target";
182182
else
183-
string_list_insert(dst, &src_for_dst);
183+
string_list_insert(&src_for_dst, dst);
184184

185185
if (bad) {
186186
if (ignore_errors) {

0 commit comments

Comments
 (0)