diff options
author | Junio C Hamano <gitster@pobox.com> | 2008-11-02 13:37:16 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-11-02 13:37:16 -0800 |
commit | f6276b788f26c3c148c2d5465a6b03fc09bb785c (patch) | |
tree | 51087b88150e40113d3c90f3822f0e0c9e5a4caa /builtin-fetch.c | |
parent | 86e67a088c581da4da36acf0edd8c27b1033e51e (diff) | |
parent | b0ad11ea165e07308fc02a5091efbe2e2d22237c (diff) | |
download | git-f6276b788f26c3c148c2d5465a6b03fc09bb785c.tar.gz git-f6276b788f26c3c148c2d5465a6b03fc09bb785c.tar.xz |
Merge branch 'js/maint-fetch-update-head' into maint
* js/maint-fetch-update-head:
pull: allow "git pull origin $something:$current_branch" into an unborn branch
Fix fetch/pull when run without --update-head-ok
Diffstat (limited to 'builtin-fetch.c')
-rw-r--r-- | builtin-fetch.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/builtin-fetch.c b/builtin-fetch.c index ee93d3a93..57c161d35 100644 --- a/builtin-fetch.c +++ b/builtin-fetch.c @@ -534,6 +534,19 @@ static void find_non_local_tags(struct transport *transport, string_list_clear(&new_refs, 0); } +static void check_not_current_branch(struct ref *ref_map) +{ + struct branch *current_branch = branch_get(NULL); + + if (is_bare_repository() || !current_branch) + return; + + for (; ref_map; ref_map = ref_map->next) + if (ref_map->peer_ref && !strcmp(current_branch->refname, + ref_map->peer_ref->name)) + die("Refusing to fetch into current branch"); +} + static int do_fetch(struct transport *transport, struct refspec *refs, int ref_count) { @@ -558,6 +571,8 @@ static int do_fetch(struct transport *transport, } ref_map = get_ref_map(transport, refs, ref_count, tags, &autotags); + if (!update_head_ok) + check_not_current_branch(ref_map); for (rm = ref_map; rm; rm = rm->next) { if (rm->peer_ref) |