match_refs: search ref list tail internally
[gitweb.git] / builtin-remote.c
index ca7c639ad30fd5682014eb984ab18d3fb0546c67..9248e0aac79462261ba3cf2b21342c93c38fc1eb 100644 (file)
@@ -294,17 +294,14 @@ static int get_push_ref_states(const struct ref *remote_refs,
        struct ref_states *states)
 {
        struct remote *remote = states->remote;
-       struct ref *ref, *local_refs, *push_map, **push_tail;
+       struct ref *ref, *local_refs, *push_map;
        if (remote->mirror)
                return 0;
 
        local_refs = get_local_heads();
-       ref = push_map = copy_ref_list(remote_refs);
-       while (ref->next)
-               ref = ref->next;
-       push_tail = &ref->next;
+       push_map = copy_ref_list(remote_refs);
 
-       match_refs(local_refs, push_map, &push_tail, remote->push_refspec_nr,
+       match_refs(local_refs, &push_map, remote->push_refspec_nr,
                   remote->push_refspec, MATCH_REFS_NONE);
 
        states->push.strdup_strings = 1;
@@ -525,8 +522,8 @@ static int migrate_file(struct remote *remote)
                path = git_path("remotes/%s", remote->name);
        else if (remote->origin == REMOTE_BRANCHES)
                path = git_path("branches/%s", remote->name);
-       if (path && unlink(path))
-               warning("failed to remove '%s'", path);
+       if (path)
+               unlink_or_warn(path);
        return 0;
 }
 
@@ -1216,7 +1213,7 @@ static int update(int argc, const char **argv)
        struct option options[] = {
                OPT_GROUP("update specific options"),
                OPT_BOOLEAN('p', "prune", &prune,
-                           "prune remotes after fecthing"),
+                           "prune remotes after fetching"),
                OPT_END()
        };