Skip to content

Commit 9c1259a

Browse files
committed
Merge branch 'jt/t1450-fsck-corrupt-packfile'
A test update. * jt/t1450-fsck-corrupt-packfile: tests: ensure fsck fails on corrupt packfiles
2 parents 40dc8d3 + a7c28a2 commit 9c1259a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

t/t1450-fsck.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,22 @@ test_expect_success 'fsck errors in packed objects' '
608608
! grep corrupt out
609609
'
610610

611+
test_expect_success 'fsck fails on corrupt packfile' '
612+
hsh=$(git commit-tree -m mycommit HEAD^{tree}) &&
613+
pack=$(echo $hsh | git pack-objects .git/objects/pack/pack) &&
614+
615+
# Corrupt the first byte of the first object. (It contains 3 type bits,
616+
# at least one of which is not zero, so setting the first byte to 0 is
617+
# sufficient.)
618+
chmod a+w .git/objects/pack/pack-$pack.pack &&
619+
printf '\0' | dd of=.git/objects/pack/pack-$pack.pack bs=1 conv=notrunc seek=12 &&
620+
621+
test_when_finished "rm -f .git/objects/pack/pack-$pack.*" &&
622+
remove_object $hsh &&
623+
test_must_fail git fsck 2>out &&
624+
test_i18ngrep "checksum mismatch" out
625+
'
626+
611627
test_expect_success 'fsck finds problems in duplicate loose objects' '
612628
rm -rf broken-duplicate &&
613629
git init broken-duplicate &&

0 commit comments

Comments
 (0)