X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=builtin-fetch.c;h=003ed76d16236ec6857a19d6223518e6e73bdc93;hb=e2b7eaf0ca3897940961d23392d4ff718867ea9f;hp=cf7498b15fe91e2d138f384fa304c7f4e90f454d;hpb=2b5a06edca8f7237aad6464b349b79772024d2a2;p=git.git diff --git a/builtin-fetch.c b/builtin-fetch.c index cf7498b15..003ed76d1 100644 --- a/builtin-fetch.c +++ b/builtin-fetch.c @@ -48,15 +48,21 @@ static void add_merge_config(struct ref **head, if (rm) continue; - /* Not fetched to a tracking branch? We need to fetch + /* + * Not fetched to a tracking branch? We need to fetch * it anyway to allow this branch's "branch.$name.merge" - * to be honored by git-pull. + * to be honored by git-pull, but we do not have to + * fail if branch.$name.merge is misconfigured to point + * at a nonexisting branch. If we were indeed called by + * git-pull, it will notice the misconfiguration because + * there is no entry in the resulting FETCH_HEAD marked + * for merging. */ refspec.src = branch->merge[i]->src; refspec.dst = NULL; refspec.pattern = 0; refspec.force = 0; - get_fetch_map(remote_refs, &refspec, tail); + get_fetch_map(remote_refs, &refspec, tail, 1); for (rm = *old_tail; rm; rm = rm->next) rm->merge = 1; } @@ -75,7 +81,7 @@ static struct ref *get_ref_map(struct transport *transport, if (ref_count || tags) { for (i = 0; i < ref_count; i++) { - get_fetch_map(remote_refs, &refs[i], &tail); + get_fetch_map(remote_refs, &refs[i], &tail, 0); if (refs[i].dst && refs[i].dst[0]) *autotags = 1; } @@ -88,7 +94,7 @@ static struct ref *get_ref_map(struct transport *transport, refspec.dst = "refs/tags/"; refspec.pattern = 1; refspec.force = 0; - get_fetch_map(remote_refs, &refspec, &tail); + get_fetch_map(remote_refs, &refspec, &tail, 0); } } else { /* Use the defaults */ @@ -97,7 +103,7 @@ static struct ref *get_ref_map(struct transport *transport, int has_merge = branch_has_merge_config(branch); if (remote && (remote->fetch_refspec_nr || has_merge)) { for (i = 0; i < remote->fetch_refspec_nr; i++) { - get_fetch_map(remote_refs, &remote->fetch[i], &tail); + get_fetch_map(remote_refs, &remote->fetch[i], &tail, 0); if (remote->fetch[i].dst && remote->fetch[i].dst[0]) *autotags = 1; @@ -105,13 +111,22 @@ static struct ref *get_ref_map(struct transport *transport, !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..remote, we add the + * ref given in branch..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"); + if (!ref_map) + die("Couldn't find remote ref HEAD"); ref_map->merge = 1; } } + ref_remove_duplicates(ref_map); return ref_map; } @@ -195,8 +210,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 +269,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;