fast-import.c: fix regression due to strbuf conversion
[gitweb.git] / builtin-fetch.c
index 997a8ff954de919c35140b1523663d78176599c5..b9d2b0c27e3c09dd2746db94c25c00eaa492ba7c 100644 (file)
@@ -102,16 +102,23 @@ static struct ref *get_ref_map(struct transport *transport,
                                    remote->fetch[i].dst[0])
                                        *autotags = 1;
                                if (!i && !has_merge && ref_map &&
-                                   !strcmp(remote->fetch[0].src, ref_map->name))
+                                   !remote->fetch[0].pattern)
                                        ref_map->merge = 1;
                        }
-                       if (has_merge)
+                       /*
+                        * if the remote we're fetching from is the same
+                        * as given in branch.<name>.remote, we add the
+                        * ref given in branch.<name>.merge, too.
+                        */
+                       if (has_merge && !strcmp(branch->remote_name,
+                                               remote->name))
                                add_merge_config(&ref_map, remote_refs, branch, &tail);
                } else {
                        ref_map = get_remote_ref(remote_refs, "HEAD");
                        ref_map->merge = 1;
                }
        }
+       ref_remove_duplicates(ref_map);
 
        return ref_map;
 }
@@ -195,8 +202,8 @@ static int update_local_ref(struct ref *ref,
                return s_update_ref("updating tag", ref, 0);
        }
 
-       current = lookup_commit_reference(ref->old_sha1);
-       updated = lookup_commit_reference(ref->new_sha1);
+       current = lookup_commit_reference_gently(ref->old_sha1, 1);
+       updated = lookup_commit_reference_gently(ref->new_sha1, 1);
        if (!current || !updated) {
                char *msg;
                if (!strncmp(ref->name, "refs/tags/", 10))
@@ -254,7 +261,7 @@ static void store_updated_refs(const char *url, struct ref *ref_map)
                        ref->force = rm->peer_ref->force;
                }
 
-               commit = lookup_commit_reference(rm->old_sha1);
+               commit = lookup_commit_reference_gently(rm->old_sha1, 1);
                if (!commit)
                        rm->merge = 0;
 
@@ -392,8 +399,7 @@ static int do_fetch(struct transport *transport,
        if (transport->remote->fetch_tags == -1)
                no_tags = 1;
 
-       if (!transport->ops || !transport->ops->get_refs_list ||
-           !transport->ops->fetch)
+       if (!transport->get_refs_list || !transport->fetch)
                die("Don't know how to fetch from %s", transport->url);
 
        /* if not appending, truncate FETCH_HEAD */
@@ -534,7 +540,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
        if (verbose >= 2)
                transport->verbose = 1;
        if (quiet)
-               transport->verbose = 0;
+               transport->verbose = -1;
        if (upload_pack)
                set_option(TRANS_OPT_UPLOADPACK, upload_pack);
        if (keep)