Skip to content

Commit a5ed333

Browse files
avargitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 42cd635 commit a5ed333

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

t/t1450-fsck.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,26 @@ test_expect_success 'object with hash and type mismatch' '
9393
)
9494
'
9595

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+
96116
test_expect_success 'branch pointing to non-commit' '
97117
git rev-parse HEAD^{tree} >.git/refs/heads/invalid &&
98118
test_when_finished "git update-ref -d refs/heads/invalid" &&

0 commit comments

Comments
 (0)