| test_description='git rev-list should notice bad commits' |
| # - compression level is set to zero to make "corruptions" easier to perform |
| # - reflog is disabled to avoid extra references which would twart the test |
| test_expect_success 'setup' \ |
| git config core.compression 0 && |
| git config core.logallrefupdates false && |
| git commit -m "first commit" && |
| git commit -m "second commit" && |
| git commit -m "third commit" && |
| echo "foo again" >> foo && |
| git commit -m "fourth commit" && |
| test_expect_success 'verify number of revisions' \ |
| revs=$(git rev-list --all | wc -l) && |
| first_commit=$(git rev-parse HEAD~3) |
| test_expect_success 'corrupt second commit object' \ |
| perl -i.bak -pe "s/second commit/socond commit/" .git/objects/pack/*.pack && |
| test_must_fail git fsck --full |
| test_expect_success 'rev-list should fail' \ |
| test_must_fail git rev-list --all > /dev/null |
| test_expect_success 'git repack _MUST_ fail' \ |
| test_must_fail git repack -a -f -d |
| test_expect_success 'first commit is still available' \ |