summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/technical/api-string-list.txt4
-rw-r--r--builtin/apply.c10
-rw-r--r--builtin/commit.c2
-rw-r--r--builtin/fast-export.c4
-rw-r--r--builtin/fetch.c18
-rw-r--r--builtin/fmt-merge-msg.c18
-rw-r--r--builtin/log.c20
-rw-r--r--builtin/ls-files.c2
-rw-r--r--builtin/mailsplit.c2
-rw-r--r--builtin/mv.c2
-rw-r--r--builtin/receive-pack.c4
-rw-r--r--builtin/remote.c68
-rw-r--r--builtin/rerere.c2
-rw-r--r--builtin/shortlog.c4
-rw-r--r--builtin/show-ref.c2
-rw-r--r--diff-no-index.c2
-rw-r--r--http-backend.c6
-rw-r--r--mailmap.c8
-rw-r--r--merge-recursive.c24
-rw-r--r--notes.c12
-rw-r--r--reflog-walk.c4
-rw-r--r--remote.c6
-rw-r--r--rerere.c10
-rw-r--r--resolve-undo.c8
-rw-r--r--revision.c4
-rw-r--r--string-list.c18
-rw-r--r--string-list.h16
-rw-r--r--transport-helper.c4
-rw-r--r--wt-status.c10
29 files changed, 147 insertions, 147 deletions
diff --git a/Documentation/technical/api-string-list.txt b/Documentation/technical/api-string-list.txt
index 6d8c24bb1e..3f575bdcff 100644
--- a/Documentation/technical/api-string-list.txt
+++ b/Documentation/technical/api-string-list.txt
@@ -38,8 +38,8 @@ struct string_list list;
int i;
memset(&list, 0, sizeof(struct string_list));
-string_list_append("foo", &list);
-string_list_append("bar", &list);
+string_list_append(&list, "foo");
+string_list_append(&list, "bar");
for (i = 0; i < list.nr; i++)
printf("%s\n", list.items[i].string)
----
diff --git a/builtin/apply.c b/builtin/apply.c
index 562e5345fc..12ef9ea8af 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -2628,7 +2628,7 @@ static struct patch *in_fn_table(const char *name)
if (name == NULL)
return NULL;
- item = string_list_lookup(name, &fn_table);
+ item = string_list_lookup(&fn_table, name);
if (item != NULL)
return (struct patch *)item->util;
@@ -2664,7 +2664,7 @@ static void add_to_fn_table(struct patch *patch)
* file creations and copies
*/
if (patch->new_name != NULL) {
- item = string_list_insert(patch->new_name, &fn_table);
+ item = string_list_insert(&fn_table, patch->new_name);
item->util = patch;
}
@@ -2673,7 +2673,7 @@ static void add_to_fn_table(struct patch *patch)
* later chunks shouldn't patch old names
*/
if ((patch->new_name == NULL) || (patch->is_rename)) {
- item = string_list_insert(patch->old_name, &fn_table);
+ item = string_list_insert(&fn_table, patch->old_name);
item->util = PATH_WAS_DELETED;
}
}
@@ -2686,7 +2686,7 @@ static void prepare_fn_table(struct patch *patch)
while (patch) {
if ((patch->new_name == NULL) || (patch->is_rename)) {
struct string_list_item *item;
- item = string_list_insert(patch->old_name, &fn_table);
+ item = string_list_insert(&fn_table, patch->old_name);
item->util = PATH_TO_BE_DELETED;
}
patch = patch->next;
@@ -3394,7 +3394,7 @@ static void add_name_limit(const char *name, int exclude)
{
struct string_list_item *it;
- it = string_list_append(name, &limit_by_name);
+ it = string_list_append(&limit_by_name, name);
it->util = exclude ? NULL : (void *) 1;
}
diff --git a/builtin/commit.c b/builtin/commit.c
index 3d99cf9158..c6b053a508 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -219,7 +219,7 @@ static int list_paths(struct string_list *list, const char *with_tree,
continue;
if (!match_pathspec(pattern, ce->name, ce_namelen(ce), 0, m))
continue;
- item = string_list_insert(ce->name, list);
+ item = string_list_insert(list, ce->name);
if (ce_skip_worktree(ce))
item->util = item; /* better a valid pointer than a fake one */
}
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index c6dd71a7bc..9fe25ff0b3 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -438,7 +438,7 @@ static void get_tags_and_duplicates(struct object_array *pending,
/* handle nested tags */
while (tag && tag->object.type == OBJ_TAG) {
parse_object(tag->object.sha1);
- string_list_append(full_name, extra_refs)->util = tag;
+ string_list_append(extra_refs, full_name)->util = tag;
tag = (struct tag *)tag->tagged;
}
if (!tag)
@@ -464,7 +464,7 @@ static void get_tags_and_duplicates(struct object_array *pending,
}
if (commit->util)
/* more than one name for the same object */
- string_list_append(full_name, extra_refs)->util = commit;
+ string_list_append(extra_refs, full_name)->util = commit;
else
commit->util = full_name;
}
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 5cb369cfd1..6eb1dfea09 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -528,7 +528,7 @@ static int add_existing(const char *refname, const unsigned char *sha1,
int flag, void *cbdata)
{
struct string_list *list = (struct string_list *)cbdata;
- struct string_list_item *item = string_list_insert(refname, list);
+ struct string_list_item *item = string_list_insert(list, refname);
item->util = (void *)sha1;
return 0;
}
@@ -617,7 +617,7 @@ static void find_non_local_tags(struct transport *transport,
string_list_has_string(&existing_refs, ref->name))
continue;
- item = string_list_insert(ref->name, &remote_refs);
+ item = string_list_insert(&remote_refs, ref->name);
item->util = (void *)ref->old_sha1;
}
string_list_clear(&existing_refs, 0);
@@ -634,7 +634,7 @@ static void find_non_local_tags(struct transport *transport,
* For all the tags in the remote_refs string list, call
* add_to_tail to add them to the list of refs to be fetched
*/
- for_each_string_list(add_to_tail, &remote_refs, &data);
+ for_each_string_list(&remote_refs, add_to_tail, &data);
string_list_clear(&remote_refs, 0);
}
@@ -696,8 +696,8 @@ static int do_fetch(struct transport *transport,
for (rm = ref_map; rm; rm = rm->next) {
if (rm->peer_ref) {
- peer_item = string_list_lookup(rm->peer_ref->name,
- &existing_refs);
+ peer_item = string_list_lookup(&existing_refs,
+ rm->peer_ref->name);
if (peer_item)
hashcpy(rm->peer_ref->old_sha1,
peer_item->util);
@@ -746,7 +746,7 @@ static int get_one_remote_for_fetch(struct remote *remote, void *priv)
{
struct string_list *list = priv;
if (!remote->skip_default_update)
- string_list_append(remote->name, list);
+ string_list_append(list, remote->name);
return 0;
}
@@ -765,8 +765,8 @@ static int get_remote_group(const char *key, const char *value, void *priv)
int space = strcspn(value, " \t\n");
while (*value) {
if (space > 1) {
- string_list_append(xstrndup(value, space),
- g->list);
+ string_list_append(g->list,
+ xstrndup(value, space));
}
value += space + (value[space] != '\0');
space = strcspn(value, " \t\n");
@@ -788,7 +788,7 @@ static int add_remote_or_group(const char *name, struct string_list *list)
if (!remote_is_configured(name))
return 0;
remote = remote_get(name);
- string_list_append(remote->name, list);
+ string_list_append(list, remote->name);
}
return 1;
}
diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c
index 44204257c7..bc3c5e6d3e 100644
--- a/builtin/fmt-merge-msg.c
+++ b/builtin/fmt-merge-msg.c
@@ -82,7 +82,7 @@ static int handle_line(char *line)
item = unsorted_string_list_lookup(&srcs, src);
if (!item) {
- item = string_list_append(src, &srcs);
+ item = string_list_append(&srcs, src);
item->util = xcalloc(1, sizeof(struct src_data));
init_src_data(item->util);
}
@@ -93,19 +93,19 @@ static int handle_line(char *line)
src_data->head_status |= 1;
} else if (!prefixcmp(line, "branch ")) {
origin = line + 7;
- string_list_append(origin, &src_data->branch);
+ string_list_append(&src_data->branch, origin);
src_data->head_status |= 2;
} else if (!prefixcmp(line, "tag ")) {
origin = line;
- string_list_append(origin + 4, &src_data->tag);
+ string_list_append(&src_data->tag, origin + 4);
src_data->head_status |= 2;
} else if (!prefixcmp(line, "remote branch ")) {
origin = line + 14;
- string_list_append(origin, &src_data->r_branch);
+ string_list_append(&src_data->r_branch, origin);
src_data->head_status |= 2;
} else {
origin = src;
- string_list_append(line, &src_data->generic);
+ string_list_append(&src_data->generic, line);
src_data->head_status |= 2;
}
@@ -118,7 +118,7 @@ static int handle_line(char *line)
sprintf(new_origin, "%s of %s", origin, src);
origin = new_origin;
}
- string_list_append(origin, &origins)->util = sha1;
+ string_list_append(&origins, origin)->util = sha1;
return 0;
}
@@ -176,10 +176,10 @@ static void shortlog(const char *name, unsigned char *sha1,
strbuf_ltrim(&sb);
if (!sb.len)
- string_list_append(sha1_to_hex(commit->object.sha1),
- &subjects);
+ string_list_append(&subjects,
+ sha1_to_hex(commit->object.sha1));
else
- string_list_append(strbuf_detach(&sb, NULL), &subjects);
+ string_list_append(&subjects, strbuf_detach(&sb, NULL));
}
if (count > limit)
diff --git a/builtin/log.c b/builtin/log.c
index f068583618..7cb9317af7 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -535,13 +535,13 @@ static void add_header(const char *value)
len--;
if (!strncasecmp(value, "to: ", 4)) {
- item = string_list_append(value + 4, &extra_to);
+ item = string_list_append(&extra_to, value + 4);
len -= 4;
} else if (!strncasecmp(value, "cc: ", 4)) {
- item = string_list_append(value + 4, &extra_cc);
+ item = string_list_append(&extra_cc, value + 4);
len -= 4;
} else {
- item = string_list_append(value, &extra_hdr);
+ item = string_list_append(&extra_hdr, value);
}
item->string[len] = '\0';
@@ -566,13 +566,13 @@ static int git_format_config(const char *var, const char *value, void *cb)
if (!strcmp(var, "format.to")) {
if (!value)
return config_error_nonbool(var);
- string_list_append(value, &extra_to);
+ string_list_append(&extra_to, value);
return 0;
}
if (!strcmp(var, "format.cc")) {
if (!value)
return config_error_nonbool(var);
- string_list_append(value, &extra_cc);
+ string_list_append(&extra_cc, value);
return 0;
}
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)
if (unset)
string_list_clear(&extra_to, 0);
else
- string_list_append(arg, &extra_to);
+ string_list_append(&extra_to, arg);
return 0;
}
@@ -968,7 +968,7 @@ static int cc_callback(const struct option *opt, const char *arg, int unset)
if (unset)
string_list_clear(&extra_cc, 0);
else
- string_list_append(arg, &extra_cc);
+ string_list_append(&extra_cc, arg);
return 0;
}
@@ -1251,7 +1251,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
rev.ref_message_ids = xcalloc(1, sizeof(struct string_list));
if (in_reply_to) {
const char *msgid = clean_message_id(in_reply_to);
- string_list_append(msgid, rev.ref_message_ids);
+ string_list_append(rev.ref_message_ids, msgid);
}
rev.numbered_files = numbered_files;
rev.patch_suffix = fmt_patch_suffix;
@@ -1298,8 +1298,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
&& (!cover_letter || rev.nr > 1))
free(rev.message_id);
else
- string_list_append(rev.message_id,
- rev.ref_message_ids);
+ string_list_append(rev.ref_message_ids,
+ rev.message_id);
}
gen_message_id(&rev, sha1_to_hex(commit->object.sha1));
}
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index 0804047693..1b9b8a8b4a 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -190,7 +190,7 @@ static void show_ru_info(void)
{
if (!the_index.resolve_undo)
return;
- for_each_string_list(show_one_ru, the_index.resolve_undo, NULL);
+ for_each_string_list(the_index.resolve_undo, show_one_ru, NULL);
}
static void show_files(struct dir_struct *dir)
diff --git a/builtin/mailsplit.c b/builtin/mailsplit.c
index cdfc1b7042..e4560da191 100644
--- a/builtin/mailsplit.c
+++ b/builtin/mailsplit.c
@@ -121,7 +121,7 @@ static int populate_maildir_list(struct string_list *list, const char *path)
if (dent->d_name[0] == '.')
continue;
snprintf(name, sizeof(name), "%s/%s", *sub, dent->d_name);
- string_list_insert(name, list);
+ string_list_insert(list, name);
}
closedir(dir);
diff --git a/builtin/mv.c b/builtin/mv.c
index c07f53b343..38574b89f7 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -180,7 +180,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
} else if (string_list_has_string(&src_for_dst, dst))
bad = "multiple sources for the same target";
else
- string_list_insert(dst, &src_for_dst);
+ string_list_insert(&src_for_dst, dst);
if (bad) {
if (ignore_errors) {
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 29bc8d50bb..d634b5a3d5 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -501,7 +501,7 @@ static void check_aliased_update(struct command *cmd, struct string_list *list)
if (!(flag & REF_ISSYMREF))
return;
- if ((item = string_list_lookup(dst_name, list)) == NULL)
+ if ((item = string_list_lookup(list, dst_name)) == NULL)
return;
cmd->skip_update = 1;
@@ -534,7 +534,7 @@ static void check_aliased_updates(struct command *commands)
for (cmd = commands; cmd; cmd = cmd->next) {
struct string_list_item *item =
- string_list_append(cmd->ref_name, &ref_list);
+ string_list_append(&ref_list, cmd->ref_name);
item->util = (void *)cmd;
}
sort_string_list(&ref_list);
diff --git a/builtin/remote.c b/builtin/remote.c
index 0a52667e0f..6699bc5712 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -94,7 +94,7 @@ static int opt_parse_track(const struct option *opt, const char *arg, int not)
if (not)
string_list_clear(list, 0);
else
- string_list_append(arg, list);
+ string_list_append(list, arg);
return 0;
}
@@ -181,7 +181,7 @@ static int add(int argc, const char **argv)
strbuf_addf(&buf, "remote.%s.fetch", name);
if (track.nr == 0)
- string_list_append("*", &track);
+ string_list_append(&track, "*");
for (i = 0; i < track.nr; i++) {
if (add_branch(buf.buf, track.items[i].string,
name, mirror, &buf2))
@@ -263,7 +263,7 @@ static int config_read_branches(const char *key, const char *value, void *cb)
} else
return 0;
- item = string_list_insert(name, &branch_list);
+ item = string_list_insert(&branch_list, name);
if (!item->util)
item->util = xcalloc(sizeof(struct branch_info), 1);
@@ -278,11 +278,11 @@ static int config_read_branches(const char *key, const char *value, void *cb)
while (space) {
char *merge;
merge = xstrndup(value, space - value);
- string_list_append(merge, &info->merge);
+ string_list_append(&info->merge, merge);
value = abbrev_branch(space + 1);
space = strchr(value, ' ');
}
- string_list_append(xstrdup(value), &info->merge);
+ string_list_append(&info->merge, xstrdup(value));
} else
info->rebase = git_config_bool(orig_key, value);
}
@@ -319,14 +319,14 @@ static int get_ref_states(const struct ref *remote_refs, struct ref_states *stat
for (ref = fetch_map; ref; ref = ref->next) {
unsigned char sha1[20];
if (!ref->peer_ref || read_ref(ref->peer_ref->name, sha1))
- string_list_append(abbrev_branch(ref->name), &states->new);
+ string_list_append(&states->new, abbrev_branch(ref->name));
else
- string_list_append(abbrev_branch(ref->name), &states->tracked);
+ string_list_append(&states->tracked, abbrev_branch(ref->name));
}
stale_refs = get_stale_heads(states->remote, fetch_map);
for (ref = stale_refs; ref; ref = ref->next) {
struct string_list_item *item =
- string_list_append(abbrev_branch(ref->name), &states->stale);
+ string_list_append(&states->stale, abbrev_branch(ref->name));
item->util = xstrdup(ref->name);
}
free_refs(stale_refs);
@@ -375,8 +375,8 @@ static int get_push_ref_states(const struct ref *remote_refs,
continue;
hashcpy(ref->new_sha1, ref->peer_ref->new_sha1);
- item = string_list_append(abbrev_branch(ref->peer_ref->name),
- &states->push);
+ item = string_list_append(&states->push,
+ abbrev_branch(ref->peer_ref->name));
item->util = xcalloc(sizeof(struct push_info), 1);
info = item->util;
info->forced = ref->force;
@@ -411,7 +411,7 @@ static int get_push_ref_states_noquery(struct ref_states *states)
states->push.strdup_strings = 1;
if (!remote->push_refspec_nr) {
- item = string_list_append("(matching)", &states->push);
+ item = string_list_append(&states->push, "(matching)");
info = item->util = xcalloc(sizeof(struct push_info), 1);
info->status = PUSH_STATUS_NOTQUERIED;
info->dest = xstrdup(item->string);
@@ -419,11 +419,11 @@ static int get_push_ref_states_noquery(struct ref_states *states)
for (i = 0; i < remote->push_refspec_nr; i++) {
struct refspec *spec = remote->push + i;
if (spec->matching)
- item = string_list_append("(matching)", &states->push);
+ item = string_list_append(&states->push, "(matching)");
else if (strlen(spec->src))
- item = string_list_append(spec->src, &states->push);
+ item = string_list_append(&states->push, spec->src);
else
- item = string_list_append("(delete)", &states->push);
+ item = string_list_append(&states->push, "(delete)");
info = item->util = xcalloc(sizeof(struct push_info), 1);
info->forced = spec->force;
@@ -447,7 +447,7 @@ static int get_head_names(const struct ref *remote_refs, struct ref_states *stat
matches = guess_remote_head(find_ref_by_name(remote_refs, "HEAD"),
fetch_map, 1);
for (ref = matches; ref; ref = ref->next)
- string_list_append(abbrev_branch(ref->name), &states->heads);
+ string_list_append(&states->heads, abbrev_branch(ref->name));
free_refs(fetch_map);
free_refs(matches);
@@ -511,8 +511,8 @@ static int add_branch_for_removal(const char *refname,
if (prefixcmp(refname, "refs/remotes")) {
/* advise user how to delete local branches */
if (!prefixcmp(refname, "refs/heads/"))
- string_list_append(abbrev_branch(refname),
- branches->skipped);
+ string_list_append(branches->skipped,
+ abbrev_branch(refname));
/* silently skip over other non-remote refs */
return 0;
}
@@ -521,7 +521,7 @@ static int add_branch_for_removal(const char *refname,
if (flags & REF_ISSYMREF)
return unlink(git_path("%s", refname));
- item = string_list_append(refname, branches->branches);
+ item = string_list_append(branches->branches, refname);
item->util = xmalloc(20);
hashcpy(item->util, sha1);
@@ -546,7 +546,7 @@ static int read_remote_branches(const char *refname,
strbuf_addf(&buf, "refs/remotes/%s", rename->old);
if (!prefixcmp(refname, buf.buf)) {
- item = string_list_append(xstrdup(refname), rename->remote_branches);
+ item = string_list_append(rename->remote_branches, xstrdup(refname));
symref = resolve_ref(refname, orig_sha1, 1, &flag);
if (flag & REF_ISSYMREF)
item->util = xstrdup(symref);
@@ -832,7 +832,7 @@ static int append_ref_to_tracked_list(const char *refname,
memset(&refspec, 0, sizeof(refspec));
refspec.dst = (char *)refname;
if (!remote_find_tracking(states->remote, &refspec))
- string_list_append(abbrev_branch(refspec.src), &states->tracked);
+ string_list_append(&states->tracked, abbrev_branch(refspec.src));
return 0;
}
@@ -885,7 +885,7 @@ static int add_remote_to_show_info(struct string_list_item *item, void *cb_data)
int n = strlen(item->string);
if (n > info->width)
info->width = n;
- string_list_insert(item->string, info->list);
+ string_list_insert(info->list, item->string);
return 0;
}
@@ -932,7 +932,7 @@ static int add_local_to_show_info(struct string_list_item *branch_item, void *cb
if (branch_info->rebase)
show_info->any_rebase = 1;
- item = string_list_insert(branch_item->string, show_info->list);
+ item = string_list_insert(show_info->list, branch_item->string);
item->util = branch_info;
return 0;
@@ -980,7 +980,7 @@ static int add_push_to_show_info(struct string_list_item *push_item, void *cb_da
show_info->width = n;
if ((n = strlen(push_info->dest)) > show_info->width2)
show_info->width2 = n;
- item = string_list_append(push_item->string, show_info->list);
+ item = string_list_append(show_info->list, push_item->string);
item->util = push_item->util;
return 0;
}
@@ -1096,24 +1096,24 @@ static int show(int argc, const char **argv)
/* remote branch info */
info.width = 0;
- for_each_string_list(add_remote_to_show_info, &states.new, &info);
- for_each_string_list(add_remote_to_show_info, &states.tracked, &info);
- for_each_string_list(add_remote_to_show_info, &states.stale, &info);
+ for_each_string_list(&states.new, add_remote_to_show_info, &info);
+ for_each_string_list(&states.tracked, add_remote_to_show_info, &info);
+ for_each_string_list(&states.stale, add_remote_to_show_info, &info);
if (info.list->nr)
printf(" Remote branch%s:%s\n",
info.list->nr > 1 ? "es" : "",
no_query ? " (status not queried)" : "");
- for_each_string_list(show_remote_info_item, info.list, &info);
+ for_each_string_list(info.list, show_remote_info_item, &info);
string_list_clear(info.list, 0);
/* git pull info */
info.width = 0;
info.any_rebase = 0;
- for_each_string_list(add_local_to_show_info, &branch_list, &info);
+ for_each_string_list(&branch_list, add_local_to_show_info, &info);
if (info.list->nr)
printf(" Local branch%s configured for 'git pull':\n",
info.list->nr > 1 ? "es" : "");
- for_each_string_list(show_local_info_item, info.list, &info);
+ for_each_string_list(info.list, show_local_info_item, &info);
string_list_clear(info.list, 0);
/* git push info */
@@ -1121,14 +1121,14 @@ static int show(int argc, const char **argv)
printf(" Local refs will be mirrored by 'git push'\n");
info.width = info.width2 = 0;
- for_each_string_list(add_push_to_show_info, &states.push, &info);
+ for_each_string_list(&states.push, add_push_to_show_info, &info);
qsort(info.list->items, info.list->nr,
sizeof(*info.list->items), cmp_string_with_push);
if (info.list->nr)
printf(" Local ref%s configured for 'git push'%s:\n",
info.list->nr > 1 ? "s" : "",
no_query ? " (status not queried)" : "");
- for_each_string_list(show_push_info_item, info.list, &info);
+ for_each_string_list(info.list, show_push_info_item, &info);
string_list_clear(info.list, 0);
free_remote_ref_states(&states);
@@ -1460,10 +1460,10 @@ static int get_one_entry(struct remote *remote, void *priv)
if (remote->url_nr > 0) {
strbuf_addf(&url_buf, "%s (fetch)", remote->url[0]);
- string_list_append(remote->name, list)->util =
+ string_list_append(list, remote->name)->util =
strbuf_detach(&url_buf, NULL);
} else
- string_list_append(remote->name, list)->util = NULL;
+ string_list_append(list, remote->name)->util = NULL;
if (remote->pushurl_nr) {
url = remote->pushurl;
url_nr = remote->pushurl_nr;
@@ -1474,7 +1474,7 @@ static int get_one_entry(struct remote *remote, void *priv)
for (i = 0; i < url_nr; i++)
{
strbuf_addf(&url_buf, "%s (push)", url[i]);
- string_list_append(remote->name, list)->util =
+ string_list_append(list, remote->name)->util =
strbuf_detach(&url_buf, NULL);
}
diff --git a/builtin/rerere.c b/builtin/rerere.c
index 0048f9ef7f..980d5421ee 100644
--- a/builtin/rerere.c
+++ b/builtin/rerere.c
@@ -59,7 +59,7 @@ static void garbage_collect(struct string_list *rr)
cutoff = (has_rerere_resolution(e->d_name)
? cutoff_resolve : cutoff_noresolve);
if (then < now - cutoff * 86400)
- string_list_append(e->d_name, &to_remove);
+ string_list_append(&to_remove, e->d_name);
}
for (i = 0; i < to_remove.nr; i++)
unlink_rr_item(to_remove.items[i].string);
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 5089502800..0a9681ba7e 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -84,7 +84,7 @@ static void insert_one_record(struct shortlog *log,
snprintf(namebuf + len, room, " <%.*s>", maillen, emailbuf);
}
- item = string_list_insert(namebuf, &log->list);
+ item = string_list_insert(&log->list, namebuf);
if (item->util == NULL)
item->util = xcalloc(1, sizeof(struct string_list));
@@ -115,7 +115,7 @@ static void insert_one_record(struct shortlog *log,
}
}
- string_list_append(buffer, item->util);
+ string_list_append(item->util, buffer);
}
static void read_from_stdin(struct shortlog *log)
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index 17ada88dfb..0b2a9ad1a9 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -105,7 +105,7 @@ match:
static int add_existing(const char *refname, const unsigned char *sha1, int flag, void *cbdata)
{
struct string_list *list = (struct string_list *)cbdata;
- string_list_insert(refname, list);
+ string_list_insert(list, refname);
return 0;
}
diff --git a/diff-no-index.c b/diff-no-index.c
index 4cd9dacbe8..43aeeba2e0 100644
--- a/diff-no-index.c
+++ b/diff-no-index.c
@@ -26,7 +26,7 @@ static int read_directory(const char *path, struct string_list *list)
while ((e = readdir(dir)))
if (strcmp(".", e->d_name) && strcmp("..", e->d_name))
- string_list_insert(e->d_name, list);
+ string_list_insert(list, e->d_name);
closedir(dir);
return 0;
diff --git a/http-backend.c b/http-backend.c
index 44ce6bb32b..14c90c2e84 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -37,9 +37,9 @@ static struct string_list *get_parameters(void)
char *value = url_decode_parameter_value(&query);
struct string_list_item *i;
- i = string_list_lookup(name, query_params);
+ i = string_list_lookup(query_params, name);
if (!i)
- i = string_list_insert(name, query_params);
+ i = string_list_insert(query_params, name);
else
free(i->util);
i->util = value;
@@ -51,7 +51,7 @@ static struct string_list *get_parameters(void)
static const char *get_parameter(const char *name)
{
struct string_list_item *i;
- i = string_list_lookup(name, get_parameters());
+ i = string_list_lookup(get_parameters(), name);
return i ? i->util : NULL;
}
diff --git a/mailmap.c b/mailmap.c
index b68c1fec9c..f80b701292 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -69,7 +69,7 @@ static void add_mapping(struct string_list *map,
index = -1 - index;
} else {
/* create mailmap entry */
- struct string_list_item *item = string_list_insert_at_index(index, old_email, map);
+ struct string_list_item *item = string_list_insert_at_index(map, index, old_email);
item->util = xmalloc(sizeof(struct mailmap_entry));
memset(item->util, 0, sizeof(struct mailmap_entry));
((struct mailmap_entry *)item->util)->namemap.strdup_strings = 1;
@@ -92,7 +92,7 @@ static void add_mapping(struct string_list *map,
mi->name = xstrdup(new_name);
if (new_email)
mi->email = xstrdup(new_email);
- string_list_insert(old_name, &me->namemap)->util = mi;
+ string_list_insert(&me->namemap, old_name)->util = mi;
}
debug_mm("mailmap: '%s' <%s> -> '%s' <%s>\n",
@@ -214,13 +214,13 @@ int map_user(struct string_list *map,
mailbuf[i] = 0;
debug_mm("map_user: map '%s' <%s>\n", name, mailbuf);
- item = string_list_lookup(mailbuf, map);
+ item = string_list_lookup(map, mailbuf);
if (item != NULL) {
me = (struct mailmap_entry *)item->util;
if (me->namemap.nr) {
/* The item has multiple items, so we'll look up on name too */
/* If the name is not found, we choose the simple entry */
- struct string_list_item *subitem = string_list_lookup(name, &me->namemap);
+ struct string_list_item *subitem = string_list_lookup(&me->namemap, name);
if (subitem)
item = subitem;
}
diff --git a/merge-recursive.c b/merge-recursive.c
index 206c103635..856e98c083 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -238,9 +238,9 @@ static int save_files_dirs(const unsigned char *sha1,
newpath[baselen + len] = '\0';
if (S_ISDIR(mode))
- string_list_insert(newpath, &o->current_directory_set);
+ string_list_insert(&o->current_directory_set, newpath);
else
- string_list_insert(newpath, &o->current_file_set);
+ string_list_insert(&o->current_file_set, newpath);
free(newpath);
return (S_ISDIR(mode) ? READ_TREE_RECURSIVE : 0);
@@ -271,7 +271,7 @@ static struct stage_data *insert_stage_data(const char *path,
e->stages[2].sha, &e->stages[2].mode);
get_tree_entry(b->object.sha1, path,
e->stages[3].sha, &e->stages[3].mode);
- item = string_list_insert(path, entries);
+ item = string_list_insert(entries, path);
item->util = e;
return e;
}
@@ -294,9 +294,9 @@ static struct string_list *get_unmerged(void)
if (!ce_stage(ce))
continue;
- item = string_list_lookup(ce->name, unmerged);
+ item = string_list_lookup(unmerged, ce->name);
if (!item) {
- item = string_list_insert(ce->name, unmerged);
+ item = string_list_insert(unmerged, ce->name);
item->util = xcalloc(1, sizeof(struct stage_data));
}
e = item->util;
@@ -356,20 +356,20 @@ static struct string_list *get_renames(struct merge_options *o,
re = xmalloc(sizeof(*re));
re->processed = 0;
re->pair = pair;
- item = string_list_lookup(re->pair->one->path, entries);
+ item = string_list_lookup(entries, re->pair->one->path);
if (!item)
re->src_entry = insert_stage_data(re->pair->one->path,
o_tree, a_tree, b_tree, entries);
else
re->src_entry = item->util;
- item = string_list_lookup(re->pair->two->path, entries);
+ item = string_list_lookup(entries, re->pair->two->path);
if (!item)
re->dst_entry = insert_stage_data(re->pair->two->path,
o_tree, a_tree, b_tree, entries);
else
re->dst_entry = item->util;
- item = string_list_insert(pair->one->path, renames);
+ item = string_list_insert(renames, pair->one->path);
item->util = re;
}
opts.output_format = DIFF_FORMAT_NO_OUTPUT;
@@ -432,7 +432,7 @@ static char *unique_path(struct merge_options *o, const char *path, const char *
lstat(newpath, &st) == 0)
sprintf(p, "_%d", suffix++);
- string_list_insert(newpath, &o->current_file_set);
+ string_list_insert(&o->current_file_set, newpath);
return newpath;
}
@@ -811,12 +811,12 @@ static int process_renames(struct merge_options *o,
for (i = 0; i < a_renames->nr; i++) {
sre = a_renames->items[i].util;
- string_list_insert(sre->pair->two->path, &a_by_dst)->util
+ string_list_insert(&a_by_dst, sre->pair->two->path)->util
= sre->dst_entry;
}
for (i = 0; i < b_renames->nr; i++) {
sre = b_renames->items[i].util;
- string_list_insert(sre->pair->two->path, &b_by_dst)->util
+ string_list_insert(&b_by_dst, sre->pair->two->path)->util
= sre->dst_entry;
}
@@ -988,7 +988,7 @@ static int process_renames(struct merge_options *o,
output(o, 1, "Adding as %s instead", new_path);
update_file(o, 0, dst_other.sha1, dst_other.mode, new_path);
}
- } else if ((item = string_list_lookup(ren1_dst, renames2Dst))) {
+ } else if ((item = string_list_lookup(renames2Dst, ren1_dst))) {
ren2 = item->util;
clean_merge = 0;
ren2->processed = 1;
diff --git a/notes.c b/notes.c
index 30d6ded78e..1978244398 100644
--- a/notes.c
+++ b/notes.c
@@ -838,7 +838,7 @@ static int string_list_add_one_ref(const char *path, const unsigned char *sha1,
{
struct string_list *refs = cb;
if (!unsorted_string_list_has_string(refs, path))
- string_list_append(path, refs);
+ string_list_append(refs, path);
return 0;
}
@@ -851,7 +851,7 @@ void string_list_add_refs_by_glob(struct string_list *list, const char *glob)
if (get_sha1(glob, sha1))
warning("notes ref %s is invalid", glob);
if (!unsorted_string_list_has_string(list, glob))
- string_list_append(glob, list);
+ string_list_append(list, glob);
}
}
@@ -969,7 +969,7 @@ struct notes_tree **load_notes_trees(struct string_list *refs)
trees = xmalloc((refs->nr+1) * sizeof(struct notes_tree *));
cb_data.counter = 0;
cb_data.trees = trees;
- for_each_string_list(load_one_display_note_ref, refs, &cb_data);
+ for_each_string_list(refs, load_one_display_note_ref, &cb_data);
trees[cb_data.counter] = NULL;
return trees;
}
@@ -983,7 +983,7 @@ void init_display_notes(struct display_notes_opt *opt)
assert(!display_notes_trees);
if (!opt || !opt->suppress_default_notes) {
- string_list_append(default_notes_ref(), &display_notes_refs);
+ string_list_append(&display_notes_refs, default_notes_ref());
display_ref_env = getenv(GIT_NOTES_DISPLAY_REF_ENVIRONMENT);
if (display_ref_env) {
string_list_add_refs_from_colon_sep(&display_notes_refs,
@@ -996,8 +996,8 @@ void init_display_notes(struct display_notes_opt *opt)
git_config(notes_display_config, &load_config_refs);
if (opt && opt->extra_notes_refs)
- for_each_string_list(string_list_add_refs_from_list,
- opt->extra_notes_refs,
+ for_each_string_list(opt->extra_notes_refs,
+ string_list_add_refs_from_list,
&display_notes_refs);
display_notes_trees = load_notes_trees(&display_notes_refs);
diff --git a/reflog-walk.c b/reflog-walk.c
index caba4f743f..4879615cad 100644
--- a/reflog-walk.c
+++ b/reflog-walk.c
@@ -162,7 +162,7 @@ int add_reflog_for_walk(struct reflog_walk_info *info,
} else
recno = 0;
- item = string_list_lookup(branch, &info->complete_reflogs);
+ item = string_list_lookup(&info->complete_reflogs, branch);
if (item)
reflogs = item->util;
else {
@@ -190,7 +190,7 @@ int add_reflog_for_walk(struct reflog_walk_info *info,
}
if (!reflogs || reflogs->nr == 0)
return -1;
- string_list_insert(branch, &info->complete_reflogs)->util
+ string_list_insert(&info->complete_reflogs, branch)->util
= reflogs;
}
diff --git a/remote.c b/remote.c
index e51cd22d6b..afbba47460 100644
--- a/remote.c
+++ b/remote.c
@@ -762,7 +762,7 @@ void ref_remove_duplicates(struct ref *ref_map)
if (!ref_map->peer_ref)
continue;
- item = string_list_lookup(ref_map->peer_ref->name, &refs);
+ item = string_list_lookup(&refs, ref_map->peer_ref->name);
if (item) {
if (strcmp(((struct ref *)item->util)->name,
ref_map->name))
@@ -777,7 +777,7 @@ void ref_remove_duplicates(struct ref *ref_map)
continue;
}
- item = string_list_insert(ref_map->peer_ref->name, &refs);
+ item = string_list_insert(&refs, ref_map->peer_ref->name);
item->util = ref_map;
}
string_list_clear(&refs, 0);
@@ -1710,7 +1710,7 @@ struct ref *get_stale_heads(struct remote *remote, struct ref *fetch_map)
info.ref_names = &ref_names;
info.stale_refs_tail = &stale_refs;
for (ref = fetch_map; ref; ref = ref->next)
- string_list_append(ref->name, &ref_names);
+ string_list_append(&ref_names, ref->name);
sort_string_list(&ref_names);
for_each_ref(get_stale_heads_cb, &info);
string_list_clear(&ref_names, 0);
diff --git a/rerere.c b/rerere.c
index 2197890982..d03a69634b 100644
--- a/rerere.c
+++ b/rerere.c
@@ -46,7 +46,7 @@ static void read_rr(struct string_list *rr)
; /* do nothing */
if (i == sizeof(buf))
die("filename too long");
- string_list_insert(buf, rr)->util = name;
+ string_list_insert(rr, buf)->util = name;
}
fclose(in);
}
@@ -354,7 +354,7 @@ static int find_conflict(struct string_list *conflict)
ce_same_name(e2, e3) &&
S_ISREG(e2->ce_mode) &&
S_ISREG(e3->ce_mode)) {
- string_list_insert((const char *)e2->name, conflict);
+ string_list_insert(conflict, (const char *)e2->name);
i++; /* skip over both #2 and #3 */
}
}
@@ -449,7 +449,7 @@ static int do_plain_rerere(struct string_list *rr, int fd)
if (ret < 1)
continue;
hex = xstrdup(sha1_to_hex(sha1));
- string_list_insert(path, rr)->util = hex;
+ string_list_insert(rr, path)->util = hex;
if (mkdir(git_path("rr-cache/%s", hex), 0755))
continue;
handle_file(path, NULL, rerere_path(hex, "preimage"));
@@ -471,7 +471,7 @@ static int do_plain_rerere(struct string_list *rr, int fd)
if (has_rerere_resolution(name)) {
if (!merge(name, path)) {
if (rerere_autoupdate)
- string_list_insert(path, &update);
+ string_list_insert(&update, path);
fprintf(stderr,
"%s '%s' using previous resolution.\n",
rerere_autoupdate
@@ -577,7 +577,7 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)
fprintf(stderr, "Updated preimage for '%s'\n", path);
- string_list_insert(path, rr)->util = hex;
+ string_list_insert(rr, path)->util = hex;
fprintf(stderr, "Forgot resolution for %s\n", path);
return 0;
}
diff --git a/resolve-undo.c b/resolve-undo.c
index 0f50ee0484..174ebec9e5 100644
--- a/resolve-undo.c
+++ b/resolve-undo.c
@@ -20,7 +20,7 @@ void record_resolve_undo(struct index_state *istate, struct cache_entry *ce)
istate->resolve_undo = resolve_undo;
}
resolve_undo = istate->resolve_undo;
- lost = string_list_insert(ce->name, resolve_undo);
+ lost = string_list_insert(resolve_undo, ce->name);
if (!lost->util)
lost->util = xcalloc(1, sizeof(*ui));
ui = lost->util;
@@ -50,7 +50,7 @@ static int write_one(struct string_list_item *item, void *cbdata)
void resolve_undo_write(struct strbuf *sb, struct string_list *resolve_undo)
{
- for_each_string_list(write_one, resolve_undo, sb);
+ for_each_string_list(resolve_undo, write_one, sb);
}
struct string_list *resolve_undo_read(const char *data, unsigned long size)
@@ -70,7 +70,7 @@ struct string_list *resolve_undo_read(const char *data, unsigned long size)
len = strlen(data) + 1;
if (size <= len)
goto error;
- lost = string_list_insert(data, resolve_undo);
+ lost = string_list_insert(resolve_undo, data);
if (!lost->util)
lost->util = xcalloc(1, sizeof(*ui));
ui = lost->util;
@@ -135,7 +135,7 @@ int unmerge_index_entry_at(struct index_state *istate, int pos)
pos++;
return pos - 1; /* return the last entry processed */
}
- item = string_list_lookup(ce->name, istate->resolve_undo);
+ item = string_list_lookup(istate->resolve_undo, ce->name);
if (!item)
return pos;
ru = item->util;
diff --git a/revision.c b/revision.c
index 527ec34e63..7e82efd932 100644
--- a/revision.c
+++ b/revision.c
@@ -1314,8 +1314,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
else
strbuf_addstr(&buf, "refs/notes/");
strbuf_addstr(&buf, arg+13);
- string_list_append(strbuf_detach(&buf, NULL),
- revs->notes_opt.extra_notes_refs);
+ string_list_append(revs->notes_opt.extra_notes_refs,
+ strbuf_detach(&buf, NULL));
} else if (!strcmp(arg, "--no-notes")) {
revs->show_notes = 0;
revs->show_notes_given = 1;
diff --git a/string-list.c b/string-list.c
index c9ad7fcd49..9b023a2584 100644
--- a/string-list.c
+++ b/string-list.c
@@ -51,13 +51,13 @@ static int add_entry(int insert_at, struct string_list *list, const char *string
return index;
}
-struct string_list_item *string_list_insert(const char *string, struct string_list *list)
+struct string_list_item *string_list_insert(struct string_list *list, const char *string)
{
- return string_list_insert_at_index(-1, string, list);
+ return string_list_insert_at_index(list, -1, string);
}
-struct string_list_item *string_list_insert_at_index(int insert_at,
- const char *string, struct string_list *list)
+struct string_list_item *string_list_insert_at_index(struct string_list *list,
+ int insert_at, const char *string)
{
int index = add_entry(insert_at, list, string);
@@ -84,7 +84,7 @@ int string_list_find_insert_index(const struct string_list *list, const char *st
return index;
}
-struct string_list_item *string_list_lookup(const char *string, struct string_list *list)
+struct string_list_item *string_list_lookup(struct string_list *list, const char *string)
{
int exact_match, i = get_entry_index(list, string, &exact_match);
if (!exact_match)
@@ -92,8 +92,8 @@ struct string_list_item *string_list_lookup(const char *string, struct string_li
return list->items + i;
}
-int for_each_string_list(string_list_each_func_t fn,
- struct string_list *list, void *cb_data)
+int for_each_string_list(struct string_list *list,
+ string_list_each_func_t fn, void *cb_data)
{
int i, ret = 0;
for (i = 0; i < list->nr; i++)
@@ -139,7 +139,7 @@ void string_list_clear_func(struct string_list *list, string_list_clear_func_t c
}
-void print_string_list(const char *text, const struct string_list *p)
+void print_string_list(const struct string_list *p, const char *text)
{
int i;
if ( text )
@@ -148,7 +148,7 @@ void print_string_list(const char *text, const struct string_list *p)
printf("%s:%p\n", p->items[i].string, p->items[i].util);
}
-struct string_list_item *string_list_append(const char *string, struct string_list *list)
+struct string_list_item *string_list_append(struct string_list *list, const char *string)
{
ALLOC_GROW(list->items, list->nr + 1, list->alloc);
list->items[list->nr].string =
diff --git a/string-list.h b/string-list.h
index 63b69c8d75..680d600d16 100644
--- a/string-list.h
+++ b/string-list.h
@@ -12,7 +12,7 @@ struct string_list
unsigned int strdup_strings:1;
};
-void print_string_list(const char *text, const struct string_list *p);
+void print_string_list(const struct string_list *p, const char *text);
void string_list_clear(struct string_list *list, int free_util);
/* Use this function to call a custom clear function on each util pointer */
@@ -22,20 +22,20 @@ void string_list_clear_func(struct string_list *list, string_list_clear_func_t c
/* Use this function to iterate over each item */
typedef int (*string_list_each_func_t)(struct string_list_item *, void *);
-int for_each_string_list(string_list_each_func_t,
- struct string_list *list, void *cb_data);
+int for_each_string_list(struct string_list *list,
+ string_list_each_func_t, void *cb_data);
/* Use these functions only on sorted lists: */
int string_list_has_string(const struct string_list *list, const char *string);
int string_list_find_insert_index(const struct string_list *list, const char *string,
int negative_existing_index);
-struct string_list_item *string_list_insert(const char *string, struct string_list *list);
-struct string_list_item *string_list_insert_at_index(int insert_at,
- const char *string, struct string_list *list);
-struct string_list_item *string_list_lookup(const char *string, struct string_list *list);
+struct string_list_item *string_list_insert(struct string_list *list, const char *string);
+struct string_list_item *string_list_insert_at_index(struct string_list *list,
+ int insert_at, const char *string);
+struct string_list_item *string_list_lookup(struct string_list *list, const char *string);
/* Use these functions only on unsorted lists: */
-struct string_list_item *string_list_append(const char *string, struct string_list *list);
+struct string_list_item *string_list_append(struct string_list *list, const char *string);
void sort_string_list(struct string_list *list);
int unsorted_string_list_has_string(struct string_list *list, const char *string);
struct string_list_item *unsorted_string_list_lookup(struct string_list *list,
diff --git a/transport-helper.c b/transport-helper.c
index 0381de5368..191fbf798a 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -727,10 +727,10 @@ static int push_refs_with_export(struct transport *transport,
private = apply_refspecs(data->refspecs, data->refspec_nr, ref->name);
if (private && !get_sha1(private, sha1)) {
strbuf_addf(&buf, "^%s", private);
- string_list_append(strbuf_detach(&buf, NULL), &revlist_args);
+ string_list_append(&revlist_args, strbuf_detach(&buf, NULL));
}
- string_list_append(ref->name, &revlist_args);
+ string_list_append(&revlist_args, ref->name);
}
diff --git a/wt-status.c b/wt-status.c
index 9d9cb95562..38754ad735 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -235,7 +235,7 @@ static void wt_status_collect_changed_cb(struct diff_queue_struct *q,
struct wt_status_change_data *d;
p = q->queue[i];
- it = string_list_insert(p->one->path, &s->change);
+ it = string_list_insert(&s->change, p->one->path);
d = it->util;
if (!d) {
d = xcalloc(1, sizeof(*d));
@@ -282,7 +282,7 @@ static void wt_status_collect_updated_cb(struct diff_queue_struct *q,
struct wt_status_change_data *d;
p = q->queue[i];
- it = string_list_insert(p->two->path, &s->change);
+ it = string_list_insert(&s->change, p->two->path);
d = it->util;
if (!d) {
d = xcalloc(1, sizeof(*d));
@@ -349,7 +349,7 @@ static void wt_status_collect_changes_initial(struct wt_status *s)
if (!ce_path_match(ce, s->pathspec))
continue;
- it = string_list_insert(ce->name, &s->change);
+ it = string_list_insert(&s->change, ce->name);
d = it->util;
if (!d) {
d = xcalloc(1, sizeof(*d));
@@ -384,7 +384,7 @@ static void wt_status_collect_untracked(struct wt_status *s)
continue;
if (!match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL))
continue;
- string_list_insert(ent->name, &s->untracked);
+ string_list_insert(&s->untracked, ent->name);
free(ent);
}
@@ -398,7 +398,7 @@ static void wt_status_collect_untracked(struct wt_status *s)
continue;
if (!match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL))
continue;
- string_list_insert(ent->name, &s->ignored);
+ string_list_insert(&s->ignored, ent->name);
free(ent);
}
}