]>
Commit | Line | Data |
---|---|---|
ac939109 NP |
1 | #!/bin/sh |
2 | ||
3 | test_description='git rev-list should notice bad commits' | |
4 | ||
90428ddc | 5 | TEST_PASSES_SANITIZE_LEAK=true |
ac939109 NP |
6 | . ./test-lib.sh |
7 | ||
8 | # Note: | |
9 | # - compression level is set to zero to make "corruptions" easier to perform | |
10 | # - reflog is disabled to avoid extra references which would twart the test | |
11 | ||
12 | test_expect_success 'setup' \ | |
13 | ' | |
14 | git init && | |
15 | git config core.compression 0 && | |
16 | git config core.logallrefupdates false && | |
17 | echo "foo" > foo && | |
18 | git add foo && | |
19 | git commit -m "first commit" && | |
20 | echo "bar" > bar && | |
21 | git add bar && | |
22 | git commit -m "second commit" && | |
23 | echo "baz" > baz && | |
24 | git add baz && | |
25 | git commit -m "third commit" && | |
26 | echo "foo again" >> foo && | |
27 | git add foo && | |
28 | git commit -m "fourth commit" && | |
29 | git repack -a -f -d | |
30 | ' | |
31 | ||
32 | test_expect_success 'verify number of revisions' \ | |
33 | ' | |
34 | revs=$(git rev-list --all | wc -l) && | |
35 | test $revs -eq 4 && | |
36 | first_commit=$(git rev-parse HEAD~3) | |
37 | ' | |
38 | ||
39 | test_expect_success 'corrupt second commit object' \ | |
40 | ' | |
94221d22 | 41 | perl -i.bak -pe "s/second commit/socond commit/" .git/objects/pack/*.pack && |
ac939109 NP |
42 | test_must_fail git fsck --full |
43 | ' | |
44 | ||
859fdc0c | 45 | test_expect_success 'rev-list should fail' ' |
31b1de6a | 46 | test_must_fail env GIT_TEST_COMMIT_GRAPH=0 git -c core.commitGraph=false rev-list --all > /dev/null |
859fdc0c | 47 | ' |
ac939109 NP |
48 | |
49 | test_expect_success 'git repack _MUST_ fail' \ | |
50 | ' | |
51 | test_must_fail git repack -a -f -d | |
52 | ' | |
53 | ||
54 | test_expect_success 'first commit is still available' \ | |
55 | ' | |
56 | git log $first_commit | |
57 | ' | |
58 | ||
59 | test_done | |
60 |