git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/3] demonstrate breakage of detached checkout with symbolic link HEAD

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 17, 2008, 23:10 UTC
Message-ID
<7vbpxihl87.fsf_-_@gitster.siamese.dyndns.org>
In-Reply-To
<7vfxmuhlad.fsf@gitster.siamese.dyndns.org>

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 <gitster@pobox.com>
---
 t/t7201-co.sh |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/t/t7201-co.sh b/t/t7201-co.sh
index ee2cab6..01304d7 100755
--- a/t/t7201-co.sh
+++ b/t/t7201-co.sh
@@ -339,6 +339,18 @@ test_expect_success 'checkout w/--track from non-branch HEAD fails' '
     test "z$(git rev-parse master^0)" = "z$(git rev-parse HEAD)"
 '
 
+test_expect_failure 'detch a symbolic link HEAD' '
+    git checkout master &&
+    git config --bool core.prefersymlinkrefs yes &&
+    git checkout side &&
+    git checkout master &&
+    it=$(git symbolic-ref HEAD) &&
+    test "z$it" = zrefs/heads/master &&
+    here=$(git rev-parse --verify refs/heads/master) &&
+    git checkout side^ &&
+    test "z$(git rev-parse --verify refs/heads/master)" = "z$here"
+'
+
 test_expect_success 'checkout an unmerged path should fail' '
 	rm -f .git/index &&
 	O=$(echo original | git hash-object -w --stdin) &&
-- 
1.6.0.2.734.gae0be
Previous: Junio C HamanoNext: Junio C Hamano
Message 11 of 15 in “Detached checkout will clobber branch head when using symlink HEAD”
  1. Matt DraiseyOct 15, 2008
  2. Jeff KingOct 16, 2008
  3. Matt DraiseyOct 16, 2008
  4. Nicolas PitreOct 16, 2008
  5. Jeff KingOct 16, 2008
  6. Nicolas PitreOct 16, 2008
  7. Matt DraiseyOct 16, 2008
  8. Nicolas PitreOct 16, 2008
  9. Jeff KingOct 16, 2008
  10. Junio C HamanoOct 17, 2008
  11. 1/3 demonstrate breakage of detached checkout with symbolic link HEADJunio C Hamano, Oct 17, 2008
  12. 2/3 Enhance hold_lock_file_for_{update,append}() APIJunio C Hamano, Oct 17, 2008
  13. 3/3 Fix checkout not to clobber the branch when using symlinked HEAD upon detachingJunio C Hamano, Oct 17, 2008
  14. Jeff KingOct 19, 2008
  15. Junio C HamanoOct 19, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.