]>
Commit | Line | Data |
---|---|---|
ce903018 RA |
1 | #!/bin/sh |
2 | ||
47a528ad | 3 | test_description='git send-email' |
ce903018 RA |
4 | . ./test-lib.sh |
5 | ||
1b19ccd2 JK |
6 | if ! test_have_prereq PERL; then |
7 | say 'skipping git send-email tests, perl not available' | |
8 | test_done | |
9 | fi | |
10 | ||
ce903018 RA |
11 | PROG='git send-email' |
12 | test_expect_success \ | |
13 | 'prepare reference tree' \ | |
14 | 'echo "1A quick brown fox jumps over the" >file && | |
15 | echo "lazy dog" >>file && | |
c0d45281 | 16 | git add file && |
ce903018 RA |
17 | GIT_AUTHOR_NAME="A" git commit -a -m "Initial."' |
18 | ||
19 | test_expect_success \ | |
20 | 'Setup helper tool' \ | |
bb3e4f03 | 21 | '(echo "#!$SHELL_PATH" |
2186d566 | 22 | echo shift |
6d34a2ba JK |
23 | echo output=1 |
24 | echo "while test -f commandline\$output; do output=\$((\$output+1)); done" | |
2186d566 JH |
25 | echo for a |
26 | echo do | |
27 | echo " echo \"!\$a!\"" | |
6d34a2ba JK |
28 | echo "done >commandline\$output" |
29 | echo "cat > msgtxt\$output" | |
c0d45281 JK |
30 | ) >fake.sendmail && |
31 | chmod +x ./fake.sendmail && | |
32 | git add fake.sendmail && | |
ce903018 RA |
33 | GIT_AUTHOR_NAME="A" git commit -a -m "Second."' |
34 | ||
6d34a2ba JK |
35 | clean_fake_sendmail() { |
36 | rm -f commandline* msgtxt* | |
37 | } | |
38 | ||
280242d1 | 39 | test_expect_success 'Extract patches' ' |
3531e270 | 40 | patches=`git format-patch -s --cc="One <one@example.com>" --cc=two@example.com -n HEAD^1` |
280242d1 JH |
41 | ' |
42 | ||
c1f2aa45 JS |
43 | # Test no confirm early to ensure remaining tests will not hang |
44 | test_no_confirm () { | |
45 | rm -f no_confirm_okay | |
46 | echo n | \ | |
47 | GIT_SEND_EMAIL_NOTTY=1 \ | |
48 | git send-email \ | |
49 | --from="Example <from@example.com>" \ | |
50 | --to=nobody@example.com \ | |
51 | --smtp-server="$(pwd)/fake.sendmail" \ | |
52 | $@ \ | |
53 | $patches > stdout && | |
54 | test_must_fail grep "Send this email" stdout && | |
55 | > no_confirm_okay | |
56 | } | |
57 | ||
58 | # Exit immediately to prevent hang if a no-confirm test fails | |
59 | check_no_confirm () { | |
60 | test -f no_confirm_okay || { | |
61 | say 'No confirm test failed; skipping remaining tests to prevent hanging' | |
62 | test_done | |
63 | } | |
64 | } | |
65 | ||
66 | test_expect_success 'No confirm with --suppress-cc' ' | |
67 | test_no_confirm --suppress-cc=sob | |
68 | ' | |
69 | check_no_confirm | |
70 | ||
71 | test_expect_success 'No confirm with --confirm=never' ' | |
72 | test_no_confirm --confirm=never | |
73 | ' | |
74 | check_no_confirm | |
75 | ||
76 | # leave sendemail.confirm set to never after this so that none of the | |
77 | # remaining tests prompt unintentionally. | |
78 | test_expect_success 'No confirm with sendemail.confirm=never' ' | |
79 | git config sendemail.confirm never && | |
80 | test_no_confirm --compose --subject=foo | |
81 | ' | |
82 | check_no_confirm | |
83 | ||
280242d1 | 84 | test_expect_success 'Send patches' ' |
3531e270 | 85 | git send-email --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors |
280242d1 | 86 | ' |
ce903018 | 87 | |
2186d566 JH |
88 | cat >expected <<\EOF |
89 | !nobody@example.com! | |
90 | !author@example.com! | |
5012699d JS |
91 | !one@example.com! |
92 | !two@example.com! | |
2186d566 | 93 | EOF |
ce903018 RA |
94 | test_expect_success \ |
95 | 'Verify commandline' \ | |
188c3827 | 96 | 'test_cmp expected commandline1' |
ce903018 | 97 | |
4f333bc1 JH |
98 | test_expect_success 'Send patches with --envelope-sender' ' |
99 | clean_fake_sendmail && | |
100 | git send-email --envelope-sender="Patch Contributer <patch@example.com>" --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors | |
101 | ' | |
102 | ||
103 | cat >expected <<\EOF | |
104 | !patch@example.com! | |
105 | !-i! | |
106 | !nobody@example.com! | |
107 | !author@example.com! | |
108 | !one@example.com! | |
109 | !two@example.com! | |
110 | EOF | |
111 | test_expect_success \ | |
112 | 'Verify commandline' \ | |
113 | 'test_cmp expected commandline1' | |
114 | ||
b7f30e0a DK |
115 | cat >expected-show-all-headers <<\EOF |
116 | 0001-Second.patch | |
117 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
5012699d JS |
118 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' |
119 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
b7f30e0a DK |
120 | Dry-OK. Log says: |
121 | Server: relay.example.com | |
122 | MAIL FROM:<from@example.com> | |
5012699d | 123 | RCPT TO:<to@example.com>,<cc@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<bcc@example.com> |
b7f30e0a DK |
124 | From: Example <from@example.com> |
125 | To: to@example.com | |
5012699d | 126 | Cc: cc@example.com, A <author@example.com>, One <one@example.com>, two@example.com |
b7f30e0a DK |
127 | Subject: [PATCH 1/1] Second. |
128 | Date: DATE-STRING | |
129 | Message-Id: MESSAGE-ID-STRING | |
130 | X-Mailer: X-MAILER-STRING | |
131 | In-Reply-To: <unique-message-id@example.com> | |
132 | References: <unique-message-id@example.com> | |
133 | ||
134 | Result: OK | |
135 | EOF | |
136 | ||
137 | test_expect_success 'Show all headers' ' | |
138 | git send-email \ | |
139 | --dry-run \ | |
3531e270 | 140 | --suppress-cc=sob \ |
b7f30e0a DK |
141 | --from="Example <from@example.com>" \ |
142 | --to=to@example.com \ | |
143 | --cc=cc@example.com \ | |
144 | --bcc=bcc@example.com \ | |
145 | --in-reply-to="<unique-message-id@example.com>" \ | |
146 | --smtp-server relay.example.com \ | |
147 | $patches | | |
148 | sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \ | |
149 | -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \ | |
150 | -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \ | |
151 | >actual-show-all-headers && | |
82ebb0b6 | 152 | test_cmp expected-show-all-headers actual-show-all-headers |
b7f30e0a DK |
153 | ' |
154 | ||
0da43a68 JS |
155 | test_expect_success 'Prompting works' ' |
156 | clean_fake_sendmail && | |
157 | (echo "Example <from@example.com>" | |
158 | echo "to@example.com" | |
159 | echo "" | |
160 | ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \ | |
161 | --smtp-server="$(pwd)/fake.sendmail" \ | |
162 | $patches \ | |
163 | 2>errors && | |
164 | grep "^From: Example <from@example.com>$" msgtxt1 && | |
165 | grep "^To: to@example.com$" msgtxt1 | |
166 | ' | |
167 | ||
cb8a9bd5 PB |
168 | test_expect_success 'cccmd works' ' |
169 | clean_fake_sendmail && | |
170 | cp $patches cccmd.patch && | |
171 | echo cccmd--cccmd@example.com >>cccmd.patch && | |
977e289e BC |
172 | { |
173 | echo "#!$SHELL_PATH" | |
174 | echo sed -n -e s/^cccmd--//p \"\$1\" | |
175 | } > cccmd-sed && | |
cb8a9bd5 PB |
176 | chmod +x cccmd-sed && |
177 | git send-email \ | |
178 | --from="Example <nobody@example.com>" \ | |
179 | --to=nobody@example.com \ | |
180 | --cc-cmd=./cccmd-sed \ | |
181 | --smtp-server="$(pwd)/fake.sendmail" \ | |
182 | cccmd.patch \ | |
183 | && | |
184 | grep ^Cc:.*cccmd@example.com msgtxt1 | |
185 | ' | |
186 | ||
747bbff9 JK |
187 | z8=zzzzzzzz |
188 | z64=$z8$z8$z8$z8$z8$z8$z8$z8 | |
189 | z512=$z64$z64$z64$z64$z64$z64$z64$z64 | |
190 | test_expect_success 'reject long lines' ' | |
6d34a2ba | 191 | clean_fake_sendmail && |
747bbff9 JK |
192 | cp $patches longline.patch && |
193 | echo $z512$z512 >>longline.patch && | |
d492b31c | 194 | test_must_fail git send-email \ |
747bbff9 JK |
195 | --from="Example <nobody@example.com>" \ |
196 | --to=nobody@example.com \ | |
197 | --smtp-server="$(pwd)/fake.sendmail" \ | |
198 | $patches longline.patch \ | |
199 | 2>errors && | |
200 | grep longline.patch errors | |
201 | ' | |
202 | ||
203 | test_expect_success 'no patch was sent' ' | |
6d34a2ba | 204 | ! test -e commandline1 |
747bbff9 JK |
205 | ' |
206 | ||
5012699d JS |
207 | test_expect_success 'Author From: in message body' ' |
208 | clean_fake_sendmail && | |
209 | git send-email \ | |
210 | --from="Example <nobody@example.com>" \ | |
211 | --to=nobody@example.com \ | |
212 | --smtp-server="$(pwd)/fake.sendmail" \ | |
213 | $patches && | |
214 | sed "1,/^$/d" < msgtxt1 > msgbody1 | |
215 | grep "From: A <author@example.com>" msgbody1 | |
216 | ' | |
217 | ||
218 | test_expect_success 'Author From: not in message body' ' | |
219 | clean_fake_sendmail && | |
220 | git send-email \ | |
221 | --from="A <author@example.com>" \ | |
222 | --to=nobody@example.com \ | |
223 | --smtp-server="$(pwd)/fake.sendmail" \ | |
224 | $patches && | |
225 | sed "1,/^$/d" < msgtxt1 > msgbody1 | |
226 | ! grep "From: A <author@example.com>" msgbody1 | |
227 | ' | |
228 | ||
c764a0c2 JK |
229 | test_expect_success 'allow long lines with --no-validate' ' |
230 | git send-email \ | |
231 | --from="Example <nobody@example.com>" \ | |
232 | --to=nobody@example.com \ | |
233 | --smtp-server="$(pwd)/fake.sendmail" \ | |
3fee1fe8 | 234 | --novalidate \ |
c764a0c2 JK |
235 | $patches longline.patch \ |
236 | 2>errors | |
237 | ' | |
238 | ||
0fb7fc75 | 239 | test_expect_success 'Invalid In-Reply-To' ' |
6d34a2ba | 240 | clean_fake_sendmail && |
0fb7fc75 JS |
241 | git send-email \ |
242 | --from="Example <nobody@example.com>" \ | |
243 | --to=nobody@example.com \ | |
244 | --in-reply-to=" " \ | |
245 | --smtp-server="$(pwd)/fake.sendmail" \ | |
246 | $patches | |
247 | 2>errors | |
6d34a2ba | 248 | ! grep "^In-Reply-To: < *>" msgtxt1 |
0fb7fc75 JS |
249 | ' |
250 | ||
251 | test_expect_success 'Valid In-Reply-To when prompting' ' | |
6d34a2ba | 252 | clean_fake_sendmail && |
0fb7fc75 JS |
253 | (echo "From Example <from@example.com>" |
254 | echo "To Example <to@example.com>" | |
255 | echo "" | |
256 | ) | env GIT_SEND_EMAIL_NOTTY=1 git send-email \ | |
257 | --smtp-server="$(pwd)/fake.sendmail" \ | |
258 | $patches 2>errors && | |
6d34a2ba | 259 | ! grep "^In-Reply-To: < *>" msgtxt1 |
0fb7fc75 JS |
260 | ' |
261 | ||
8a8bf469 | 262 | test_expect_success 'setup fake editor' ' |
bb3e4f03 | 263 | (echo "#!$SHELL_PATH" && |
065096c2 | 264 | echo "echo fake edit >>\"\$1\"" |
8a8bf469 JK |
265 | ) >fake-editor && |
266 | chmod +x fake-editor | |
267 | ' | |
268 | ||
7f0475c3 | 269 | test_set_editor "$(pwd)/fake-editor" |
065096c2 | 270 | |
8a8bf469 JK |
271 | test_expect_success '--compose works' ' |
272 | clean_fake_sendmail && | |
c1f2aa45 JS |
273 | git send-email \ |
274 | --compose --subject foo \ | |
275 | --from="Example <nobody@example.com>" \ | |
276 | --to=nobody@example.com \ | |
277 | --smtp-server="$(pwd)/fake.sendmail" \ | |
278 | $patches \ | |
279 | 2>errors | |
8a8bf469 JK |
280 | ' |
281 | ||
282 | test_expect_success 'first message is compose text' ' | |
283 | grep "^fake edit" msgtxt1 | |
284 | ' | |
285 | ||
286 | test_expect_success 'second message is patch' ' | |
287 | grep "Subject:.*Second" msgtxt2 | |
288 | ' | |
289 | ||
3531e270 | 290 | cat >expected-suppress-sob <<\EOF |
33c592dd MV |
291 | 0001-Second.patch |
292 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
5012699d JS |
293 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' |
294 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
33c592dd MV |
295 | Dry-OK. Log says: |
296 | Server: relay.example.com | |
297 | MAIL FROM:<from@example.com> | |
5012699d | 298 | RCPT TO:<to@example.com>,<cc@example.com>,<author@example.com>,<one@example.com>,<two@example.com> |
33c592dd MV |
299 | From: Example <from@example.com> |
300 | To: to@example.com | |
5012699d | 301 | Cc: cc@example.com, A <author@example.com>, One <one@example.com>, two@example.com |
33c592dd MV |
302 | Subject: [PATCH 1/1] Second. |
303 | Date: DATE-STRING | |
304 | Message-Id: MESSAGE-ID-STRING | |
305 | X-Mailer: X-MAILER-STRING | |
306 | ||
307 | Result: OK | |
308 | EOF | |
309 | ||
3531e270 | 310 | test_suppression () { |
33c592dd MV |
311 | git send-email \ |
312 | --dry-run \ | |
cb8a9bd5 | 313 | --suppress-cc=$1 ${2+"--suppress-cc=$2"} \ |
33c592dd MV |
314 | --from="Example <from@example.com>" \ |
315 | --to=to@example.com \ | |
316 | --smtp-server relay.example.com \ | |
317 | $patches | | |
318 | sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \ | |
319 | -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \ | |
320 | -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \ | |
cb8a9bd5 PB |
321 | >actual-suppress-$1${2+"-$2"} && |
322 | test_cmp expected-suppress-$1${2+"-$2"} actual-suppress-$1${2+"-$2"} | |
3531e270 JS |
323 | } |
324 | ||
325 | test_expect_success 'sendemail.cc set' ' | |
326 | git config sendemail.cc cc@example.com && | |
327 | test_suppression sob | |
33c592dd MV |
328 | ' |
329 | ||
3531e270 | 330 | cat >expected-suppress-sob <<\EOF |
33c592dd MV |
331 | 0001-Second.patch |
332 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
5012699d JS |
333 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' |
334 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
33c592dd MV |
335 | Dry-OK. Log says: |
336 | Server: relay.example.com | |
337 | MAIL FROM:<from@example.com> | |
5012699d | 338 | RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com> |
33c592dd MV |
339 | From: Example <from@example.com> |
340 | To: to@example.com | |
5012699d | 341 | Cc: A <author@example.com>, One <one@example.com>, two@example.com |
33c592dd MV |
342 | Subject: [PATCH 1/1] Second. |
343 | Date: DATE-STRING | |
344 | Message-Id: MESSAGE-ID-STRING | |
345 | X-Mailer: X-MAILER-STRING | |
346 | ||
347 | Result: OK | |
348 | EOF | |
349 | ||
350 | test_expect_success 'sendemail.cc unset' ' | |
351 | git config --unset sendemail.cc && | |
3531e270 JS |
352 | test_suppression sob |
353 | ' | |
354 | ||
cb8a9bd5 PB |
355 | cat >expected-suppress-cccmd <<\EOF |
356 | 0001-Second.patch | |
357 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
358 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' | |
359 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
360 | (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>' | |
361 | Dry-OK. Log says: | |
362 | Server: relay.example.com | |
363 | MAIL FROM:<from@example.com> | |
364 | RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<committer@example.com> | |
365 | From: Example <from@example.com> | |
366 | To: to@example.com | |
367 | Cc: A <author@example.com>, One <one@example.com>, two@example.com, C O Mitter <committer@example.com> | |
368 | Subject: [PATCH 1/1] Second. | |
369 | Date: DATE-STRING | |
370 | Message-Id: MESSAGE-ID-STRING | |
371 | X-Mailer: X-MAILER-STRING | |
372 | ||
373 | Result: OK | |
374 | EOF | |
375 | ||
376 | test_expect_success 'sendemail.cccmd' ' | |
377 | echo echo cc-cmd@example.com > cccmd && | |
378 | chmod +x cccmd && | |
379 | git config sendemail.cccmd ./cccmd && | |
380 | test_suppression cccmd | |
381 | ' | |
382 | ||
3531e270 JS |
383 | cat >expected-suppress-all <<\EOF |
384 | 0001-Second.patch | |
385 | Dry-OK. Log says: | |
386 | Server: relay.example.com | |
387 | MAIL FROM:<from@example.com> | |
388 | RCPT TO:<to@example.com> | |
389 | From: Example <from@example.com> | |
390 | To: to@example.com | |
391 | Subject: [PATCH 1/1] Second. | |
392 | Date: DATE-STRING | |
393 | Message-Id: MESSAGE-ID-STRING | |
394 | X-Mailer: X-MAILER-STRING | |
395 | ||
396 | Result: OK | |
397 | EOF | |
398 | ||
399 | test_expect_success '--suppress-cc=all' ' | |
400 | test_suppression all | |
401 | ' | |
402 | ||
403 | cat >expected-suppress-body <<\EOF | |
404 | 0001-Second.patch | |
405 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
406 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' | |
407 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
cb8a9bd5 | 408 | (cc-cmd) Adding cc: cc-cmd@example.com from: './cccmd' |
3531e270 JS |
409 | Dry-OK. Log says: |
410 | Server: relay.example.com | |
411 | MAIL FROM:<from@example.com> | |
cb8a9bd5 | 412 | RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<cc-cmd@example.com> |
3531e270 JS |
413 | From: Example <from@example.com> |
414 | To: to@example.com | |
cb8a9bd5 | 415 | Cc: A <author@example.com>, One <one@example.com>, two@example.com, cc-cmd@example.com |
3531e270 JS |
416 | Subject: [PATCH 1/1] Second. |
417 | Date: DATE-STRING | |
418 | Message-Id: MESSAGE-ID-STRING | |
419 | X-Mailer: X-MAILER-STRING | |
420 | ||
421 | Result: OK | |
422 | EOF | |
423 | ||
424 | test_expect_success '--suppress-cc=body' ' | |
425 | test_suppression body | |
426 | ' | |
427 | ||
cb8a9bd5 PB |
428 | cat >expected-suppress-body-cccmd <<\EOF |
429 | 0001-Second.patch | |
430 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
431 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' | |
432 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
433 | Dry-OK. Log says: | |
434 | Server: relay.example.com | |
435 | MAIL FROM:<from@example.com> | |
436 | RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com> | |
437 | From: Example <from@example.com> | |
438 | To: to@example.com | |
439 | Cc: A <author@example.com>, One <one@example.com>, two@example.com | |
440 | Subject: [PATCH 1/1] Second. | |
441 | Date: DATE-STRING | |
442 | Message-Id: MESSAGE-ID-STRING | |
443 | X-Mailer: X-MAILER-STRING | |
444 | ||
445 | Result: OK | |
446 | EOF | |
447 | ||
448 | test_expect_success '--suppress-cc=body --suppress-cc=cccmd' ' | |
449 | test_suppression body cccmd | |
450 | ' | |
451 | ||
3531e270 JS |
452 | cat >expected-suppress-sob <<\EOF |
453 | 0001-Second.patch | |
454 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
455 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' | |
456 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
457 | Dry-OK. Log says: | |
458 | Server: relay.example.com | |
459 | MAIL FROM:<from@example.com> | |
460 | RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com> | |
461 | From: Example <from@example.com> | |
462 | To: to@example.com | |
463 | Cc: A <author@example.com>, One <one@example.com>, two@example.com | |
464 | Subject: [PATCH 1/1] Second. | |
465 | Date: DATE-STRING | |
466 | Message-Id: MESSAGE-ID-STRING | |
467 | X-Mailer: X-MAILER-STRING | |
468 | ||
469 | Result: OK | |
470 | EOF | |
471 | ||
472 | test_expect_success '--suppress-cc=sob' ' | |
cb8a9bd5 | 473 | git config --unset sendemail.cccmd |
3531e270 JS |
474 | test_suppression sob |
475 | ' | |
476 | ||
477 | cat >expected-suppress-bodycc <<\EOF | |
478 | 0001-Second.patch | |
479 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
480 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' | |
481 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
482 | (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>' | |
483 | Dry-OK. Log says: | |
484 | Server: relay.example.com | |
485 | MAIL FROM:<from@example.com> | |
486 | RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<committer@example.com> | |
487 | From: Example <from@example.com> | |
488 | To: to@example.com | |
489 | Cc: A <author@example.com>, One <one@example.com>, two@example.com, C O Mitter <committer@example.com> | |
490 | Subject: [PATCH 1/1] Second. | |
491 | Date: DATE-STRING | |
492 | Message-Id: MESSAGE-ID-STRING | |
493 | X-Mailer: X-MAILER-STRING | |
494 | ||
495 | Result: OK | |
496 | EOF | |
497 | ||
498 | test_expect_success '--suppress-cc=bodycc' ' | |
499 | test_suppression bodycc | |
500 | ' | |
501 | ||
502 | cat >expected-suppress-cc <<\EOF | |
503 | 0001-Second.patch | |
504 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
505 | (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>' | |
506 | Dry-OK. Log says: | |
507 | Server: relay.example.com | |
508 | MAIL FROM:<from@example.com> | |
509 | RCPT TO:<to@example.com>,<author@example.com>,<committer@example.com> | |
510 | From: Example <from@example.com> | |
511 | To: to@example.com | |
512 | Cc: A <author@example.com>, C O Mitter <committer@example.com> | |
513 | Subject: [PATCH 1/1] Second. | |
514 | Date: DATE-STRING | |
515 | Message-Id: MESSAGE-ID-STRING | |
516 | X-Mailer: X-MAILER-STRING | |
517 | ||
518 | Result: OK | |
519 | EOF | |
520 | ||
521 | test_expect_success '--suppress-cc=cc' ' | |
522 | test_suppression cc | |
33c592dd MV |
523 | ' |
524 | ||
c1f2aa45 JS |
525 | test_confirm () { |
526 | echo y | \ | |
527 | GIT_SEND_EMAIL_NOTTY=1 \ | |
528 | git send-email \ | |
529 | --from="Example <nobody@example.com>" \ | |
530 | --to=nobody@example.com \ | |
531 | --smtp-server="$(pwd)/fake.sendmail" \ | |
c18f75a1 JS |
532 | $@ $patches > stdout && |
533 | grep "Send this email" stdout | |
c1f2aa45 JS |
534 | } |
535 | ||
536 | test_expect_success '--confirm=always' ' | |
537 | test_confirm --confirm=always --suppress-cc=all | |
538 | ' | |
539 | ||
540 | test_expect_success '--confirm=auto' ' | |
541 | test_confirm --confirm=auto | |
542 | ' | |
543 | ||
544 | test_expect_success '--confirm=cc' ' | |
545 | test_confirm --confirm=cc | |
546 | ' | |
547 | ||
548 | test_expect_success '--confirm=compose' ' | |
549 | test_confirm --confirm=compose --compose | |
550 | ' | |
551 | ||
552 | test_expect_success 'confirm by default (due to cc)' ' | |
553 | CONFIRM=$(git config --get sendemail.confirm) && | |
554 | git config --unset sendemail.confirm && | |
c18f75a1 JS |
555 | test_confirm |
556 | ret="$?" | |
557 | git config sendemail.confirm ${CONFIRM:-never} | |
558 | test $ret = "0" | |
c1f2aa45 JS |
559 | ' |
560 | ||
561 | test_expect_success 'confirm by default (due to --compose)' ' | |
562 | CONFIRM=$(git config --get sendemail.confirm) && | |
563 | git config --unset sendemail.confirm && | |
564 | test_confirm --suppress-cc=all --compose | |
565 | ret="$?" | |
566 | git config sendemail.confirm ${CONFIRM:-never} | |
567 | test $ret = "0" | |
568 | ' | |
569 | ||
c18f75a1 JS |
570 | test_expect_success 'confirm detects EOF (inform assumes y)' ' |
571 | CONFIRM=$(git config --get sendemail.confirm) && | |
572 | git config --unset sendemail.confirm && | |
dc1460aa JS |
573 | rm -fr outdir && |
574 | git format-patch -2 -o outdir && | |
c18f75a1 JS |
575 | GIT_SEND_EMAIL_NOTTY=1 \ |
576 | git send-email \ | |
577 | --from="Example <nobody@example.com>" \ | |
578 | --to=nobody@example.com \ | |
579 | --smtp-server="$(pwd)/fake.sendmail" \ | |
dc1460aa | 580 | outdir/*.patch < /dev/null |
c18f75a1 JS |
581 | ret="$?" |
582 | git config sendemail.confirm ${CONFIRM:-never} | |
583 | test $ret = "0" | |
584 | ' | |
585 | ||
586 | test_expect_success 'confirm detects EOF (auto causes failure)' ' | |
587 | CONFIRM=$(git config --get sendemail.confirm) && | |
588 | git config sendemail.confirm auto && | |
3b3637c3 JS |
589 | GIT_SEND_EMAIL_NOTTY=1 && |
590 | export GIT_SEND_EMAIL_NOTTY && | |
c18f75a1 JS |
591 | test_must_fail git send-email \ |
592 | --from="Example <nobody@example.com>" \ | |
593 | --to=nobody@example.com \ | |
594 | --smtp-server="$(pwd)/fake.sendmail" \ | |
595 | $patches < /dev/null | |
596 | ret="$?" | |
597 | git config sendemail.confirm ${CONFIRM:-never} | |
598 | test $ret = "0" | |
599 | ' | |
600 | ||
601 | test_expect_success 'confirm doesnt loop forever' ' | |
602 | CONFIRM=$(git config --get sendemail.confirm) && | |
603 | git config sendemail.confirm auto && | |
3b3637c3 JS |
604 | GIT_SEND_EMAIL_NOTTY=1 && |
605 | export GIT_SEND_EMAIL_NOTTY && | |
606 | yes "bogus" | test_must_fail git send-email \ | |
c18f75a1 JS |
607 | --from="Example <nobody@example.com>" \ |
608 | --to=nobody@example.com \ | |
609 | --smtp-server="$(pwd)/fake.sendmail" \ | |
610 | $patches | |
611 | ret="$?" | |
612 | git config sendemail.confirm ${CONFIRM:-never} | |
613 | test $ret = "0" | |
614 | ' | |
615 | ||
a61c0ffa JS |
616 | test_expect_success 'utf8 Cc is rfc2047 encoded' ' |
617 | clean_fake_sendmail && | |
618 | rm -fr outdir && | |
619 | git format-patch -1 -o outdir --cc="àéìöú <utf8@example.com>" && | |
620 | git send-email \ | |
621 | --from="Example <nobody@example.com>" \ | |
622 | --to=nobody@example.com \ | |
623 | --smtp-server="$(pwd)/fake.sendmail" \ | |
624 | outdir/*.patch && | |
625 | grep "^Cc:" msgtxt1 | | |
d1fff6fc | 626 | grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>" |
a61c0ffa JS |
627 | ' |
628 | ||
0706bd19 JK |
629 | test_expect_success '--compose adds MIME for utf8 body' ' |
630 | clean_fake_sendmail && | |
bb3e4f03 | 631 | (echo "#!$SHELL_PATH" && |
c01cdde1 | 632 | echo "echo utf8 body: àéìöú >>\"\$1\"" |
0706bd19 JK |
633 | ) >fake-editor-utf8 && |
634 | chmod +x fake-editor-utf8 && | |
c01cdde1 | 635 | GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \ |
0706bd19 JK |
636 | git send-email \ |
637 | --compose --subject foo \ | |
638 | --from="Example <nobody@example.com>" \ | |
639 | --to=nobody@example.com \ | |
640 | --smtp-server="$(pwd)/fake.sendmail" \ | |
641 | $patches && | |
642 | grep "^utf8 body" msgtxt1 && | |
d1fff6fc | 643 | grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1 |
0706bd19 JK |
644 | ' |
645 | ||
646 | test_expect_success '--compose respects user mime type' ' | |
647 | clean_fake_sendmail && | |
bb3e4f03 | 648 | (echo "#!$SHELL_PATH" && |
0706bd19 JK |
649 | echo "(echo MIME-Version: 1.0" |
650 | echo " echo Content-Type: text/plain\\; charset=iso-8859-1" | |
651 | echo " echo Content-Transfer-Encoding: 8bit" | |
652 | echo " echo Subject: foo" | |
653 | echo " echo " | |
c01cdde1 | 654 | echo " echo utf8 body: àéìöú) >\"\$1\"" |
0706bd19 JK |
655 | ) >fake-editor-utf8-mime && |
656 | chmod +x fake-editor-utf8-mime && | |
c01cdde1 | 657 | GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \ |
0706bd19 JK |
658 | git send-email \ |
659 | --compose --subject foo \ | |
660 | --from="Example <nobody@example.com>" \ | |
661 | --to=nobody@example.com \ | |
662 | --smtp-server="$(pwd)/fake.sendmail" \ | |
663 | $patches && | |
664 | grep "^utf8 body" msgtxt1 && | |
665 | grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 && | |
d1fff6fc | 666 | ! grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1 |
0706bd19 JK |
667 | ' |
668 | ||
d54eaaa2 JK |
669 | test_expect_success '--compose adds MIME for utf8 subject' ' |
670 | clean_fake_sendmail && | |
c01cdde1 | 671 | GIT_EDITOR="\"$(pwd)/fake-editor\"" \ |
d54eaaa2 JK |
672 | git send-email \ |
673 | --compose --subject utf8-sübjëct \ | |
674 | --from="Example <nobody@example.com>" \ | |
675 | --to=nobody@example.com \ | |
676 | --smtp-server="$(pwd)/fake.sendmail" \ | |
677 | $patches && | |
678 | grep "^fake edit" msgtxt1 && | |
d1fff6fc | 679 | grep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1 |
d54eaaa2 JK |
680 | ' |
681 | ||
5df9fcf6 PH |
682 | test_expect_success 'detects ambiguous reference/file conflict' ' |
683 | echo master > master && | |
684 | git add master && | |
685 | git commit -m"add master" && | |
686 | test_must_fail git send-email --dry-run master 2>errors && | |
687 | grep disambiguate errors | |
688 | ' | |
689 | ||
69f4ce55 JH |
690 | test_expect_success 'feed two files' ' |
691 | rm -fr outdir && | |
692 | git format-patch -2 -o outdir && | |
c1f2aa45 | 693 | git send-email \ |
69f4ce55 JH |
694 | --dry-run \ |
695 | --from="Example <nobody@example.com>" \ | |
696 | --to=nobody@example.com \ | |
697 | outdir/000?-*.patch 2>errors >out && | |
698 | grep "^Subject: " out >subjects && | |
699 | test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." && | |
700 | test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add master" | |
701 | ' | |
702 | ||
aaab4b9f TR |
703 | test_expect_success 'in-reply-to but no threading' ' |
704 | git send-email \ | |
705 | --dry-run \ | |
706 | --from="Example <nobody@example.com>" \ | |
707 | --to=nobody@example.com \ | |
708 | --in-reply-to="<in-reply-id@example.com>" \ | |
84eeb687 | 709 | --nothread \ |
aaab4b9f TR |
710 | $patches | |
711 | grep "In-Reply-To: <in-reply-id@example.com>" | |
712 | ' | |
713 | ||
5e9758e2 | 714 | test_expect_success 'no in-reply-to and no threading' ' |
32ae8319 MH |
715 | git send-email \ |
716 | --dry-run \ | |
717 | --from="Example <nobody@example.com>" \ | |
718 | --to=nobody@example.com \ | |
719 | --nothread \ | |
720 | $patches $patches >stdout && | |
721 | ! grep "In-Reply-To: " stdout | |
722 | ' | |
723 | ||
f74fe34b | 724 | test_expect_success 'threading but no chain-reply-to' ' |
d67114a5 MH |
725 | git send-email \ |
726 | --dry-run \ | |
727 | --from="Example <nobody@example.com>" \ | |
728 | --to=nobody@example.com \ | |
729 | --thread \ | |
730 | --nochain-reply-to \ | |
731 | $patches $patches >stdout && | |
732 | grep "In-Reply-To: " stdout | |
733 | ' | |
734 | ||
ce903018 | 735 | test_done |