summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c6d059b)
raw | patch | inline | side by side (parent: c6d059b)
author | Thomas Rast <trast@student.ethz.ch> | |
Tue, 14 Dec 2010 18:38:22 +0000 (19:38 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 14 Dec 2010 19:05:09 +0000 (11:05 -0800) |
With branch.autosetupmerge=always, 'HEAD' becomes a valid target for
branch tracking. This is a bit silly, and in fact the code already
guards against it when attempting it explicitly:
$ git checkout HEAD^0
$ git branch -t foo
fatal: Cannot setup tracking information; starting point is not a branch.
Silently drop the HEAD candidate in the implicit (i.e. without -t
flag) case, so that the branch starts out without an upstream.
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
branch tracking. This is a bit silly, and in fact the code already
guards against it when attempting it explicitly:
$ git checkout HEAD^0
$ git branch -t foo
fatal: Cannot setup tracking information; starting point is not a branch.
Silently drop the HEAD candidate in the implicit (i.e. without -t
flag) case, so that the branch starts out without an upstream.
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
branch.c | patch | blob | history | |
t/t3200-branch.sh | patch | blob | history |
diff --git a/branch.c b/branch.c
index 93dc866f8c09a2da2308c4fd677178b043f2d4d5..19310e4e88cf8276b418b7f20c95e1faa97f6020 100644 (file)
--- a/branch.c
+++ b/branch.c
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.");
+ if (!strcmp(real_ref, "HEAD")) {
+ 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);
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index f54a533456d74a3eb2f745dbc77c8ad5a5ae960f..dce90de74d10af16c3df2d90ad4419b5ee6fd7dd 100755 (executable)
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
test "z$(git config branch.myr20.rebase)" = z
'
+test_expect_success 'autosetuprebase always on detached HEAD' '
+ git config branch.autosetupmerge always &&
+ test_when_finished git checkout master &&
+ git checkout HEAD^0 &&
+ git branch my11 &&
+ test -z "$(git config branch.my11.remote)" &&
+ test -z "$(git config branch.my11.merge)"
+'
+
test_expect_success 'detect misconfigured autosetuprebase (bad value)' '
git config branch.autosetuprebase garbage &&
test_must_fail git branch