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

[PATCH v4 3/4] t1450-fsck: test core.checksumindex

From
Ggit@jeffhostetler.com <git@jeffhostetler.com>
Date
Apr 3, 2017, 18:53 UTC
Message-ID
<20170403185306.36164-4-git@jeffhostetler.com>
In-Reply-To
<20170403185306.36164-1-git@jeffhostetler.com>
From: Jeff Hostetler <jeffhost@microsoft.com>

Add test for fsck to force verify the index checksum. Add test to demonstrate that status does ignore the checksum when reading the index.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
---
 t/t1450-fsck.sh | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh
index 33a51c9..a33d542 100755
--- a/t/t1450-fsck.sh
+++ b/t/t1450-fsck.sh
@@ -689,4 +689,31 @@ test_expect_success 'bogus head does not fallback to all heads' '
 	! grep $blob out
 '
 
+test_expect_success 'validate force_core_checksum_index=1' '
+	git fsck --cache
+'
+
+test_expect_success PERL 'detect index file corrupt in fsck' '
+	cp .git/index .git/index.backup &&
+	echo zzzzzzzz >zzzzzzzz &&
+	git add zzzzzzzz &&
+	perl -pi -e "s/zzzzzzzz/yyyyyyyy/" .git/index &&
+	test_must_fail git fsck --cache &&
+	rm .git/index &&
+	mv .git/index.backup .git/index &&
+	rm zzzzzzzz
+'
+
+test_expect_success PERL 'verify status ignores corrupt checksum' '
+	cp .git/index .git/index.backup &&
+	echo zzzzzzzz >zzzzzzzz &&
+	git add zzzzzzzz &&
+	perl -pi -e "s/zzzzzzzz/yyyyyyyy/" .git/index &&
+	git -c core.checksumindex=0 status &&
+	# Status may fix the checksum
+	rm .git/index &&
+	mv .git/index.backup .git/index &&
+	rm zzzzzzzz
+'
+
 test_done
-- 
2.9.3
Previous: Jeff King
Message 11 of 11 in “read-cache: call verify_hdr() in a background thread”
  1. 0/4 read-cache: call verify_hdr() in a background threadgit@jeffhostetler.com, Apr 3, 2017
  2. 1/4 read-cache: core.checksumindexgit@jeffhostetler.com, Apr 3, 2017
  3. 4/4 p0002-read-cache: test core.checksumindexgit@jeffhostetler.com, Apr 3, 2017
  4. 2/4 fsck: force core.checksumindex=1git@jeffhostetler.com, Apr 3, 2017
  5. Ævar Arnfjörð BjarmasonApr 3, 2017
  6. Jeff KingApr 4, 2017
  7. Ævar Arnfjörð BjarmasonApr 4, 2017
  8. Jeff KingApr 4, 2017
  9. Jeff HostetlerApr 4, 2017
  10. Jeff KingApr 4, 2017
  11. 3/4 t1450-fsck: test core.checksumindexgit@jeffhostetler.com, Apr 3, 2017

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.