mirror of
https://github.com/git/git.git
synced 2024-11-01 06:47:52 +01:00
8bf4becf0c
t5516 "75 - deny fetch unreachable SHA1, allowtipsha1inwant=true" is flaky in the following case: 1. remote upload-pack finds out "not our ref" 2. remote sends a response and closes the pipe 3. fetch-pack still tries to write commands to the remote upload-pack 4. write call in wrapper.c dies with SIGPIPE The test is flaky because the sending fetch-pack may or may not have finished writing its output by step (3). If it did, then we see a closed pipe on the next read() call. If it didn't, then we get the SIGPIPE from step (4) above. Both are fine, but the latter fools test_must_fail. t5504 "9 - push with transfer.fsckobjects" is flaky, too, and returns SIGPIPE once in a while. I had to remove the final "To dst..." output check because there is no output if the process dies with SIGPIPE. Accept such a death-with-sigpipe also as OK when we are expecting a failure. Signed-off-by: Lars Schneider <larsxschneider@gmail.com> Signed-off-by: Jeff King <peff@peff.net>
168 lines
4.2 KiB
Bash
Executable file
168 lines
4.2 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
test_description='fetch/receive strict mode'
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success setup '
|
|
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|^..|&/|") &&
|
|
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 <<EOF
|
|
To dst
|
|
! refs/heads/master:refs/heads/test [remote rejected] (missing necessary objects)
|
|
EOF
|
|
|
|
test_expect_success 'push without strict' '
|
|
rm -rf dst &&
|
|
git init dst &&
|
|
(
|
|
cd dst &&
|
|
git config fetch.fsckobjects false &&
|
|
git config transfer.fsckobjects false
|
|
) &&
|
|
test_must_fail git push --porcelain dst master:refs/heads/test >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 <<EOF
|
|
To dst
|
|
! refs/heads/master:refs/heads/test [remote rejected] (unpacker error)
|
|
EOF
|
|
|
|
test_expect_success 'push with receive.fsckobjects' '
|
|
rm -rf dst &&
|
|
git init dst &&
|
|
(
|
|
cd dst &&
|
|
git config receive.fsckobjects true &&
|
|
git config transfer.fsckobjects false
|
|
) &&
|
|
test_must_fail ok=sigpipe git push --porcelain dst master:refs/heads/test >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 ok=sigpipe git push --porcelain dst master:refs/heads/test >act
|
|
'
|
|
|
|
cat >bogus-commit <<\EOF
|
|
tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
|
|
author Bugs Bunny 1234567890 +0000
|
|
committer Bugs Bunny <bugs@bun.ni> 1234567890 +0000
|
|
|
|
This commit object intentionally broken
|
|
EOF
|
|
|
|
test_expect_success 'push with receive.fsck.skipList' '
|
|
commit="$(git hash-object -t commit -w --stdin <bogus-commit)" &&
|
|
git push . $commit:refs/heads/bogus &&
|
|
rm -rf dst &&
|
|
git init dst &&
|
|
git --git-dir=dst/.git config receive.fsckObjects true &&
|
|
test_must_fail git push --porcelain dst bogus &&
|
|
git --git-dir=dst/.git config receive.fsck.skipList SKIP &&
|
|
echo $commit >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 <bogus-commit)" &&
|
|
git push . $commit:refs/heads/bogus &&
|
|
rm -rf dst &&
|
|
git init dst &&
|
|
git --git-dir=dst/.git config receive.fsckobjects true &&
|
|
test_must_fail git push --porcelain dst bogus &&
|
|
git --git-dir=dst/.git config \
|
|
receive.fsck.missingEmail warn &&
|
|
git push --porcelain dst bogus >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 --git-dir=dst/.git config --add \
|
|
receive.fsck.badDate warn &&
|
|
git push --porcelain dst bogus >act 2>&1 &&
|
|
test_must_fail 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
|