Skip to content

Commit e8c8b71

Browse files
qurgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent aadceea commit e8c8b71

File tree

11 files changed

+17
-17
lines changed

11 files changed

+17
-17
lines changed

builtin/apply.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2628,7 +2628,7 @@ static struct patch *in_fn_table(const char *name)
26282628
if (name == NULL)
26292629
return NULL;
26302630

2631-
item = string_list_lookup(name, &fn_table);
2631+
item = string_list_lookup(&fn_table, name);
26322632
if (item != NULL)
26332633
return (struct patch *)item->util;
26342634

builtin/fetch.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -695,8 +695,8 @@ static int do_fetch(struct transport *transport,
695695

696696
for (rm = ref_map; rm; rm = rm->next) {
697697
if (rm->peer_ref) {
698-
peer_item = string_list_lookup(rm->peer_ref->name,
699-
&existing_refs);
698+
peer_item = string_list_lookup(&existing_refs,
699+
rm->peer_ref->name);
700700
if (peer_item)
701701
hashcpy(rm->peer_ref->old_sha1,
702702
peer_item->util);

builtin/receive-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ static void check_aliased_update(struct command *cmd, struct string_list *list)
501501
if (!(flag & REF_ISSYMREF))
502502
return;
503503

504-
if ((item = string_list_lookup(dst_name, list)) == NULL)
504+
if ((item = string_list_lookup(list, dst_name)) == NULL)
505505
return;
506506

507507
cmd->skip_update = 1;

http-backend.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ static struct string_list *get_parameters(void)
9090
char *value = decode_parameter(&query, 0);
9191
struct string_list_item *i;
9292

93-
i = string_list_lookup(name, query_params);
93+
i = string_list_lookup(query_params, name);
9494
if (!i)
9595
i = string_list_insert(query_params, name);
9696
else
@@ -104,7 +104,7 @@ static struct string_list *get_parameters(void)
104104
static const char *get_parameter(const char *name)
105105
{
106106
struct string_list_item *i;
107-
i = string_list_lookup(name, get_parameters());
107+
i = string_list_lookup(get_parameters(), name);
108108
return i ? i->util : NULL;
109109
}
110110

mailmap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,13 @@ int map_user(struct string_list *map,
214214
mailbuf[i] = 0;
215215

216216
debug_mm("map_user: map '%s' <%s>\n", name, mailbuf);
217-
item = string_list_lookup(mailbuf, map);
217+
item = string_list_lookup(map, mailbuf);
218218
if (item != NULL) {
219219
me = (struct mailmap_entry *)item->util;
220220
if (me->namemap.nr) {
221221
/* The item has multiple items, so we'll look up on name too */
222222
/* If the name is not found, we choose the simple entry */
223-
struct string_list_item *subitem = string_list_lookup(name, &me->namemap);
223+
struct string_list_item *subitem = string_list_lookup(&me->namemap, name);
224224
if (subitem)
225225
item = subitem;
226226
}

merge-recursive.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ static struct string_list *get_unmerged(void)
294294
if (!ce_stage(ce))
295295
continue;
296296

297-
item = string_list_lookup(ce->name, unmerged);
297+
item = string_list_lookup(unmerged, ce->name);
298298
if (!item) {
299299
item = string_list_insert(unmerged, ce->name);
300300
item->util = xcalloc(1, sizeof(struct stage_data));
@@ -356,14 +356,14 @@ static struct string_list *get_renames(struct merge_options *o,
356356
re = xmalloc(sizeof(*re));
357357
re->processed = 0;
358358
re->pair = pair;
359-
item = string_list_lookup(re->pair->one->path, entries);
359+
item = string_list_lookup(entries, re->pair->one->path);
360360
if (!item)
361361
re->src_entry = insert_stage_data(re->pair->one->path,
362362
o_tree, a_tree, b_tree, entries);
363363
else
364364
re->src_entry = item->util;
365365

366-
item = string_list_lookup(re->pair->two->path, entries);
366+
item = string_list_lookup(entries, re->pair->two->path);
367367
if (!item)
368368
re->dst_entry = insert_stage_data(re->pair->two->path,
369369
o_tree, a_tree, b_tree, entries);
@@ -988,7 +988,7 @@ static int process_renames(struct merge_options *o,
988988
output(o, 1, "Adding as %s instead", new_path);
989989
update_file(o, 0, dst_other.sha1, dst_other.mode, new_path);
990990
}
991-
} else if ((item = string_list_lookup(ren1_dst, renames2Dst))) {
991+
} else if ((item = string_list_lookup(renames2Dst, ren1_dst))) {
992992
ren2 = item->util;
993993
clean_merge = 0;
994994
ren2->processed = 1;

reflog-walk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ int add_reflog_for_walk(struct reflog_walk_info *info,
162162
} else
163163
recno = 0;
164164

165-
item = string_list_lookup(branch, &info->complete_reflogs);
165+
item = string_list_lookup(&info->complete_reflogs, branch);
166166
if (item)
167167
reflogs = item->util;
168168
else {

remote.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ void ref_remove_duplicates(struct ref *ref_map)
763763
if (!ref_map->peer_ref)
764764
continue;
765765

766-
item = string_list_lookup(ref_map->peer_ref->name, &refs);
766+
item = string_list_lookup(&refs, ref_map->peer_ref->name);
767767
if (item) {
768768
if (strcmp(((struct ref *)item->util)->name,
769769
ref_map->name))

resolve-undo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ int unmerge_index_entry_at(struct index_state *istate, int pos)
135135
pos++;
136136
return pos - 1; /* return the last entry processed */
137137
}
138-
item = string_list_lookup(ce->name, istate->resolve_undo);
138+
item = string_list_lookup(istate->resolve_undo, ce->name);
139139
if (!item)
140140
return pos;
141141
ru = item->util;

string-list.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ int string_list_find_insert_index(const struct string_list *list, const char *st
8484
return index;
8585
}
8686

87-
struct string_list_item *string_list_lookup(const char *string, struct string_list *list)
87+
struct string_list_item *string_list_lookup(struct string_list *list, const char *string)
8888
{
8989
int exact_match, i = get_entry_index(list, string, &exact_match);
9090
if (!exact_match)

0 commit comments

Comments
 (0)