]>
Commit | Line | Data |
---|---|---|
b10a5358 JH |
1 | #!/bin/sh |
2 | ||
3 | test_description='fetch/receive strict mode' | |
4 | . ./test-lib.sh | |
5 | ||
8b55b9db | 6 | test_expect_success 'setup and inject "corrupt or missing" object' ' |
b10a5358 JH |
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|^..|&/|") && | |
8b55b9db ÆAB |
13 | echo $S >S && |
14 | echo $X >X && | |
15 | cp .git/objects/$S .git/objects/$S.back && | |
b10a5358 JH |
16 | mv -f .git/objects/$X .git/objects/$S && |
17 | ||
18 | test_must_fail git fsck | |
19 | ' | |
20 | ||
21 | test_expect_success 'fetch without strict' ' | |
22 | rm -rf dst && | |
23 | git init dst && | |
24 | ( | |
25 | cd dst && | |
26 | git config fetch.fsckobjects false && | |
27 | git config transfer.fsckobjects false && | |
2e2e7e9d | 28 | test_must_fail git fetch ../.git master |
b10a5358 JH |
29 | ) |
30 | ' | |
31 | ||
32 | test_expect_success 'fetch with !fetch.fsckobjects' ' | |
33 | rm -rf dst && | |
34 | git init dst && | |
35 | ( | |
36 | cd dst && | |
37 | git config fetch.fsckobjects false && | |
38 | git config transfer.fsckobjects true && | |
2e2e7e9d | 39 | test_must_fail git fetch ../.git master |
b10a5358 JH |
40 | ) |
41 | ' | |
42 | ||
43 | test_expect_success 'fetch with fetch.fsckobjects' ' | |
44 | rm -rf dst && | |
45 | git init dst && | |
46 | ( | |
47 | cd dst && | |
48 | git config fetch.fsckobjects true && | |
49 | git config transfer.fsckobjects false && | |
50 | test_must_fail git fetch ../.git master | |
51 | ) | |
52 | ' | |
53 | ||
54 | test_expect_success 'fetch with transfer.fsckobjects' ' | |
55 | rm -rf dst && | |
56 | git init dst && | |
57 | ( | |
58 | cd dst && | |
59 | git config transfer.fsckobjects true && | |
60 | test_must_fail git fetch ../.git master | |
61 | ) | |
62 | ' | |
63 | ||
ef7e93d9 CB |
64 | cat >exp <<EOF |
65 | To dst | |
66 | ! refs/heads/master:refs/heads/test [remote rejected] (missing necessary objects) | |
67 | EOF | |
68 | ||
b10a5358 JH |
69 | test_expect_success 'push without strict' ' |
70 | rm -rf dst && | |
71 | git init dst && | |
72 | ( | |
73 | cd dst && | |
74 | git config fetch.fsckobjects false && | |
75 | git config transfer.fsckobjects false | |
76 | ) && | |
ef7e93d9 CB |
77 | test_must_fail git push --porcelain dst master:refs/heads/test >act && |
78 | test_cmp exp act | |
b10a5358 JH |
79 | ' |
80 | ||
81 | test_expect_success 'push with !receive.fsckobjects' ' | |
82 | rm -rf dst && | |
83 | git init dst && | |
84 | ( | |
85 | cd dst && | |
86 | git config receive.fsckobjects false && | |
87 | git config transfer.fsckobjects true | |
88 | ) && | |
ef7e93d9 CB |
89 | test_must_fail git push --porcelain dst master:refs/heads/test >act && |
90 | test_cmp exp act | |
b10a5358 JH |
91 | ' |
92 | ||
ef7e93d9 CB |
93 | cat >exp <<EOF |
94 | To dst | |
74eb32d3 | 95 | ! refs/heads/master:refs/heads/test [remote rejected] (unpacker error) |
ef7e93d9 CB |
96 | EOF |
97 | ||
b10a5358 JH |
98 | test_expect_success 'push with receive.fsckobjects' ' |
99 | rm -rf dst && | |
100 | git init dst && | |
101 | ( | |
102 | cd dst && | |
103 | git config receive.fsckobjects true && | |
104 | git config transfer.fsckobjects false | |
105 | ) && | |
c4b27511 JK |
106 | test_must_fail git push --porcelain dst master:refs/heads/test >act && |
107 | test_cmp exp act | |
b10a5358 JH |
108 | ' |
109 | ||
110 | test_expect_success 'push with transfer.fsckobjects' ' | |
111 | rm -rf dst && | |
112 | git init dst && | |
113 | ( | |
114 | cd dst && | |
115 | git config transfer.fsckobjects true | |
116 | ) && | |
c4b27511 JK |
117 | test_must_fail git push --porcelain dst master:refs/heads/test >act && |
118 | test_cmp exp act | |
b10a5358 JH |
119 | ' |
120 | ||
8b55b9db ÆAB |
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 | ||
f9e7d9f8 NTND |
128 | cat >bogus-commit <<EOF |
129 | tree $EMPTY_TREE | |
70a4ae73 JS |
130 | author Bugs Bunny 1234567890 +0000 |
131 | committer Bugs Bunny <bugs@bun.ni> 1234567890 +0000 | |
132 | ||
133 | This commit object intentionally broken | |
134 | EOF | |
135 | ||
134b7327 ÆAB |
136 | test_expect_success 'setup bogus commit' ' |
137 | commit="$(git hash-object -t commit -w --stdin <bogus-commit)" | |
138 | ' | |
139 | ||
65a836fa ÆAB |
140 | test_expect_success 'fsck with invalid or bogus skipList input' ' |
141 | git -c fsck.skipList=/dev/null -c fsck.missingEmail=ignore fsck && | |
142 | test_must_fail git -c fsck.skipList=does-not-exist -c fsck.missingEmail=ignore fsck 2>err && | |
143 | test_i18ngrep "Could not open skip list: does-not-exist" err && | |
144 | test_must_fail git -c fsck.skipList=.git/config -c fsck.missingEmail=ignore fsck 2>err && | |
145 | test_i18ngrep "Invalid SHA-1: \[core\]" err | |
146 | ' | |
147 | ||
cd94c6f9 | 148 | test_expect_success 'push with receive.fsck.skipList' ' |
cd94c6f9 JS |
149 | git push . $commit:refs/heads/bogus && |
150 | rm -rf dst && | |
151 | git init dst && | |
152 | git --git-dir=dst/.git config receive.fsckObjects true && | |
153 | test_must_fail git push --porcelain dst bogus && | |
cd94c6f9 | 154 | echo $commit >dst/.git/SKIP && |
d786da1c ÆAB |
155 | |
156 | # receive.fsck.* does not fall back on fsck.* | |
157 | git --git-dir=dst/.git config fsck.skipList SKIP && | |
158 | test_must_fail git push --porcelain dst bogus && | |
159 | ||
65a836fa ÆAB |
160 | # Invalid and/or bogus skipList input |
161 | git --git-dir=dst/.git config receive.fsck.skipList /dev/null && | |
162 | test_must_fail git push --porcelain dst bogus && | |
163 | git --git-dir=dst/.git config receive.fsck.skipList does-not-exist && | |
164 | test_must_fail git push --porcelain dst bogus 2>err && | |
165 | test_i18ngrep "Could not open skip list: does-not-exist" err && | |
166 | git --git-dir=dst/.git config receive.fsck.skipList config && | |
167 | test_must_fail git push --porcelain dst bogus 2>err && | |
168 | test_i18ngrep "Invalid SHA-1: \[core\]" err && | |
169 | ||
d786da1c | 170 | git --git-dir=dst/.git config receive.fsck.skipList SKIP && |
cd94c6f9 JS |
171 | git push --porcelain dst bogus |
172 | ' | |
173 | ||
1362df0d | 174 | test_expect_success 'fetch with fetch.fsck.skipList' ' |
1362df0d ÆAB |
175 | refspec=refs/heads/bogus:refs/heads/bogus && |
176 | git push . $commit:refs/heads/bogus && | |
177 | rm -rf dst && | |
178 | git init dst && | |
179 | git --git-dir=dst/.git config fetch.fsckObjects true && | |
180 | test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" $refspec && | |
d786da1c ÆAB |
181 | git --git-dir=dst/.git config fetch.fsck.skipList /dev/null && |
182 | test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" $refspec && | |
1362df0d | 183 | echo $commit >dst/.git/SKIP && |
d786da1c ÆAB |
184 | |
185 | # fetch.fsck.* does not fall back on fsck.* | |
186 | git --git-dir=dst/.git config fsck.skipList dst/.git/SKIP && | |
187 | test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" $refspec && | |
188 | ||
65a836fa ÆAB |
189 | # Invalid and/or bogus skipList input |
190 | git --git-dir=dst/.git config fetch.fsck.skipList /dev/null && | |
191 | test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" $refspec && | |
192 | git --git-dir=dst/.git config fetch.fsck.skipList does-not-exist && | |
193 | test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" $refspec 2>err && | |
194 | test_i18ngrep "Could not open skip list: does-not-exist" err && | |
195 | git --git-dir=dst/.git config fetch.fsck.skipList dst/.git/config && | |
196 | test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" $refspec 2>err && | |
197 | test_i18ngrep "Invalid SHA-1: \[core\]" err && | |
198 | ||
d786da1c | 199 | git --git-dir=dst/.git config fetch.fsck.skipList dst/.git/SKIP && |
1362df0d ÆAB |
200 | git --git-dir=dst/.git fetch "file://$(pwd)" $refspec |
201 | ' | |
202 | ||
8a6d0525 ÆAB |
203 | test_expect_success 'fsck.<unknownmsg-id> dies' ' |
204 | test_must_fail git -c fsck.whatEver=ignore fsck 2>err && | |
205 | test_i18ngrep "Unhandled message id: whatever" err | |
206 | ' | |
1362df0d | 207 | |
70a4ae73 | 208 | test_expect_success 'push with receive.fsck.missingEmail=warn' ' |
70a4ae73 JS |
209 | git push . $commit:refs/heads/bogus && |
210 | rm -rf dst && | |
211 | git init dst && | |
212 | git --git-dir=dst/.git config receive.fsckobjects true && | |
213 | test_must_fail git push --porcelain dst bogus && | |
d786da1c ÆAB |
214 | |
215 | # receive.fsck.<msg-id> does not fall back on fsck.<msg-id> | |
216 | git --git-dir=dst/.git config fsck.missingEmail warn && | |
217 | test_must_fail git push --porcelain dst bogus && | |
218 | ||
8a6d0525 ÆAB |
219 | # receive.fsck.<unknownmsg-id> warns |
220 | git --git-dir=dst/.git config \ | |
221 | receive.fsck.whatEver error && | |
222 | ||
70a4ae73 JS |
223 | git --git-dir=dst/.git config \ |
224 | receive.fsck.missingEmail warn && | |
225 | git push --porcelain dst bogus >act 2>&1 && | |
efaba7cc | 226 | grep "missingEmail" act && |
8a6d0525 | 227 | test_i18ngrep "Skipping unknown msg id.*whatever" act && |
efaba7cc JS |
228 | git --git-dir=dst/.git branch -D bogus && |
229 | git --git-dir=dst/.git config --add \ | |
230 | receive.fsck.missingEmail ignore && | |
efaba7cc | 231 | git push --porcelain dst bogus >act 2>&1 && |
c7cf9566 | 232 | ! grep "missingEmail" act |
70a4ae73 JS |
233 | ' |
234 | ||
1362df0d | 235 | test_expect_success 'fetch with fetch.fsck.missingEmail=warn' ' |
1362df0d ÆAB |
236 | refspec=refs/heads/bogus:refs/heads/bogus && |
237 | git push . $commit:refs/heads/bogus && | |
238 | rm -rf dst && | |
239 | git init dst && | |
240 | git --git-dir=dst/.git config fetch.fsckobjects true && | |
241 | test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" $refspec && | |
d786da1c ÆAB |
242 | |
243 | # fetch.fsck.<msg-id> does not fall back on fsck.<msg-id> | |
244 | git --git-dir=dst/.git config fsck.missingEmail warn && | |
245 | test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" $refspec && | |
246 | ||
8a6d0525 ÆAB |
247 | # receive.fsck.<unknownmsg-id> warns |
248 | git --git-dir=dst/.git config \ | |
249 | fetch.fsck.whatEver error && | |
250 | ||
1362df0d ÆAB |
251 | git --git-dir=dst/.git config \ |
252 | fetch.fsck.missingEmail warn && | |
253 | git --git-dir=dst/.git fetch "file://$(pwd)" $refspec >act 2>&1 && | |
254 | grep "missingEmail" act && | |
8a6d0525 | 255 | test_i18ngrep "Skipping unknown msg id.*whatever" act && |
1362df0d ÆAB |
256 | rm -rf dst && |
257 | git init dst && | |
258 | git --git-dir=dst/.git config fetch.fsckobjects true && | |
259 | git --git-dir=dst/.git config \ | |
260 | fetch.fsck.missingEmail ignore && | |
261 | git --git-dir=dst/.git fetch "file://$(pwd)" $refspec >act 2>&1 && | |
262 | ! grep "missingEmail" act | |
263 | ' | |
264 | ||
f50c4407 JS |
265 | test_expect_success \ |
266 | 'receive.fsck.unterminatedHeader=warn triggers error' ' | |
267 | rm -rf dst && | |
268 | git init dst && | |
269 | git --git-dir=dst/.git config receive.fsckobjects true && | |
270 | git --git-dir=dst/.git config \ | |
271 | receive.fsck.unterminatedheader warn && | |
272 | test_must_fail git push --porcelain dst HEAD >act 2>&1 && | |
273 | grep "Cannot demote unterminatedheader" act | |
274 | ' | |
275 | ||
1362df0d ÆAB |
276 | test_expect_success \ |
277 | 'fetch.fsck.unterminatedHeader=warn triggers error' ' | |
278 | rm -rf dst && | |
279 | git init dst && | |
280 | git --git-dir=dst/.git config fetch.fsckobjects true && | |
281 | git --git-dir=dst/.git config \ | |
282 | fetch.fsck.unterminatedheader warn && | |
283 | test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" HEAD && | |
284 | grep "Cannot demote unterminatedheader" act | |
285 | ' | |
286 | ||
b10a5358 | 287 | test_done |