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

[PATCH] Add failing test: "fsck survives inflate errors"

From
Samuel Bronson <naesten@gmail.com>
Date
Jul 20, 2014, 04:43 UTC
Message-ID
<1405831383-22477-1-git-send-email-naesten@gmail.com>

While inflate errors are obviously NOT GOOD, and should perhaps be fatal for most commands, git fsck is something of a special case because it is useful to have *it* report as many corrupt objects as possible in one run.

Signed-off-by: Samuel Bronson <naesten@gmail.com>
---
 t/t1450-fsck.sh | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh
index 8c739c9..6dcc4b2 100755
--- a/t/t1450-fsck.sh
+++ b/t/t1450-fsck.sh
@@ -53,6 +53,23 @@ test_expect_success 'setup: helpers for corruption tests' '
 	}
 '
 
+# git fsck should be able to detect more than one corrupt object per run
+test_expect_failure 'fsck survives inflate errors' '
+	hash1=ffffffffffffffffffffffffffffffffffffffff &&
+	hash2=fffffffffffffffffffffffffffffffffffffffe &&
+	mkdir -p .git/objects/ff &&
+	echo not-zlib >$(sha1_file $hash1) &&
+	test_when_finished "remove_object $hash1" &&
+	echo not-zlib >$(sha1_file $hash2) &&
+	test_when_finished "remove_object $hash2" &&
+
+	# Return value is not documented
+	test_might_fail git fsck 2>out &&
+	cat out && echo ====== &&
+	grep "$hash1.*corrupt" out &&
+	grep "$hash2.*corrupt" out
+'
+
 test_expect_success 'object with bad sha1' '
 	sha=$(echo blob | git hash-object -w --stdin) &&
 	old=$(echo $sha | sed "s+^..+&/+") &&
-- 
2.0.1
Next: Samuel Bronson
Message 1 of 5 in “Add failing test: "fsck survives inflate errors"”
  1. Add failing test: "fsck survives inflate errors"Samuel Bronson, Jul 20, 2014
  2. Samuel BronsonJul 20, 2014
  3. [BUG] parse_object() does not behave as documentedSamuel Bronson, Jul 30, 2014
  4. Samuel BronsonAug 9, 2014
  5. Duy NguyenAug 9, 2014

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.