Code

string_list: Fix argument order for string_list_lookup
authorJulian Phillips <julian@quantumfyre.co.uk>
Fri, 25 Jun 2010 23:41:37 +0000 (00:41 +0100)
committerJunio C Hamano <gitster@pobox.com>
Sun, 27 Jun 2010 17:06:51 +0000 (10:06 -0700)
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>
builtin/apply.c
builtin/fetch.c
builtin/receive-pack.c
http-backend.c
mailmap.c
merge-recursive.c
reflog-walk.c
remote.c
resolve-undo.c
string-list.c
string-list.h

index 57151225fe9b1cb55678597e3bc8b5c5b706e659..cf92f12a1bfd6e84dcdf60bb397587e6c7e3df8d 100644 (file)
@@ -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;
 
index e4296ab3bd1771e730a2955651163037f65fa6de..9165bb6052f95fd127e7c2911a0f58b5281211c5 100644 (file)
@@ -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);
index bb34757d27f32fff8cb15a8f99d8295b5e38cb9e..8b5a4656ec6143436e1f1a6f1d589b1ee6d73001 100644 (file)
@@ -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;
index 0e7af4eebb277feb45e4ecbbd3facc7dac395c53..8ec15f99c05cbdcc432cce95bdf1b6a45347368d 100644 (file)
@@ -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;
 }
 
index 8b6dc36bbc54bf8c4606ad9ecf03b8cdcc8f9dac..f80b701292f0d852950735ab20a63dac13e92362 100644 (file)
--- a/mailmap.c
+++ b/mailmap.c
@@ -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;
                }
index 5e60f4ba224b6c49bb7434023a8f7ac73297d7c5..856e98c0837f422f18d57aa4f3ca453120882bca 100644 (file)
@@ -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;
index f125f374612a373f0875951f3aa683cb19fea66a..4879615cad7527dc5346cd1a85bd56b9d11e052b 100644 (file)
@@ -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 {
index 7ce714ca2fc9865278cc5adfe3c3866ca352f7a9..5a658381150520056ea70aed5a15882bbb448bd8 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -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))
index 8b935594aaa707a6eff146a998250196ae2a654b..174ebec9e573b1942e379942037f38500bd19b97 100644 (file)
@@ -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;
index 84444c2c19e623ac7bf825ea331918b6db9e9666..7b616ae825ae08138e89ef47fb6d39b1fa54f6cb 100644 (file)
@@ -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)
index a4e1919ada3c2ac95765bc0e952b1328a18e53d1..4a30e9d1045def8a2b563580aea75d392cb5e131 100644 (file)
@@ -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);