3 test_description
='fetch/receive strict mode'
6 test_expect_success setup
'
7 echo hello >greetings &&
9 git commit -m greetings &&
11 S=$(git rev-parse :greetings | sed -e "s|^..|&/|") &&
12 X=$(echo bye | git hash-object -w --stdin | sed -e "s|^..|&/|") &&
13 mv -f .git/objects/$X .git/objects/$S &&
15 test_must_fail git fsck
18 test_expect_success
'fetch without strict' '
23 git config fetch.fsckobjects false &&
24 git config transfer.fsckobjects false &&
25 test_must_fail git fetch ../.git master
29 test_expect_success
'fetch with !fetch.fsckobjects' '
34 git config fetch.fsckobjects false &&
35 git config transfer.fsckobjects true &&
36 test_must_fail git fetch ../.git master
40 test_expect_success
'fetch with fetch.fsckobjects' '
45 git config fetch.fsckobjects true &&
46 git config transfer.fsckobjects false &&
47 test_must_fail git fetch ../.git master
51 test_expect_success
'fetch with transfer.fsckobjects' '
56 git config transfer.fsckobjects true &&
57 test_must_fail git fetch ../.git master
63 ! refs/heads/master:refs/heads/test [remote rejected] (missing necessary objects)
66 test_expect_success
'push without strict' '
71 git config fetch.fsckobjects false &&
72 git config transfer.fsckobjects false
74 test_must_fail git push --porcelain dst master:refs/heads/test >act &&
78 test_expect_success
'push with !receive.fsckobjects' '
83 git config receive.fsckobjects false &&
84 git config transfer.fsckobjects true
86 test_must_fail git push --porcelain dst master:refs/heads/test >act &&
92 ! refs/heads/master:refs/heads/test [remote rejected] (unpacker error)
95 test_expect_success
'push with receive.fsckobjects' '
100 git config receive.fsckobjects true &&
101 git config transfer.fsckobjects false
103 test_must_fail ok=sigpipe git push --porcelain dst master:refs/heads/test >act &&
107 test_expect_success
'push with transfer.fsckobjects' '
112 git config transfer.fsckobjects true
114 test_must_fail ok=sigpipe git push --porcelain dst master:refs/heads/test >act
117 cat >bogus-commit
<<\EOF
118 tree
4b825dc642cb6eb9a060e54bf8d69288fbee4904
119 author Bugs Bunny
1234567890 +0000
120 committer Bugs Bunny
<bugs@bun.ni
> 1234567890 +0000
122 This commit object intentionally broken
125 test_expect_success
'push with receive.fsck.skipList' '
126 commit="$(git hash-object -t commit -w --stdin <bogus-commit)" &&
127 git push . $commit:refs/heads/bogus &&
130 git --git-dir=dst/.git config receive.fsckObjects true &&
131 test_must_fail git push --porcelain dst bogus &&
132 git --git-dir=dst/.git config receive.fsck.skipList SKIP &&
133 echo $commit >dst/.git/SKIP &&
134 git push --porcelain dst bogus
137 test_expect_success
'push with receive.fsck.missingEmail=warn' '
138 commit="$(git hash-object -t commit -w --stdin <bogus-commit)" &&
139 git push . $commit:refs/heads/bogus &&
142 git --git-dir=dst/.git config receive.fsckobjects true &&
143 test_must_fail git push --porcelain dst bogus &&
144 git --git-dir=dst/.git config \
145 receive.fsck.missingEmail warn &&
146 git push --porcelain dst bogus >act 2>&1 &&
147 grep "missingEmail" act &&
148 git --git-dir=dst/.git branch -D bogus &&
149 git --git-dir=dst/.git config --add \
150 receive.fsck.missingEmail ignore &&
151 git --git-dir=dst/.git config --add \
152 receive.fsck.badDate warn &&
153 git push --porcelain dst bogus >act 2>&1 &&
154 test_must_fail grep "missingEmail" act
157 test_expect_success \
158 'receive.fsck.unterminatedHeader=warn triggers error' '
161 git --git-dir=dst/.git config receive.fsckobjects true &&
162 git --git-dir=dst/.git config \
163 receive.fsck.unterminatedheader warn &&
164 test_must_fail git push --porcelain dst HEAD >act 2>&1 &&
165 grep "Cannot demote unterminatedheader" act