mirror of
https://github.com/git/git.git
synced 2024-12-15 12:53:36 +08:00
31b1de6a09
The commit-graph feature has seen a lot of activity in the past year or so since it was introduced. The feature is a critical performance enhancement for medium- to large-sized repos, and does not significantly hurt small repos. Change the defaults for core.commitGraph and gc.writeCommitGraph to true so users benefit from this feature by default. There are several places in the test suite where the environment variable GIT_TEST_COMMIT_GRAPH is disabled to avoid reading a commit-graph, if it exists. The config option overrides the environment, so swap these. Some GIT_TEST_COMMIT_GRAPH assignments remain, and those are to avoid writing a commit-graph when a new commit is created. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
60 lines
1.4 KiB
Bash
Executable File
60 lines
1.4 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='git rev-list should notice bad commits'
|
|
|
|
. ./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' \
|
|
'
|
|
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 env GIT_TEST_COMMIT_GRAPH=0 git -c core.commitGraph=false 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' \
|
|
'
|
|
git log $first_commit
|
|
'
|
|
|
|
test_done
|
|
|