fsck tests: test for garbage appended to a loose object

There wasn't any output tests for this scenario, let's ensure that we don't regress on it in the changes that come after this. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Oct 1, 2021 at 11:16 UTC a5ed333121bde3e170e5497d30391671a9910fb0
1 file changed +20
t/t1450-fsck.sh
+20
@@ -93,6 +93,26 @@ test_expect_success 'object with hash and type mismatch' '
93 )
94 '
95
96 +test_expect_success POSIXPERM 'zlib corrupt loose object output ' '
97 + git init --bare corrupt-loose-output &&
98 + (
99 + cd corrupt-loose-output &&
100 + oid=$(git hash-object -w --stdin --literally </dev/null) &&
101 + oidf=objects/$(test_oid_to_path "$oid") &&
102 + chmod 755 $oidf &&
103 + echo extra garbage >>$oidf &&
104 +
105 + cat >expect.error <<-EOF &&
106 + error: garbage at end of loose object '\''$oid'\''
107 + error: unable to unpack contents of ./$oidf
108 + error: $oid: object corrupt or missing: ./$oidf
109 + EOF
110 + test_must_fail git fsck 2>actual &&
111 + grep ^error: actual >error &&
112 + test_cmp expect.error error
113 + )
114 +'
115 +
116 test_expect_success 'branch pointing to non-commit' '
117 git rev-parse HEAD^{tree} >.git/refs/heads/invalid &&
118 test_when_finished "git update-ref -d refs/heads/invalid" &&