summaryrefslogtreecommitdiff
path: root/builtin-fetch.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2007-10-26 23:09:48 -0700
committerJunio C Hamano <gitster@pobox.com>2007-10-28 14:06:39 -0700
commit9ad7c5ae8ae4625bfe32d910b0b480cfea9819e0 (patch)
tree8a838ed84b2cac5f66e0adc5d084d233f90c1ca9 /builtin-fetch.c
parent071a8877662974f588dfc0b1ac7df2764b7e0337 (diff)
downloadgit-9ad7c5ae8ae4625bfe32d910b0b480cfea9819e0.tar.gz
git-fetch: do not fail when remote branch disappears
When the branch named with branch.$name.merge is not covered by the fetch configuration for the remote repository named with branch.$name.remote, we automatically add that branch to the set of branches to be fetched. However, if the remote repository does not have that branch (e.g. it used to exist, but got removed), this is not a reason to fail the git-fetch itself. The situation however will be noticed if git-fetch was called by git-pull, as the resulting FETCH_HEAD would not have any entry that is marked for merging. Acked-By: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-fetch.c')
-rw-r--r--builtin-fetch.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/builtin-fetch.c b/builtin-fetch.c
index b9d2b0c27e..003ed76d16 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;
@@ -110,11 +116,13 @@ static struct ref *get_ref_map(struct transport *transport,
* 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))
+ 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;
}
}