summaryrefslogtreecommitdiff
path: root/builtin-fetch.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-10-21 17:58:21 -0700
committerJunio C Hamano <gitster@pobox.com>2008-10-21 17:58:21 -0700
commitca6c06b2efe2f55c498670efcb419bce35678e03 (patch)
tree741239f028d57d825b8bbd66df8271ad0576bbe0 /builtin-fetch.c
parenta157400c972bbdeab2b5629658c99839c855f5ab (diff)
parentb0ad11ea165e07308fc02a5091efbe2e2d22237c (diff)
downloadgit-ca6c06b2efe2f55c498670efcb419bce35678e03.tar.gz
Merge branch 'js/maint-fetch-update-head'
* 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 Conflicts: t/t5510-fetch.sh
Diffstat (limited to 'builtin-fetch.c')
-rw-r--r--builtin-fetch.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/builtin-fetch.c b/builtin-fetch.c
index e008ee92ab..f151cfa2fd 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)