2008-07-15 03:46:48 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='git rev-list should notice bad commits'
|
|
|
|
|
2023-02-07 00:07:42 +01:00
|
|
|
TEST_PASSES_SANITIZE_LEAK=true
|
2008-07-15 03:46:48 +02:00
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
# Note:
|
|
|
|
# - 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 init &&
|
|
|
|
git config core.compression 0 &&
|
|
|
|
git config core.logallrefupdates false &&
|
|
|
|
echo "foo" > foo &&
|
|
|
|
git add foo &&
|
|
|
|
git commit -m "first commit" &&
|
|
|
|
echo "bar" > bar &&
|
|
|
|
git add bar &&
|
|
|
|
git commit -m "second commit" &&
|
|
|
|
echo "baz" > baz &&
|
|
|
|
git add baz &&
|
|
|
|
git commit -m "third commit" &&
|
|
|
|
echo "foo again" >> foo &&
|
|
|
|
git add foo &&
|
|
|
|
git commit -m "fourth commit" &&
|
|
|
|
git repack -a -f -d
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'verify number of revisions' \
|
|
|
|
'
|
|
|
|
revs=$(git rev-list --all | wc -l) &&
|
|
|
|
test $revs -eq 4 &&
|
|
|
|
first_commit=$(git rev-parse HEAD~3)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'corrupt second commit object' \
|
|
|
|
'
|
2013-10-29 02:23:03 +01:00
|
|
|
perl -i.bak -pe "s/second commit/socond commit/" .git/objects/pack/*.pack &&
|
2008-07-15 03:46:48 +02:00
|
|
|
test_must_fail git fsck --full
|
|
|
|
'
|
|
|
|
|
2018-08-29 14:49:04 +02:00
|
|
|
test_expect_success 'rev-list should fail' '
|
2019-08-13 20:37:45 +02:00
|
|
|
test_must_fail env GIT_TEST_COMMIT_GRAPH=0 git -c core.commitGraph=false rev-list --all > /dev/null
|
2018-08-29 14:49:04 +02:00
|
|
|
'
|
2008-07-15 03:46:48 +02:00
|
|
|
|
|
|
|
test_expect_success 'git repack _MUST_ fail' \
|
|
|
|
'
|
|
|
|
test_must_fail git repack -a -f -d
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'first commit is still available' \
|
|
|
|
'
|
|
|
|
git log $first_commit
|
|
|
|
'
|
|
|
|
|
|
|
|
test_done
|
|
|
|
|