Skip to content

Commit 78a395d

Browse files
qurgitster
authored andcommitted
string_list: Fix argument order for string_list_insert
Update the definition and callers of string_list_insert to use the string_list as the first argument. This helps make the string_list API easier to use by being more consistent. Signed-off-by: Julian Phillips <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b684e97 commit 78a395d

19 files changed

+40
-40
lines changed

builtin/apply.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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;

builtin/commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ static int list_paths(struct string_list *list, const char *with_tree,
212212
continue;
213213
if (!match_pathspec(pattern, ce->name, ce_namelen(ce), 0, m))
214214
continue;
215-
item = string_list_insert(ce->name, list);
215+
item = string_list_insert(list, ce->name);
216216
if (ce_skip_worktree(ce))
217217
item->util = item; /* better a valid pointer than a fake one */
218218
}

builtin/fetch.c

Lines changed: 2 additions & 2 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
}
@@ -616,7 +616,7 @@ static void find_non_local_tags(struct transport *transport,
616616
string_list_has_string(&existing_refs, ref->name))
617617
continue;
618618

619-
item = string_list_insert(ref->name, &remote_refs);
619+
item = string_list_insert(&remote_refs, ref->name);
620620
item->util = (void *)ref->old_sha1;
621621
}
622622
string_list_clear(&existing_refs, 0);

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) {

builtin/remote.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ static int config_read_branches(const char *key, const char *value, void *cb)
251251
} else
252252
return 0;
253253

254-
item = string_list_insert(name, &branch_list);
254+
item = string_list_insert(&branch_list, name);
255255

256256
if (!item->util)
257257
item->util = xcalloc(sizeof(struct branch_info), 1);
@@ -870,7 +870,7 @@ static int add_remote_to_show_info(struct string_list_item *item, void *cb_data)
870870
int n = strlen(item->string);
871871
if (n > info->width)
872872
info->width = n;
873-
string_list_insert(item->string, info->list);
873+
string_list_insert(info->list, item->string);
874874
return 0;
875875
}
876876

@@ -917,7 +917,7 @@ static int add_local_to_show_info(struct string_list_item *branch_item, void *cb
917917
if (branch_info->rebase)
918918
show_info->any_rebase = 1;
919919

920-
item = string_list_insert(branch_item->string, show_info->list);
920+
item = string_list_insert(show_info->list, branch_item->string);
921921
item->util = branch_info;
922922

923923
return 0;

builtin/shortlog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static void insert_one_record(struct shortlog *log,
8484
snprintf(namebuf + len, room, " <%.*s>", maillen, emailbuf);
8585
}
8686

87-
item = string_list_insert(namebuf, &log->list);
87+
item = string_list_insert(&log->list, namebuf);
8888
if (item->util == NULL)
8989
item->util = xcalloc(1, sizeof(struct string_list));
9090

builtin/show-ref.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ static int show_ref(const char *refname, const unsigned char *sha1, int flag, vo
105105
static int add_existing(const char *refname, const unsigned char *sha1, int flag, void *cbdata)
106106
{
107107
struct string_list *list = (struct string_list *)cbdata;
108-
string_list_insert(refname, list);
108+
string_list_insert(list, refname);
109109
return 0;
110110
}
111111

diff-no-index.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static int read_directory(const char *path, struct string_list *list)
2626

2727
while ((e = readdir(dir)))
2828
if (strcmp(".", e->d_name) && strcmp("..", e->d_name))
29-
string_list_insert(e->d_name, list);
29+
string_list_insert(list, e->d_name);
3030

3131
closedir(dir);
3232
return 0;

http-backend.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static struct string_list *get_parameters(void)
9292

9393
i = string_list_lookup(name, query_params);
9494
if (!i)
95-
i = string_list_insert(name, query_params);
95+
i = string_list_insert(query_params, name);
9696
else
9797
free(i->util);
9898
i->util = value;

0 commit comments

Comments
 (0)