@matheusbsbs / matheus-bagliano / commits / e8c8b7139c
Fork 0

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>

Julian Phillips committed Jun 26, 2010 at 00:41 UTC e8c8b7139c87c3e3017d3bff07f91c4349850d58
11 files changed +17 -17
builtin/apply.c
+1 -1
@@ -2628,7 +2628,7 @@ static struct patch *in_fn_table(const char *name)
2628 if (name == NULL)
2629 return NULL;
2630
2631 - item = string_list_lookup(name, &fn_table);
2631 + item = string_list_lookup(&fn_table, name);
2632 if (item != NULL)
2633 return (struct patch *)item->util;
2634
builtin/fetch.c
+2 -2
@@ -695,8 +695,8 @@ static int do_fetch(struct transport *transport,
695
696 for (rm = ref_map; rm; rm = rm->next) {
697 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);
700 if (peer_item)
701 hashcpy(rm->peer_ref->old_sha1,
702 peer_item->util);
builtin/receive-pack.c
+1 -1
@@ -501,7 +501,7 @@ static void check_aliased_update(struct command *cmd, struct string_list *list)
501 if (!(flag & REF_ISSYMREF))
502 return;
503
504 - if ((item = string_list_lookup(dst_name, list)) == NULL)
504 + if ((item = string_list_lookup(list, dst_name)) == NULL)
505 return;
506
507 cmd->skip_update = 1;
http-backend.c
+2 -2
@@ -90,7 +90,7 @@ static struct string_list *get_parameters(void)
90 char *value = decode_parameter(&query, 0);
91 struct string_list_item *i;
92
93 - i = string_list_lookup(name, query_params);
93 + i = string_list_lookup(query_params, name);
94 if (!i)
95 i = string_list_insert(query_params, name);
96 else
@@ -104,7 +104,7 @@ static struct string_list *get_parameters(void)
104 static const char *get_parameter(const char *name)
105 {
106 struct string_list_item *i;
107 - i = string_list_lookup(name, get_parameters());
107 + i = string_list_lookup(get_parameters(), name);
108 return i ? i->util : NULL;
109 }
110
mailmap.c
+2 -2
@@ -214,13 +214,13 @@ int map_user(struct string_list *map,
214 mailbuf[i] = 0;
215
216 debug_mm("map_user: map '%s' <%s>\n", name, mailbuf);
217 - item = string_list_lookup(mailbuf, map);
217 + item = string_list_lookup(map, mailbuf);
218 if (item != NULL) {
219 me = (struct mailmap_entry *)item->util;
220 if (me->namemap.nr) {
221 /* The item has multiple items, so we'll look up on name too */
222 /* 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);
224 if (subitem)
225 item = subitem;
226 }
merge-recursive.c
+4 -4
@@ -294,7 +294,7 @@ static struct string_list *get_unmerged(void)
294 if (!ce_stage(ce))
295 continue;
296
297 - item = string_list_lookup(ce->name, unmerged);
297 + item = string_list_lookup(unmerged, ce->name);
298 if (!item) {
299 item = string_list_insert(unmerged, ce->name);
300 item->util = xcalloc(1, sizeof(struct stage_data));
@@ -356,14 +356,14 @@ static struct string_list *get_renames(struct merge_options *o,
356 re = xmalloc(sizeof(*re));
357 re->processed = 0;
358 re->pair = pair;
359 - item = string_list_lookup(re->pair->one->path, entries);
359 + item = string_list_lookup(entries, re->pair->one->path);
360 if (!item)
361 re->src_entry = insert_stage_data(re->pair->one->path,
362 o_tree, a_tree, b_tree, entries);
363 else
364 re->src_entry = item->util;
365
366 - item = string_list_lookup(re->pair->two->path, entries);
366 + item = string_list_lookup(entries, re->pair->two->path);
367 if (!item)
368 re->dst_entry = insert_stage_data(re->pair->two->path,
369 o_tree, a_tree, b_tree, entries);
@@ -988,7 +988,7 @@ static int process_renames(struct merge_options *o,
988 output(o, 1, "Adding as %s instead", new_path);
989 update_file(o, 0, dst_other.sha1, dst_other.mode, new_path);
990 }
991 - } else if ((item = string_list_lookup(ren1_dst, renames2Dst))) {
991 + } else if ((item = string_list_lookup(renames2Dst, ren1_dst))) {
992 ren2 = item->util;
993 clean_merge = 0;
994 ren2->processed = 1;
reflog-walk.c
+1 -1
@@ -162,7 +162,7 @@ int add_reflog_for_walk(struct reflog_walk_info *info,
162 } else
163 recno = 0;
164
165 - item = string_list_lookup(branch, &info->complete_reflogs);
165 + item = string_list_lookup(&info->complete_reflogs, branch);
166 if (item)
167 reflogs = item->util;
168 else {
remote.c
+1 -1
@@ -763,7 +763,7 @@ void ref_remove_duplicates(struct ref *ref_map)
763 if (!ref_map->peer_ref)
764 continue;
765
766 - item = string_list_lookup(ref_map->peer_ref->name, &refs);
766 + item = string_list_lookup(&refs, ref_map->peer_ref->name);
767 if (item) {
768 if (strcmp(((struct ref *)item->util)->name,
769 ref_map->name))
resolve-undo.c
+1 -1
@@ -135,7 +135,7 @@ int unmerge_index_entry_at(struct index_state *istate, int pos)
135 pos++;
136 return pos - 1; /* return the last entry processed */
137 }
138 - item = string_list_lookup(ce->name, istate->resolve_undo);
138 + item = string_list_lookup(istate->resolve_undo, ce->name);
139 if (!item)
140 return pos;
141 ru = item->util;
string-list.c
+1 -1
@@ -84,7 +84,7 @@ int string_list_find_insert_index(const struct string_list *list, const char *st
84 return index;
85 }
86
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)
88 {
89 int exact_match, i = get_entry_index(list, string, &exact_match);
90 if (!exact_match)
string-list.h
+1 -1
@@ -32,7 +32,7 @@ int string_list_find_insert_index(const struct string_list *list, const char *st
32 struct string_list_item *string_list_insert(struct string_list *list, const char *string);
33 struct string_list_item *string_list_insert_at_index(struct string_list *list,
34 int insert_at, const char *string);
35 -struct string_list_item *string_list_lookup(const char *string, struct string_list *list);
35 +struct string_list_item *string_list_lookup(struct string_list *list, const char *string);
36
37 /* Use these functions only on unsorted lists: */
38 struct string_list_item *string_list_append(const char *string, struct string_list *list);