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

[RFC PATCH 2/3] t1450-fsck: Add tests for HEAD of other worktrees

From
Elijah Newren <newren@gmail.com>
Date
Feb 9, 2018, 23:13 UTC
Message-ID
<20180209231330.4457-3-newren@gmail.com>
In-Reply-To
<20180209231330.4457-1-newren@gmail.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
---
 t/t1450-fsck.sh | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh
index cb4b66e29d..fa94c59458 100755
--- a/t/t1450-fsck.sh
+++ b/t/t1450-fsck.sh
@@ -102,6 +102,33 @@ test_expect_success 'HEAD link pointing at a funny place' '
 	grep "HEAD points to something strange" out
 '
 
+test_expect_failure 'other worktree HEAD link pointing at a funny object' '
+	test_when_finished "rm -rf .git/worktrees" &&
+	mkdir -p .git/worktrees/other &&
+	echo 0000000000000000000000000000000000000000 >.git/worktrees/other/HEAD &&
+	test_must_fail git fsck 2>out &&
+	cat out &&
+	grep "worktrees/other/HEAD: detached HEAD points" out
+'
+
+test_expect_failure 'other worktree HEAD link pointing at missing object' '
+	test_when_finished "rm -rf .git/worktrees" &&
+	mkdir -p .git/worktrees/other &&
+	echo "Contents missing from repo" | git hash-object --stdin >.git/worktrees/other/HEAD &&
+	test_must_fail git fsck 2>out &&
+	cat out &&
+	grep "worktrees/other/HEAD: invalid sha1 pointer" out
+'
+
+test_expect_failure 'other worktree HEAD link pointing at a funny place' '
+	test_when_finished "rm -rf .git/worktrees" &&
+	mkdir -p .git/worktrees/other &&
+	echo "ref: refs/funny/place" >.git/worktrees/other/HEAD &&
+	test_must_fail git fsck 2>out &&
+	cat out &&
+	grep "worktrees/other/HEAD points to something strange" out
+'
+
 test_expect_success 'email without @ is okay' '
 	git cat-file commit HEAD >basis &&
 	sed "s/@/AT/" basis >okay &&
-- 
2.16.1.75.gc01c8fdd7d
Previous: Elijah Newren
Message 7 of 7 in “Make fsck check other worktree HEADs”
  1. 0/3 Make fsck check other worktree HEADsElijah Newren, Feb 9, 2018
  2. 3/3 fsck: Check HEAD of other worktrees as wellElijah Newren, Feb 9, 2018
  3. Duy NguyenFeb 10, 2018
  4. Jeff KingFeb 10, 2018
  5. Junio C HamanoFeb 10, 2018
  6. 1/3 fsck: Move fsck_head_link() to get_default_heads() to avoid some globalsElijah Newren, Feb 9, 2018
  7. 2/3 t1450-fsck: Add tests for HEAD of other worktreesElijah Newren, Feb 9, 2018

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.