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 <julian@quantumfyre.co.uk> Subject: [PATCH v2 7/7] grep: fix string_list_append calls Date: Sat, 26 Jun 2010 00:41:39 +0100 Message-ID: <20100625234140.18927.35025.julian@quantumfyre.co.uk> * 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 <julian@quantumfyre.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
commit
0c72cead84
@ -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)
|
||||
----
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -212,7 +212,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 */
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
@ -616,7 +616,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);
|
||||
@ -633,7 +633,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);
|
||||
}
|
||||
@ -695,8 +695,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);
|
||||
@ -745,7 +745,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;
|
||||
}
|
||||
|
||||
@ -764,8 +764,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");
|
||||
@ -786,7 +786,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;
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -564,7 +564,7 @@ static void append_path(struct grep_opt *opt, const void *data, size_t len)
|
||||
|
||||
if (len == 1 && *(const char *)data == '\0')
|
||||
return;
|
||||
string_list_append(xstrndup(data, len), path_list);
|
||||
string_list_append(path_list, xstrndup(data, len));
|
||||
}
|
||||
|
||||
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)
|
||||
opt.null_following_name = 1;
|
||||
opt.output_priv = &path_list;
|
||||
opt.output = append_path;
|
||||
string_list_append(show_in_pager, &path_list);
|
||||
string_list_append(&path_list, show_in_pager);
|
||||
use_threads = 0;
|
||||
}
|
||||
|
||||
@ -1076,7 +1076,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
|
||||
strbuf_addf(&buf, "+/%s%s",
|
||||
strcmp("less", pager) ? "" : "*",
|
||||
opt.pattern_list->pattern);
|
||||
string_list_append(buf.buf, &path_list);
|
||||
string_list_append(&path_list, buf.buf);
|
||||
strbuf_detach(&buf, NULL);
|
||||
}
|
||||
}
|
||||
|
@ -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';
|
||||
@ -565,13 +565,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")) {
|
||||
@ -949,7 +949,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;
|
||||
}
|
||||
|
||||
@ -958,7 +958,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;
|
||||
}
|
||||
|
||||
@ -1239,7 +1239,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;
|
||||
@ -1286,8 +1286,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));
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ static void show_ru_info(const char *prefix)
|
||||
{
|
||||
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, const char *prefix)
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -87,7 +87,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;
|
||||
}
|
||||
|
||||
@ -160,7 +160,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++) {
|
||||
struct string_list_item *item = track.items + i;
|
||||
|
||||
@ -251,7 +251,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);
|
||||
@ -266,11 +266,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);
|
||||
}
|
||||
@ -307,14 +307,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);
|
||||
@ -363,8 +363,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;
|
||||
@ -399,7 +399,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);
|
||||
@ -407,11 +407,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;
|
||||
@ -435,7 +435,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);
|
||||
@ -499,8 +499,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;
|
||||
}
|
||||
@ -509,7 +509,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);
|
||||
|
||||
@ -534,7 +534,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);
|
||||
@ -817,7 +817,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;
|
||||
}
|
||||
@ -870,7 +870,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;
|
||||
}
|
||||
|
||||
@ -917,7 +917,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;
|
||||
@ -965,7 +965,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;
|
||||
}
|
||||
@ -1081,24 +1081,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 */
|
||||
@ -1106,14 +1106,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);
|
||||
@ -1379,10 +1379,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;
|
||||
@ -1393,7 +1393,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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -90,9 +90,9 @@ static struct string_list *get_parameters(void)
|
||||
char *value = decode_parameter(&query, 0);
|
||||
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;
|
||||
@ -104,7 +104,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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
12
notes.c
12
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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
6
remote.c
6
remote.c
@ -763,7 +763,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))
|
||||
@ -778,7 +778,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);
|
||||
@ -1711,7 +1711,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);
|
||||
|
10
rerere.c
10
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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -1205,8 +1205,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;
|
||||
|
@ -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 =
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
10
wt-status.c
10
wt-status.c
@ -232,7 +232,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));
|
||||
@ -279,7 +279,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));
|
||||
@ -346,7 +346,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));
|
||||
@ -381,7 +381,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);
|
||||
}
|
||||
|
||||
@ -395,7 +395,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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user