Skip to content

Commit f563754

Browse files
committed
demonstrate breakage of detached checkout with symbolic link HEAD
When core.prefersymlinkrefs is in use, detaching the HEAD by checkout incorrectly clobbers the tip of the current branch. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 51a94af commit f563754

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

t/t7201-co.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,18 @@ test_expect_success 'checkout w/--track from non-branch HEAD fails' '
339339
test "z$(git rev-parse master^0)" = "z$(git rev-parse HEAD)"
340340
'
341341

342+
test_expect_failure 'detach a symbolic link HEAD' '
343+
git checkout master &&
344+
git config --bool core.prefersymlinkrefs yes &&
345+
git checkout side &&
346+
git checkout master &&
347+
it=$(git symbolic-ref HEAD) &&
348+
test "z$it" = zrefs/heads/master &&
349+
here=$(git rev-parse --verify refs/heads/master) &&
350+
git checkout side^ &&
351+
test "z$(git rev-parse --verify refs/heads/master)" = "z$here"
352+
'
353+
342354
test_expect_success 'checkout an unmerged path should fail' '
343355
rm -f .git/index &&
344356
O=$(echo original | git hash-object -w --stdin) &&

0 commit comments

Comments
 (0)