mirror of
https://github.com/git/git
synced 2024-10-31 08:44:08 +00:00
859fdc0c3c
The commit-graph feature is tested in isolation by t5318-commit-graph.sh and t6600-test-reach.sh, but there are many more interesting scenarios involving commit walks. Many of these scenarios are covered by the existing test suite, but we need to maintain coverage when the optional commit-graph structure is not present. To allow running the full test suite with the commit-graph present, add a new test environment variable, GIT_TEST_COMMIT_GRAPH. Similar to GIT_TEST_SPLIT_INDEX, this variable makes every Git command try to load the commit-graph when parsing commits, and writes the commit-graph file after every 'git commit' command. There are a few tests that rely on commits not existing in pack-files to trigger important events, so manually set GIT_TEST_COMMIT_GRAPH to false for the necessary commands. There is one test in t6024-recursive-merge.sh that relies on the merge-base algorithm picking one of two ambiguous merge-bases, and the commit-graph feature changes which merge-base is picked. Helped-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
59 lines
1.4 KiB
Bash
Executable file
59 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 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
|
|
|