зеркало из https://github.com/microsoft/git.git
string_list: Fix argument order for string_list_insert
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>
This commit is contained in:
Родитель
b684e97736
Коммит
78a395d371
|
@ -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;
|
||||
|
|
|
@ -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 */
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -92,7 +92,7 @@ static struct string_list *get_parameters(void)
|
|||
|
||||
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;
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
@ -296,7 +296,7 @@ static struct string_list *get_unmerged(void)
|
|||
|
||||
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;
|
||||
|
@ -369,7 +369,7 @@ static struct string_list *get_renames(struct merge_options *o,
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
2
remote.c
2
remote.c
|
@ -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);
|
||||
|
|
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;
|
||||
|
@ -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;
|
||||
|
|
|
@ -51,7 +51,7 @@ 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);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ int for_each_string_list(struct string_list *list,
|
|||
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);
|
||||
|
|
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);
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче