diff options
author | Junio C Hamano <gitster@pobox.com> | 2007-10-26 23:09:48 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-10-28 14:06:39 -0700 |
commit | 9ad7c5ae8ae4625bfe32d910b0b480cfea9819e0 (patch) | |
tree | 8a838ed84b2cac5f66e0adc5d084d233f90c1ca9 /remote.c | |
parent | 071a8877662974f588dfc0b1ac7df2764b7e0337 (diff) | |
download | git-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 'remote.c')
-rw-r--r-- | remote.c | 22 |
1 files changed, 13 insertions, 9 deletions
@@ -857,7 +857,7 @@ struct ref *get_remote_ref(struct ref *remote_refs, const char *name) struct ref *ref = find_ref_by_name_abbrev(remote_refs, name); if (!ref) - die("Couldn't find remote ref %s\n", name); + return NULL; return copy_ref(ref); } @@ -889,20 +889,24 @@ static struct ref *get_local_ref(const char *name) int get_fetch_map(struct ref *remote_refs, const struct refspec *refspec, - struct ref ***tail) + struct ref ***tail, + int missing_ok) { struct ref *ref_map, *rm; if (refspec->pattern) { ref_map = get_expanded_map(remote_refs, refspec); } else { - ref_map = get_remote_ref(remote_refs, - refspec->src[0] ? - refspec->src : "HEAD"); - - ref_map->peer_ref = get_local_ref(refspec->dst); - if (ref_map->peer_ref && refspec->force) - ref_map->peer_ref->force = 1; + const char *name = refspec->src[0] ? refspec->src : "HEAD"; + + ref_map = get_remote_ref(remote_refs, name); + if (!missing_ok && !ref_map) + die("Couldn't find remote ref %s", name); + if (ref_map) { + ref_map->peer_ref = get_local_ref(refspec->dst); + if (ref_map->peer_ref && refspec->force) + ref_map->peer_ref->force = 1; + } } for (rm = ref_map; rm; rm = rm->next) { |