summaryrefslogtreecommitdiff
path: root/branch.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-03-15 14:22:13 -0700
committerJunio C Hamano <gitster@pobox.com>2011-03-15 14:22:13 -0700
commit663ee1a4c9b9caa4c8f446934410ca636f998df6 (patch)
tree16709d531edb349a53910e3f7dd7c4a306b73cbb /branch.c
parent936dfc220210bc00c7dc094250c9680620dab291 (diff)
parent21b5b1e8dc9bed2b518defe29d69ebc27da4b68f (diff)
downloadgit-663ee1a4c9b9caa4c8f446934410ca636f998df6.tar.gz
Merge branch 'jh/maint-do-not-track-non-branches'
* jh/maint-do-not-track-non-branches: branch/checkout --track: Ensure that upstream branch is indeed a branch
Diffstat (limited to 'branch.c')
-rw-r--r--branch.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/branch.c b/branch.c
index dc23e95435..c0c865a4b1 100644
--- a/branch.c
+++ b/branch.c
@@ -175,9 +175,14 @@ void create_branch(const char *head,
die("Cannot setup tracking information; starting point is not a branch.");
break;
case 1:
- /* Unique completion -- good, only if it is a real ref */
- if (explicit_tracking && !strcmp(real_ref, "HEAD"))
- die("Cannot setup tracking information; starting point is not a branch.");
+ /* Unique completion -- good, only if it is a real branch */
+ if (prefixcmp(real_ref, "refs/heads/") &&
+ prefixcmp(real_ref, "refs/remotes/")) {
+ if (explicit_tracking)
+ die("Cannot setup tracking information; starting point is not a branch.");
+ else
+ real_ref = NULL;
+ }
break;
default:
die("Ambiguous object name: '%s'.", start_name);