summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b684e97)
raw | patch | inline | side by side (parent: b684e97)
author | Julian Phillips <julian@quantumfyre.co.uk> | |
Fri, 25 Jun 2010 23:41:35 +0000 (00:41 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 27 Jun 2010 17:06:51 +0000 (10:06 -0700) |
Update the definition and callers of string_list_insert to use the
string_list as the first argument. This helps make the string_list
API easier to use by being more consistent.
Signed-off-by: Julian Phillips <julian@quantumfyre.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
string_list as the first argument. This helps make the string_list
API easier to use by being more consistent.
Signed-off-by: Julian Phillips <julian@quantumfyre.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
19 files changed:
builtin/apply.c | patch | blob | history | |
builtin/commit.c | patch | blob | history | |
builtin/fetch.c | patch | blob | history | |
builtin/mailsplit.c | patch | blob | history | |
builtin/mv.c | patch | blob | history | |
builtin/remote.c | patch | blob | history | |
builtin/shortlog.c | patch | blob | history | |
builtin/show-ref.c | patch | blob | history | |
diff-no-index.c | patch | blob | history | |
http-backend.c | patch | blob | history | |
mailmap.c | patch | blob | history | |
merge-recursive.c | patch | blob | history | |
reflog-walk.c | patch | blob | history | |
remote.c | patch | blob | history | |
rerere.c | patch | blob | history | |
resolve-undo.c | patch | blob | history | |
string-list.c | patch | blob | history | |
string-list.h | patch | blob | history | |
wt-status.c | patch | blob | history |
diff --git a/builtin/apply.c b/builtin/apply.c
index 8fc5ec31deae63122878bdb776921bcf656fb791..57151225fe9b1cb55678597e3bc8b5c5b706e659 100644 (file)
--- a/builtin/apply.c
+++ b/builtin/apply.c
* 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;
}
* 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;
}
}
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;
diff --git a/builtin/commit.c b/builtin/commit.c
index ddf77e48e1d9fa1e6db0ac49008857b85a9b5e41..763fe74b905f28a2061fa1da16b935d3bf4d5fd4 100644 (file)
--- a/builtin/commit.c
+++ b/builtin/commit.c
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/fetch.c b/builtin/fetch.c
index b040e5a31d417d39a1cd9520dfd6b71ebf2f75a3..e4296ab3bd1771e730a2955651163037f65fa6de 100644 (file)
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
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;
}
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);
diff --git a/builtin/mailsplit.c b/builtin/mailsplit.c
index cdfc1b70429dc5d47e42e7aabc9449a585623b0f..e4560da19138cd67843f93a05bc6509d51cfe076 100644 (file)
--- a/builtin/mailsplit.c
+++ b/builtin/mailsplit.c
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 c07f53b34380200eaba223d2e1f8f977c1f9fd18..38574b89f7cfc127b2ea5044b3ebb5dabe726fb4 100644 (file)
--- a/builtin/mv.c
+++ b/builtin/mv.c
} 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/remote.c b/builtin/remote.c
index 67a3b4ac43d3347534b7e8b91ed0e62015363de6..7e9299cfcebad7ec51caab3039236c387027e122 100644 (file)
--- a/builtin/remote.c
+++ b/builtin/remote.c
} 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);
@@ -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;
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 5089502800d5f477f47b6cd6499d278097f11e67..86d32fb7ffdb5ce6523152b80ebbc71979f887f6 100644 (file)
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
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));
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index 17ada88dfb9543ba782b84507b451fabfec28e10..0b2a9ad1a9a8a825c2e2104f8a9f729a9cb03d1a 100644 (file)
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
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 4cd9dacbe8e98d1420ebe1a217b0f927d24d125a..43aeeba2e0fd9c3c175dbc74a6f488e2c352c928 100644 (file)
--- a/diff-no-index.c
+++ b/diff-no-index.c
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 d1e83d0906dbc9d677630cdf74615ec3f9dfc46d..0e7af4eebb277feb45e4ecbbd3facc7dac395c53 100644 (file)
--- a/http-backend.c
+++ b/http-backend.c
i = string_list_lookup(name, query_params);
if (!i)
- i = string_list_insert(name, query_params);
+ i = string_list_insert(query_params, name);
else
free(i->util);
i->util = value;
diff --git a/mailmap.c b/mailmap.c
index b68c1fec9c2ca69f313bc3fa16461c6c9150c53d..badf6a4dad909e2cd462ee08682f98334b6102e8 100644 (file)
--- a/mailmap.c
+++ b/mailmap.c
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",
diff --git a/merge-recursive.c b/merge-recursive.c
index 206c1036359ce7b1fc5a1f5734b2d0bc2a760d90..5e60f4ba224b6c49bb7434023a8f7ac73297d7c5 100644 (file)
--- a/merge-recursive.c
+++ b/merge-recursive.c
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);
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;
}
item = string_list_lookup(ce->name, unmerged);
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;
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;
}
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;
}
diff --git a/reflog-walk.c b/reflog-walk.c
index caba4f743f2dcc1cf7046cec294f242b2af19052..f125f374612a373f0875951f3aa683cb19fea66a 100644 (file)
--- a/reflog-walk.c
+++ b/reflog-walk.c
}
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 0f073e0b5f9f08510af3a9e0ab5aed106475b30f..7ce714ca2fc9865278cc5adfe3c3866ca352f7a9 100644 (file)
--- a/remote.c
+++ b/remote.c
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);
diff --git a/rerere.c b/rerere.c
index f221bed1e97a0f1b41d1845edac270a109e3a4dd..910cfd963dcdbcb096b36b91868955a65ecdffa1 100644 (file)
--- a/rerere.c
+++ b/rerere.c
; /* 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);
}
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 */
}
}
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"));
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
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 e93b3d1b530e878245ac68d76230e028d596d4a7..8b935594aaa707a6eff146a998250196ae2a654b 100644 (file)
--- a/resolve-undo.c
+++ b/resolve-undo.c
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;
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;
diff --git a/string-list.c b/string-list.c
index 09798a2dc8277286454998e74297e868b9345857..de89efd2d88fcdcbe7e1b52c800c451dd95890e4 100644 (file)
--- a/string-list.c
+++ b/string-list.c
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);
}
diff --git a/string-list.h b/string-list.h
index 1e2dfc3453ec786bc38fcbacec63e4bb5f058e44..3d5a8de4b5a4977900268f29ccc92a09bd98c6b3 100644 (file)
--- a/string-list.h
+++ b/string-list.h
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(struct string_list *list, const char *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_lookup(const char *string, struct string_list *list);
diff --git a/wt-status.c b/wt-status.c
index 14e0acce8cc92f332a5b88482621119ec4dc1ded..1653cfa9d66395b97ccdd64f9bd9d35ca9521484 100644 (file)
--- a/wt-status.c
+++ b/wt-status.c
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));
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));
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));
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);
}
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);
}
}