Fix "checkout --track -b newbranch" on detached HEAD
The test to make sure that checkout fails when --track was asked for and we cannot set up tracking information in t7201 was wrong, and it turns out that the implementation for that feature itself was buggy. This fixes it. Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
8ed0a740dd
commit
51a94af845
4
branch.c
4
branch.c
@ -129,7 +129,9 @@ void create_branch(const char *head,
|
|||||||
die("Cannot setup tracking information; starting point is not a branch.");
|
die("Cannot setup tracking information; starting point is not a branch.");
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
/* Unique completion -- good */
|
/* Unique completion -- good, only if it is a real ref */
|
||||||
|
if (track == BRANCH_TRACK_EXPLICIT && !strcmp(real_ref, "HEAD"))
|
||||||
|
die("Cannot setup tracking information; starting point is not a branch.");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
die("Ambiguous object name: '%s'.", start_name);
|
die("Ambiguous object name: '%s'.", start_name);
|
||||||
|
@ -330,12 +330,14 @@ test_expect_success \
|
|||||||
test "$(git config branch.track2.merge)"
|
test "$(git config branch.track2.merge)"
|
||||||
git config branch.autosetupmerge false'
|
git config branch.autosetupmerge false'
|
||||||
|
|
||||||
test_expect_success \
|
test_expect_success 'checkout w/--track from non-branch HEAD fails' '
|
||||||
'checkout w/--track from non-branch HEAD fails' '
|
git checkout master^0 &&
|
||||||
git checkout -b delete-me master &&
|
test_must_fail git symbolic-ref HEAD &&
|
||||||
rm .git/refs/heads/delete-me &&
|
test_must_fail git checkout --track -b track &&
|
||||||
test refs/heads/delete-me = "$(git symbolic-ref HEAD)" &&
|
test_must_fail git rev-parse --verify track &&
|
||||||
test_must_fail git checkout --track -b track'
|
test_must_fail git symbolic-ref HEAD &&
|
||||||
|
test "z$(git rev-parse master^0)" = "z$(git rev-parse HEAD)"
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'checkout an unmerged path should fail' '
|
test_expect_success 'checkout an unmerged path should fail' '
|
||||||
rm -f .git/index &&
|
rm -f .git/index &&
|
||||||
|
Loading…
Reference in New Issue
Block a user