string_list: Fix argument order for string_list_lookup

Update the definition and callers of string_list_lookup 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:
Julian Phillips 2010-06-26 00:41:37 +01:00 коммит произвёл Junio C Hamano
Родитель aadceea641
Коммит e8c8b7139c
11 изменённых файлов: 17 добавлений и 17 удалений

Просмотреть файл

@ -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;

Просмотреть файл

@ -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);

Просмотреть файл

@ -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;

Просмотреть файл

@ -90,7 +90,7 @@ 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(query_params, name);
else
@ -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;
}

Просмотреть файл

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

Просмотреть файл

@ -294,7 +294,7 @@ 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(unmerged, ce->name);
item->util = xcalloc(1, sizeof(struct stage_data));
@ -356,14 +356,14 @@ 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);
@ -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;

Просмотреть файл

@ -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 {

Просмотреть файл

@ -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))

Просмотреть файл

@ -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;

Просмотреть файл

@ -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)

Просмотреть файл

@ -32,7 +32,7 @@ int string_list_find_insert_index(const struct string_list *list, const char *st
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(const char *string, struct string_list *list);
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);