Skip to content

Commit 0c72cea

Browse files
qurgitster
authored andcommitted
Merge branch 'jp/string-list-api-cleanup' into jn/grep-open
An evil merge to adjust the series to cleaned-up API. From: Julian Phillips <[email protected]> Subject: [PATCH v2 7/7] grep: fix string_list_append calls Date: Sat, 26 Jun 2010 00:41:39 +0100 Message-ID: <[email protected]> * 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 Signed-off-by: Julian Phillips <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
2 parents 7f5329f + 1d2f80f commit 0c72cea

30 files changed

+150
-150
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
@@ -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/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
}
@@ -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);
@@ -633,7 +633,7 @@ static void find_non_local_tags(struct transport *transport,
633633
* For all the tags in the remote_refs string list, call
634634
* add_to_tail to add them to the list of refs to be fetched
635635
*/
636-
for_each_string_list(add_to_tail, &remote_refs, &data);
636+
for_each_string_list(&remote_refs, add_to_tail, &data);
637637

638638
string_list_clear(&remote_refs, 0);
639639
}
@@ -695,8 +695,8 @@ static int do_fetch(struct transport *transport,
695695

696696
for (rm = ref_map; rm; rm = rm->next) {
697697
if (rm->peer_ref) {
698-
peer_item = string_list_lookup(rm->peer_ref->name,
699-
&existing_refs);
698+
peer_item = string_list_lookup(&existing_refs,
699+
rm->peer_ref->name);
700700
if (peer_item)
701701
hashcpy(rm->peer_ref->old_sha1,
702702
peer_item->util);
@@ -745,7 +745,7 @@ static int get_one_remote_for_fetch(struct remote *remote, void *priv)
745745
{
746746
struct string_list *list = priv;
747747
if (!remote->skip_default_update)
748-
string_list_append(remote->name, list);
748+
string_list_append(list, remote->name);
749749
return 0;
750750
}
751751

@@ -764,8 +764,8 @@ static int get_remote_group(const char *key, const char *value, void *priv)
764764
int space = strcspn(value, " \t\n");
765765
while (*value) {
766766
if (space > 1) {
767-
string_list_append(xstrndup(value, space),
768-
g->list);
767+
string_list_append(g->list,
768+
xstrndup(value, space));
769769
}
770770
value += space + (value[space] != '\0');
771771
space = strcspn(value, " \t\n");
@@ -786,7 +786,7 @@ static int add_remote_or_group(const char *name, struct string_list *list)
786786
if (!remote_is_configured(name))
787787
return 0;
788788
remote = remote_get(name);
789-
string_list_append(remote->name, list);
789+
string_list_append(list, remote->name);
790790
}
791791
return 1;
792792
}

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/grep.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ static void append_path(struct grep_opt *opt, const void *data, size_t len)
564564

565565
if (len == 1 && *(const char *)data == '\0')
566566
return;
567-
string_list_append(xstrndup(data, len), path_list);
567+
string_list_append(path_list, xstrndup(data, len));
568568
}
569569

570570
static void run_pager(struct grep_opt *opt, const char *prefix)
@@ -1001,7 +1001,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
10011001
opt.null_following_name = 1;
10021002
opt.output_priv = &path_list;
10031003
opt.output = append_path;
1004-
string_list_append(show_in_pager, &path_list);
1004+
string_list_append(&path_list, show_in_pager);
10051005
use_threads = 0;
10061006
}
10071007

@@ -1076,7 +1076,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
10761076
strbuf_addf(&buf, "+/%s%s",
10771077
strcmp("less", pager) ? "" : "*",
10781078
opt.pattern_list->pattern);
1079-
string_list_append(buf.buf, &path_list);
1079+
string_list_append(&path_list, buf.buf);
10801080
strbuf_detach(&buf, NULL);
10811081
}
10821082
}

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';
@@ -565,13 +565,13 @@ static int git_format_config(const char *var, const char *value, void *cb)
565565
if (!strcmp(var, "format.to")) {
566566
if (!value)
567567
return config_error_nonbool(var);
568-
string_list_append(value, &extra_to);
568+
string_list_append(&extra_to, value);
569569
return 0;
570570
}
571571
if (!strcmp(var, "format.cc")) {
572572
if (!value)
573573
return config_error_nonbool(var);
574-
string_list_append(value, &extra_cc);
574+
string_list_append(&extra_cc, value);
575575
return 0;
576576
}
577577
if (!strcmp(var, "diff.color") || !strcmp(var, "color.diff")) {
@@ -949,7 +949,7 @@ static int to_callback(const struct option *opt, const char *arg, int unset)
949949
if (unset)
950950
string_list_clear(&extra_to, 0);
951951
else
952-
string_list_append(arg, &extra_to);
952+
string_list_append(&extra_to, arg);
953953
return 0;
954954
}
955955

@@ -958,7 +958,7 @@ static int cc_callback(const struct option *opt, const char *arg, int unset)
958958
if (unset)
959959
string_list_clear(&extra_cc, 0);
960960
else
961-
string_list_append(arg, &extra_cc);
961+
string_list_append(&extra_cc, arg);
962962
return 0;
963963
}
964964

@@ -1239,7 +1239,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
12391239
rev.ref_message_ids = xcalloc(1, sizeof(struct string_list));
12401240
if (in_reply_to) {
12411241
const char *msgid = clean_message_id(in_reply_to);
1242-
string_list_append(msgid, rev.ref_message_ids);
1242+
string_list_append(rev.ref_message_ids, msgid);
12431243
}
12441244
rev.numbered_files = numbered_files;
12451245
rev.patch_suffix = fmt_patch_suffix;
@@ -1286,8 +1286,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
12861286
&& (!cover_letter || rev.nr > 1))
12871287
free(rev.message_id);
12881288
else
1289-
string_list_append(rev.message_id,
1290-
rev.ref_message_ids);
1289+
string_list_append(rev.ref_message_ids,
1290+
rev.message_id);
12911291
}
12921292
gen_message_id(&rev, sha1_to_hex(commit->object.sha1));
12931293
}

builtin/ls-files.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ static void show_ru_info(const char *prefix)
186186
{
187187
if (!the_index.resolve_undo)
188188
return;
189-
for_each_string_list(show_one_ru, the_index.resolve_undo, NULL);
189+
for_each_string_list(the_index.resolve_undo, show_one_ru, NULL);
190190
}
191191

192192
static void show_files(struct dir_struct *dir, const char *prefix)

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

0 commit comments

Comments
 (0)