Skip to content

Commit

Permalink
Merge branch 'jp/string-list-api-cleanup' into jn/grep-open
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Julian Phillips authored and Junio C Hamano committed Jun 27, 2010
2 parents 7f5329f + 1d2f80f commit 0c72cea
Show file tree
Hide file tree
Showing 30 changed files with 150 additions and 150 deletions.
4 changes: 2 additions & 2 deletions Documentation/technical/api-string-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
----
Expand Down
10 changes: 5 additions & 5 deletions builtin/apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}
}
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion builtin/commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
}
Expand Down
4 changes: 2 additions & 2 deletions builtin/fast-export.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
}
Expand Down
18 changes: 9 additions & 9 deletions builtin/fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand All @@ -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");
Expand All @@ -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;
}
Expand Down
18 changes: 9 additions & 9 deletions builtin/fmt-merge-msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions builtin/grep.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
}
}
Expand Down
20 changes: 10 additions & 10 deletions builtin/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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")) {
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion builtin/ls-files.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion builtin/mailsplit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion builtin/mv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions builtin/receive-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 0c72cea

Please sign in to comment.