]> git.ipfire.org Git - thirdparty/git.git/blobdiff - remote.c
Merge branch 'master' of git://git.kernel.org/pub/scm/gitk/gitk
[thirdparty/git.git] / remote.c
index 2166a2bf15d20d5e51696fe3b56e4d66b0b12061..170015aabfc18d028b22a5200cbddc5a5ec3f042 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -380,6 +380,33 @@ int for_each_remote(each_remote_fn fn, void *priv)
        return result;
 }
 
+void ref_remove_duplicates(struct ref *ref_map)
+{
+       struct ref **posn;
+       struct ref *next;
+       for (; ref_map; ref_map = ref_map->next) {
+               if (!ref_map->peer_ref)
+                       continue;
+               posn = &ref_map->next;
+               while (*posn) {
+                       if ((*posn)->peer_ref &&
+                           !strcmp((*posn)->peer_ref->name,
+                                   ref_map->peer_ref->name)) {
+                               if (strcmp((*posn)->name, ref_map->name))
+                                       die("%s tracks both %s and %s",
+                                           ref_map->peer_ref->name,
+                                           (*posn)->name, ref_map->name);
+                               next = (*posn)->next;
+                               free((*posn)->peer_ref);
+                               free(*posn);
+                               *posn = next;
+                       } else {
+                               posn = &(*posn)->next;
+                       }
+               }
+       }
+}
+
 int remote_has_url(struct remote *remote, const char *url)
 {
        int i;
@@ -610,8 +637,11 @@ static int match_explicit(struct ref *src, struct ref *dst,
        if (!matched_src)
                errs = 1;
 
-       if (!dst_value)
+       if (!dst_value) {
+               if (!matched_src)
+                       return errs;
                dst_value = matched_src->name;
+       }
 
        switch (count_refspec_match(dst_value, dst, &matched_dst)) {
        case 1:
@@ -732,6 +762,8 @@ int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
                        hashcpy(dst_peer->new_sha1, src->new_sha1);
                }
                dst_peer->peer_ref = src;
+               if (pat)
+                       dst_peer->force = pat->force;
        free_name:
                free(dst_name);
        }
@@ -879,7 +911,8 @@ int get_fetch_map(struct ref *remote_refs,
                            rm->peer_ref->name);
        }
 
-       tail_link_ref(ref_map, tail);
+       if (ref_map)
+               tail_link_ref(ref_map, tail);
 
        return 0;
 }