#!/bin/sh test_description='fetch/receive strict mode' . ./test-lib.sh test_expect_success 'setup and inject "corrupt or missing" object' ' echo hello >greetings && git add greetings && git commit -m greetings && S=$(git rev-parse :greetings | sed -e "s|^..|&/|") && X=$(echo bye | git hash-object -w --stdin | sed -e "s|^..|&/|") && echo $S >S && echo $X >X && cp .git/objects/$S .git/objects/$S.back && mv -f .git/objects/$X .git/objects/$S && test_must_fail git fsck ' test_expect_success 'fetch without strict' ' rm -rf dst && git init dst && ( cd dst && git config fetch.fsckobjects false && git config transfer.fsckobjects false && test_must_fail git fetch ../.git master ) ' test_expect_success 'fetch with !fetch.fsckobjects' ' rm -rf dst && git init dst && ( cd dst && git config fetch.fsckobjects false && git config transfer.fsckobjects true && test_must_fail git fetch ../.git master ) ' test_expect_success 'fetch with fetch.fsckobjects' ' rm -rf dst && git init dst && ( cd dst && git config fetch.fsckobjects true && git config transfer.fsckobjects false && test_must_fail git fetch ../.git master ) ' test_expect_success 'fetch with transfer.fsckobjects' ' rm -rf dst && git init dst && ( cd dst && git config transfer.fsckobjects true && test_must_fail git fetch ../.git master ) ' cat >exp <act && test_cmp exp act ' test_expect_success 'push with !receive.fsckobjects' ' rm -rf dst && git init dst && ( cd dst && git config receive.fsckobjects false && git config transfer.fsckobjects true ) && test_must_fail git push --porcelain dst master:refs/heads/test >act && test_cmp exp act ' cat >exp <act && test_cmp exp act ' test_expect_success 'push with transfer.fsckobjects' ' rm -rf dst && git init dst && ( cd dst && git config transfer.fsckobjects true ) && test_must_fail git push --porcelain dst master:refs/heads/test >act && test_cmp exp act ' test_expect_success 'repair the "corrupt or missing" object' ' mv -f .git/objects/$(cat S) .git/objects/$(cat X) && mv .git/objects/$(cat S).back .git/objects/$(cat S) && rm -rf .git/objects/$(cat X) && git fsck ' cat >bogus-commit < 1234567890 +0000 This commit object intentionally broken EOF test_expect_success 'push with receive.fsck.skipList' ' commit="$(git hash-object -t commit -w --stdin dst/.git/SKIP && git push --porcelain dst bogus ' test_expect_success 'push with receive.fsck.missingEmail=warn' ' commit="$(git hash-object -t commit -w --stdin act 2>&1 && grep "missingEmail" act && git --git-dir=dst/.git branch -D bogus && git --git-dir=dst/.git config --add \ receive.fsck.missingEmail ignore && git push --porcelain dst bogus >act 2>&1 && ! grep "missingEmail" act ' test_expect_success \ 'receive.fsck.unterminatedHeader=warn triggers error' ' rm -rf dst && git init dst && git --git-dir=dst/.git config receive.fsckobjects true && git --git-dir=dst/.git config \ receive.fsck.unterminatedheader warn && test_must_fail git push --porcelain dst HEAD >act 2>&1 && grep "Cannot demote unterminatedheader" act ' test_done