transfer.fsckObjects tests: untangle confusing setup

The tests for transfer.fsckObjects have grown organically over time to not make much sense. Initially when these were added in b10a53583f ("test: fetch/receive with fsckobjects", 2011-09-04) they were only testing the "corrupt or missing object" case, but later on in 70a4ae73d8 ("fsck: add a simple test for receive.fsck.<msg-id>", 2015-06-22) they were expanded to check for the fsck.<msg-id> feature. The problem was that we still kept the same corrupt test repo, making it harder to add new tests that check the entirety of the repository between operations via "git fsck" to see whether only known issues that can be ignored with fsck.<msg-id> have occurred. The tests only did the right thing because such a full "git fsck" was never done after a certain point, and instead we were only manipulating specific refs. This makes it harder to add new tests, and none of the fsck.<msg-id> tests relied on this. So let's not confuse the two and repair the corrupt repository before we run the fsck.<msg-id> tests. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Jul 27, 2018 at 14:37 UTC 8b55b9db23962c5623f724d9ec857226dab9631a
1 file changed +11 -1
t/t5504-fetch-receive-strict.sh
+11 -1
@@ -3,13 +3,16 @@
3 test_description='fetch/receive strict mode'
4 . ./test-lib.sh
5
6 -test_expect_success setup '
6 +test_expect_success 'setup and inject "corrupt or missing" object' '
7 echo hello >greetings &&
8 git add greetings &&
9 git commit -m greetings &&
10
11 S=$(git rev-parse :greetings | sed -e "s|^..|&/|") &&
12 X=$(echo bye | git hash-object -w --stdin | sed -e "s|^..|&/|") &&
13 + echo $S >S &&
14 + echo $X >X &&
15 + cp .git/objects/$S .git/objects/$S.back &&
16 mv -f .git/objects/$X .git/objects/$S &&
17
18 test_must_fail git fsck
@@ -115,6 +118,13 @@ test_expect_success 'push with transfer.fsckobjects' '
118 test_cmp exp act
119 '
120
121 +test_expect_success 'repair the "corrupt or missing" object' '
122 + mv -f .git/objects/$(cat S) .git/objects/$(cat X) &&
123 + mv .git/objects/$(cat S).back .git/objects/$(cat S) &&
124 + rm -rf .git/objects/$(cat X) &&
125 + git fsck
126 +'
127 +
128 cat >bogus-commit <<EOF
129 tree $EMPTY_TREE
130 author Bugs Bunny 1234567890 +0000