]>
Commit | Line | Data |
---|---|---|
ce903018 RA |
1 | #!/bin/sh |
2 | ||
47a528ad | 3 | test_description='git send-email' |
ce903018 RA |
4 | . ./test-lib.sh |
5 | ||
57cd35e6 ÆAB |
6 | # May be altered later in the test |
7 | PREREQ="PERL" | |
1b19ccd2 | 8 | |
57cd35e6 | 9 | test_expect_success $PREREQ \ |
ce903018 RA |
10 | 'prepare reference tree' \ |
11 | 'echo "1A quick brown fox jumps over the" >file && | |
12 | echo "lazy dog" >>file && | |
c0d45281 | 13 | git add file && |
ce903018 RA |
14 | GIT_AUTHOR_NAME="A" git commit -a -m "Initial."' |
15 | ||
57cd35e6 | 16 | test_expect_success $PREREQ \ |
ce903018 | 17 | 'Setup helper tool' \ |
bb3e4f03 | 18 | '(echo "#!$SHELL_PATH" |
2186d566 | 19 | echo shift |
6d34a2ba JK |
20 | echo output=1 |
21 | echo "while test -f commandline\$output; do output=\$((\$output+1)); done" | |
2186d566 JH |
22 | echo for a |
23 | echo do | |
24 | echo " echo \"!\$a!\"" | |
6d34a2ba | 25 | echo "done >commandline\$output" |
72b5158b | 26 | test_have_prereq MINGW && echo "dos2unix commandline\$output" |
6d34a2ba | 27 | echo "cat > msgtxt\$output" |
c0d45281 JK |
28 | ) >fake.sendmail && |
29 | chmod +x ./fake.sendmail && | |
30 | git add fake.sendmail && | |
ce903018 RA |
31 | GIT_AUTHOR_NAME="A" git commit -a -m "Second."' |
32 | ||
6d34a2ba JK |
33 | clean_fake_sendmail() { |
34 | rm -f commandline* msgtxt* | |
35 | } | |
36 | ||
57cd35e6 | 37 | test_expect_success $PREREQ 'Extract patches' ' |
3531e270 | 38 | patches=`git format-patch -s --cc="One <one@example.com>" --cc=two@example.com -n HEAD^1` |
280242d1 JH |
39 | ' |
40 | ||
c1f2aa45 JS |
41 | # Test no confirm early to ensure remaining tests will not hang |
42 | test_no_confirm () { | |
43 | rm -f no_confirm_okay | |
44 | echo n | \ | |
45 | GIT_SEND_EMAIL_NOTTY=1 \ | |
46 | git send-email \ | |
47 | --from="Example <from@example.com>" \ | |
48 | --to=nobody@example.com \ | |
49 | --smtp-server="$(pwd)/fake.sendmail" \ | |
50 | $@ \ | |
51 | $patches > stdout && | |
52 | test_must_fail grep "Send this email" stdout && | |
53 | > no_confirm_okay | |
54 | } | |
55 | ||
56 | # Exit immediately to prevent hang if a no-confirm test fails | |
57 | check_no_confirm () { | |
57cd35e6 ÆAB |
58 | if ! test -f no_confirm_okay |
59 | then | |
60 | say 'confirm test failed; skipping remaining tests to prevent hanging' | |
61 | PREREQ="$PREREQ,CHECK_NO_CONFIRM" | |
62 | fi | |
63 | return 0 | |
c1f2aa45 JS |
64 | } |
65 | ||
57cd35e6 ÆAB |
66 | test_expect_success $PREREQ 'No confirm with --suppress-cc' ' |
67 | test_no_confirm --suppress-cc=sob && | |
68 | check_no_confirm | |
c1f2aa45 | 69 | ' |
c1f2aa45 | 70 | |
57cd35e6 ÆAB |
71 | |
72 | test_expect_success $PREREQ 'No confirm with --confirm=never' ' | |
73 | test_no_confirm --confirm=never && | |
74 | check_no_confirm | |
c1f2aa45 | 75 | ' |
c1f2aa45 JS |
76 | |
77 | # leave sendemail.confirm set to never after this so that none of the | |
78 | # remaining tests prompt unintentionally. | |
57cd35e6 | 79 | test_expect_success $PREREQ 'No confirm with sendemail.confirm=never' ' |
c1f2aa45 | 80 | git config sendemail.confirm never && |
57cd35e6 ÆAB |
81 | test_no_confirm --compose --subject=foo && |
82 | check_no_confirm | |
c1f2aa45 | 83 | ' |
c1f2aa45 | 84 | |
57cd35e6 | 85 | test_expect_success $PREREQ 'Send patches' ' |
3531e270 | 86 | git send-email --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors |
280242d1 | 87 | ' |
ce903018 | 88 | |
f9444147 | 89 | test_expect_success $PREREQ 'setup expect' ' |
2186d566 JH |
90 | cat >expected <<\EOF |
91 | !nobody@example.com! | |
92 | !author@example.com! | |
5012699d JS |
93 | !one@example.com! |
94 | !two@example.com! | |
2186d566 | 95 | EOF |
f9444147 ÆAB |
96 | ' |
97 | ||
57cd35e6 | 98 | test_expect_success $PREREQ \ |
ce903018 | 99 | 'Verify commandline' \ |
188c3827 | 100 | 'test_cmp expected commandline1' |
ce903018 | 101 | |
57cd35e6 | 102 | test_expect_success $PREREQ 'Send patches with --envelope-sender' ' |
4f333bc1 JH |
103 | clean_fake_sendmail && |
104 | 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 | |
105 | ' | |
106 | ||
f9444147 | 107 | test_expect_success $PREREQ 'setup expect' ' |
4f333bc1 JH |
108 | cat >expected <<\EOF |
109 | !patch@example.com! | |
110 | !-i! | |
111 | !nobody@example.com! | |
112 | !author@example.com! | |
113 | !one@example.com! | |
114 | !two@example.com! | |
115 | EOF | |
f9444147 ÆAB |
116 | ' |
117 | ||
57cd35e6 | 118 | test_expect_success $PREREQ \ |
4f333bc1 JH |
119 | 'Verify commandline' \ |
120 | 'test_cmp expected commandline1' | |
121 | ||
57cd35e6 | 122 | test_expect_success $PREREQ 'Send patches with --envelope-sender=auto' ' |
c89e3241 FC |
123 | clean_fake_sendmail && |
124 | git send-email --envelope-sender=auto --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors | |
125 | ' | |
126 | ||
f9444147 | 127 | test_expect_success $PREREQ 'setup expect' ' |
c89e3241 FC |
128 | cat >expected <<\EOF |
129 | !nobody@example.com! | |
130 | !-i! | |
131 | !nobody@example.com! | |
132 | !author@example.com! | |
133 | !one@example.com! | |
134 | !two@example.com! | |
135 | EOF | |
f9444147 ÆAB |
136 | ' |
137 | ||
57cd35e6 | 138 | test_expect_success $PREREQ \ |
c89e3241 FC |
139 | 'Verify commandline' \ |
140 | 'test_cmp expected commandline1' | |
141 | ||
f9444147 | 142 | test_expect_success $PREREQ 'setup expect' " |
b7f30e0a DK |
143 | cat >expected-show-all-headers <<\EOF |
144 | 0001-Second.patch | |
145 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
5012699d JS |
146 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' |
147 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
b7f30e0a DK |
148 | Dry-OK. Log says: |
149 | Server: relay.example.com | |
150 | MAIL FROM:<from@example.com> | |
02461e0e JP |
151 | RCPT TO:<to@example.com> |
152 | RCPT TO:<cc@example.com> | |
153 | RCPT TO:<author@example.com> | |
154 | RCPT TO:<one@example.com> | |
155 | RCPT TO:<two@example.com> | |
156 | RCPT TO:<bcc@example.com> | |
b7f30e0a DK |
157 | From: Example <from@example.com> |
158 | To: to@example.com | |
02461e0e JP |
159 | Cc: cc@example.com, |
160 | A <author@example.com>, | |
161 | One <one@example.com>, | |
162 | two@example.com | |
b7f30e0a DK |
163 | Subject: [PATCH 1/1] Second. |
164 | Date: DATE-STRING | |
165 | Message-Id: MESSAGE-ID-STRING | |
166 | X-Mailer: X-MAILER-STRING | |
167 | In-Reply-To: <unique-message-id@example.com> | |
168 | References: <unique-message-id@example.com> | |
169 | ||
170 | Result: OK | |
171 | EOF | |
f9444147 | 172 | " |
b7f30e0a | 173 | |
57cd35e6 | 174 | test_expect_success $PREREQ 'Show all headers' ' |
b7f30e0a DK |
175 | git send-email \ |
176 | --dry-run \ | |
3531e270 | 177 | --suppress-cc=sob \ |
b7f30e0a DK |
178 | --from="Example <from@example.com>" \ |
179 | --to=to@example.com \ | |
180 | --cc=cc@example.com \ | |
181 | --bcc=bcc@example.com \ | |
182 | --in-reply-to="<unique-message-id@example.com>" \ | |
183 | --smtp-server relay.example.com \ | |
184 | $patches | | |
185 | sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \ | |
186 | -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \ | |
187 | -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \ | |
188 | >actual-show-all-headers && | |
82ebb0b6 | 189 | test_cmp expected-show-all-headers actual-show-all-headers |
b7f30e0a DK |
190 | ' |
191 | ||
57cd35e6 | 192 | test_expect_success $PREREQ 'Prompting works' ' |
0da43a68 | 193 | clean_fake_sendmail && |
8cac13dc | 194 | (echo "to@example.com" |
0da43a68 JS |
195 | echo "" |
196 | ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \ | |
197 | --smtp-server="$(pwd)/fake.sendmail" \ | |
198 | $patches \ | |
199 | 2>errors && | |
8cac13dc | 200 | grep "^From: A U Thor <author@example.com>\$" msgtxt1 && |
9524cf29 | 201 | grep "^To: to@example.com\$" msgtxt1 |
0da43a68 JS |
202 | ' |
203 | ||
59defcc3 JK |
204 | test_expect_success $PREREQ,AUTOIDENT 'implicit ident is allowed' ' |
205 | clean_fake_sendmail && | |
206 | (sane_unset GIT_AUTHOR_NAME && | |
207 | sane_unset GIT_AUTHOR_EMAIL && | |
208 | sane_unset GIT_COMMITTER_NAME && | |
209 | sane_unset GIT_COMMITTER_EMAIL && | |
210 | GIT_SEND_EMAIL_NOTTY=1 git send-email \ | |
211 | --smtp-server="$(pwd)/fake.sendmail" \ | |
212 | --to=to@example.com \ | |
213 | $patches </dev/null 2>errors | |
214 | ) | |
215 | ' | |
216 | ||
217 | test_expect_success $PREREQ,!AUTOIDENT 'broken implicit ident aborts send-email' ' | |
218 | clean_fake_sendmail && | |
219 | (sane_unset GIT_AUTHOR_NAME && | |
220 | sane_unset GIT_AUTHOR_EMAIL && | |
221 | sane_unset GIT_COMMITTER_NAME && | |
222 | sane_unset GIT_COMMITTER_EMAIL && | |
223 | GIT_SEND_EMAIL_NOTTY=1 && export GIT_SEND_EMAIL_NOTTY && | |
224 | test_must_fail git send-email \ | |
225 | --smtp-server="$(pwd)/fake.sendmail" \ | |
226 | --to=to@example.com \ | |
227 | $patches </dev/null 2>errors && | |
228 | test_i18ngrep "tell me who you are" errors | |
229 | ) | |
230 | ' | |
231 | ||
6e74e075 JP |
232 | test_expect_success $PREREQ 'tocmd works' ' |
233 | clean_fake_sendmail && | |
234 | cp $patches tocmd.patch && | |
235 | echo tocmd--tocmd@example.com >>tocmd.patch && | |
236 | { | |
237 | echo "#!$SHELL_PATH" | |
238 | echo sed -n -e s/^tocmd--//p \"\$1\" | |
239 | } > tocmd-sed && | |
240 | chmod +x tocmd-sed && | |
241 | git send-email \ | |
242 | --from="Example <nobody@example.com>" \ | |
243 | --to-cmd=./tocmd-sed \ | |
244 | --smtp-server="$(pwd)/fake.sendmail" \ | |
245 | tocmd.patch \ | |
246 | && | |
247 | grep "^To: tocmd@example.com" msgtxt1 | |
248 | ' | |
249 | ||
57cd35e6 | 250 | test_expect_success $PREREQ 'cccmd works' ' |
cb8a9bd5 PB |
251 | clean_fake_sendmail && |
252 | cp $patches cccmd.patch && | |
41ae8f1d | 253 | echo "cccmd-- cccmd@example.com" >>cccmd.patch && |
977e289e BC |
254 | { |
255 | echo "#!$SHELL_PATH" | |
256 | echo sed -n -e s/^cccmd--//p \"\$1\" | |
257 | } > cccmd-sed && | |
cb8a9bd5 PB |
258 | chmod +x cccmd-sed && |
259 | git send-email \ | |
260 | --from="Example <nobody@example.com>" \ | |
261 | --to=nobody@example.com \ | |
262 | --cc-cmd=./cccmd-sed \ | |
263 | --smtp-server="$(pwd)/fake.sendmail" \ | |
264 | cccmd.patch \ | |
265 | && | |
02461e0e | 266 | grep "^ cccmd@example.com" msgtxt1 |
cb8a9bd5 PB |
267 | ' |
268 | ||
57cd35e6 | 269 | test_expect_success $PREREQ 'reject long lines' ' |
f9444147 ÆAB |
270 | z8=zzzzzzzz && |
271 | z64=$z8$z8$z8$z8$z8$z8$z8$z8 && | |
272 | z512=$z64$z64$z64$z64$z64$z64$z64$z64 && | |
6d34a2ba | 273 | clean_fake_sendmail && |
747bbff9 JK |
274 | cp $patches longline.patch && |
275 | echo $z512$z512 >>longline.patch && | |
d492b31c | 276 | test_must_fail git send-email \ |
747bbff9 JK |
277 | --from="Example <nobody@example.com>" \ |
278 | --to=nobody@example.com \ | |
279 | --smtp-server="$(pwd)/fake.sendmail" \ | |
280 | $patches longline.patch \ | |
281 | 2>errors && | |
282 | grep longline.patch errors | |
283 | ' | |
284 | ||
57cd35e6 | 285 | test_expect_success $PREREQ 'no patch was sent' ' |
6d34a2ba | 286 | ! test -e commandline1 |
747bbff9 JK |
287 | ' |
288 | ||
57cd35e6 | 289 | test_expect_success $PREREQ 'Author From: in message body' ' |
5012699d JS |
290 | clean_fake_sendmail && |
291 | git send-email \ | |
292 | --from="Example <nobody@example.com>" \ | |
293 | --to=nobody@example.com \ | |
294 | --smtp-server="$(pwd)/fake.sendmail" \ | |
295 | $patches && | |
cc7e8167 | 296 | sed "1,/^\$/d" < msgtxt1 > msgbody1 && |
5012699d JS |
297 | grep "From: A <author@example.com>" msgbody1 |
298 | ' | |
299 | ||
57cd35e6 | 300 | test_expect_success $PREREQ 'Author From: not in message body' ' |
5012699d JS |
301 | clean_fake_sendmail && |
302 | git send-email \ | |
303 | --from="A <author@example.com>" \ | |
304 | --to=nobody@example.com \ | |
305 | --smtp-server="$(pwd)/fake.sendmail" \ | |
306 | $patches && | |
cc7e8167 | 307 | sed "1,/^\$/d" < msgtxt1 > msgbody1 && |
5012699d JS |
308 | ! grep "From: A <author@example.com>" msgbody1 |
309 | ' | |
310 | ||
57cd35e6 | 311 | test_expect_success $PREREQ 'allow long lines with --no-validate' ' |
c764a0c2 JK |
312 | git send-email \ |
313 | --from="Example <nobody@example.com>" \ | |
314 | --to=nobody@example.com \ | |
315 | --smtp-server="$(pwd)/fake.sendmail" \ | |
3fee1fe8 | 316 | --novalidate \ |
c764a0c2 JK |
317 | $patches longline.patch \ |
318 | 2>errors | |
319 | ' | |
320 | ||
57cd35e6 | 321 | test_expect_success $PREREQ 'Invalid In-Reply-To' ' |
6d34a2ba | 322 | clean_fake_sendmail && |
0fb7fc75 JS |
323 | git send-email \ |
324 | --from="Example <nobody@example.com>" \ | |
325 | --to=nobody@example.com \ | |
326 | --in-reply-to=" " \ | |
327 | --smtp-server="$(pwd)/fake.sendmail" \ | |
5b57413c | 328 | $patches \ |
cc7e8167 | 329 | 2>errors && |
6d34a2ba | 330 | ! grep "^In-Reply-To: < *>" msgtxt1 |
0fb7fc75 JS |
331 | ' |
332 | ||
57cd35e6 | 333 | test_expect_success $PREREQ 'Valid In-Reply-To when prompting' ' |
6d34a2ba | 334 | clean_fake_sendmail && |
0fb7fc75 JS |
335 | (echo "From Example <from@example.com>" |
336 | echo "To Example <to@example.com>" | |
337 | echo "" | |
338 | ) | env GIT_SEND_EMAIL_NOTTY=1 git send-email \ | |
339 | --smtp-server="$(pwd)/fake.sendmail" \ | |
340 | $patches 2>errors && | |
6d34a2ba | 341 | ! grep "^In-Reply-To: < *>" msgtxt1 |
0fb7fc75 JS |
342 | ' |
343 | ||
54aae5e1 JH |
344 | test_expect_success $PREREQ 'In-Reply-To without --chain-reply-to' ' |
345 | clean_fake_sendmail && | |
346 | echo "<unique-message-id@example.com>" >expect && | |
347 | git send-email \ | |
348 | --from="Example <nobody@example.com>" \ | |
349 | --to=nobody@example.com \ | |
d2559f73 | 350 | --nochain-reply-to \ |
54aae5e1 JH |
351 | --in-reply-to="$(cat expect)" \ |
352 | --smtp-server="$(pwd)/fake.sendmail" \ | |
353 | $patches $patches $patches \ | |
354 | 2>errors && | |
db54c8e7 | 355 | # The first message is a reply to --in-reply-to |
54aae5e1 JH |
356 | sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual && |
357 | test_cmp expect actual && | |
db54c8e7 AO |
358 | # Second and subsequent messages are replies to the first one |
359 | sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect && | |
54aae5e1 JH |
360 | sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual && |
361 | test_cmp expect actual && | |
362 | sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual && | |
363 | test_cmp expect actual | |
364 | ' | |
365 | ||
366 | test_expect_success $PREREQ 'In-Reply-To with --chain-reply-to' ' | |
367 | clean_fake_sendmail && | |
368 | echo "<unique-message-id@example.com>" >expect && | |
369 | git send-email \ | |
370 | --from="Example <nobody@example.com>" \ | |
371 | --to=nobody@example.com \ | |
372 | --chain-reply-to \ | |
373 | --in-reply-to="$(cat expect)" \ | |
374 | --smtp-server="$(pwd)/fake.sendmail" \ | |
375 | $patches $patches $patches \ | |
376 | 2>errors && | |
377 | sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual && | |
378 | test_cmp expect actual && | |
379 | sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect && | |
380 | sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual && | |
381 | test_cmp expect actual && | |
382 | sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt2 >expect && | |
383 | sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual && | |
384 | test_cmp expect actual | |
385 | ' | |
386 | ||
57cd35e6 | 387 | test_expect_success $PREREQ 'setup fake editor' ' |
bb3e4f03 | 388 | (echo "#!$SHELL_PATH" && |
065096c2 | 389 | echo "echo fake edit >>\"\$1\"" |
8a8bf469 JK |
390 | ) >fake-editor && |
391 | chmod +x fake-editor | |
392 | ' | |
393 | ||
7f0475c3 | 394 | test_set_editor "$(pwd)/fake-editor" |
065096c2 | 395 | |
57cd35e6 | 396 | test_expect_success $PREREQ '--compose works' ' |
8a8bf469 | 397 | clean_fake_sendmail && |
c1f2aa45 JS |
398 | git send-email \ |
399 | --compose --subject foo \ | |
400 | --from="Example <nobody@example.com>" \ | |
401 | --to=nobody@example.com \ | |
402 | --smtp-server="$(pwd)/fake.sendmail" \ | |
403 | $patches \ | |
404 | 2>errors | |
8a8bf469 JK |
405 | ' |
406 | ||
57cd35e6 | 407 | test_expect_success $PREREQ 'first message is compose text' ' |
8a8bf469 JK |
408 | grep "^fake edit" msgtxt1 |
409 | ' | |
410 | ||
57cd35e6 | 411 | test_expect_success $PREREQ 'second message is patch' ' |
8a8bf469 JK |
412 | grep "Subject:.*Second" msgtxt2 |
413 | ' | |
414 | ||
f9444147 | 415 | test_expect_success $PREREQ 'setup expect' " |
3531e270 | 416 | cat >expected-suppress-sob <<\EOF |
33c592dd MV |
417 | 0001-Second.patch |
418 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
5012699d JS |
419 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' |
420 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
33c592dd MV |
421 | Dry-OK. Log says: |
422 | Server: relay.example.com | |
423 | MAIL FROM:<from@example.com> | |
02461e0e JP |
424 | RCPT TO:<to@example.com> |
425 | RCPT TO:<cc@example.com> | |
426 | RCPT TO:<author@example.com> | |
427 | RCPT TO:<one@example.com> | |
428 | RCPT TO:<two@example.com> | |
33c592dd MV |
429 | From: Example <from@example.com> |
430 | To: to@example.com | |
02461e0e JP |
431 | Cc: cc@example.com, |
432 | A <author@example.com>, | |
433 | One <one@example.com>, | |
434 | two@example.com | |
33c592dd MV |
435 | Subject: [PATCH 1/1] Second. |
436 | Date: DATE-STRING | |
437 | Message-Id: MESSAGE-ID-STRING | |
438 | X-Mailer: X-MAILER-STRING | |
439 | ||
440 | Result: OK | |
441 | EOF | |
f9444147 | 442 | " |
33c592dd | 443 | |
3531e270 | 444 | test_suppression () { |
33c592dd MV |
445 | git send-email \ |
446 | --dry-run \ | |
cb8a9bd5 | 447 | --suppress-cc=$1 ${2+"--suppress-cc=$2"} \ |
33c592dd MV |
448 | --from="Example <from@example.com>" \ |
449 | --to=to@example.com \ | |
450 | --smtp-server relay.example.com \ | |
451 | $patches | | |
452 | sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \ | |
453 | -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \ | |
454 | -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \ | |
cb8a9bd5 PB |
455 | >actual-suppress-$1${2+"-$2"} && |
456 | test_cmp expected-suppress-$1${2+"-$2"} actual-suppress-$1${2+"-$2"} | |
3531e270 JS |
457 | } |
458 | ||
57cd35e6 | 459 | test_expect_success $PREREQ 'sendemail.cc set' ' |
3531e270 JS |
460 | git config sendemail.cc cc@example.com && |
461 | test_suppression sob | |
33c592dd MV |
462 | ' |
463 | ||
f9444147 | 464 | test_expect_success $PREREQ 'setup expect' " |
3531e270 | 465 | cat >expected-suppress-sob <<\EOF |
33c592dd MV |
466 | 0001-Second.patch |
467 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
5012699d JS |
468 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' |
469 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
33c592dd MV |
470 | Dry-OK. Log says: |
471 | Server: relay.example.com | |
472 | MAIL FROM:<from@example.com> | |
02461e0e JP |
473 | RCPT TO:<to@example.com> |
474 | RCPT TO:<author@example.com> | |
475 | RCPT TO:<one@example.com> | |
476 | RCPT TO:<two@example.com> | |
33c592dd MV |
477 | From: Example <from@example.com> |
478 | To: to@example.com | |
02461e0e JP |
479 | Cc: A <author@example.com>, |
480 | One <one@example.com>, | |
481 | two@example.com | |
33c592dd MV |
482 | Subject: [PATCH 1/1] Second. |
483 | Date: DATE-STRING | |
484 | Message-Id: MESSAGE-ID-STRING | |
485 | X-Mailer: X-MAILER-STRING | |
486 | ||
487 | Result: OK | |
488 | EOF | |
f9444147 | 489 | " |
33c592dd | 490 | |
57cd35e6 | 491 | test_expect_success $PREREQ 'sendemail.cc unset' ' |
33c592dd | 492 | git config --unset sendemail.cc && |
3531e270 JS |
493 | test_suppression sob |
494 | ' | |
495 | ||
f9444147 | 496 | test_expect_success $PREREQ 'setup expect' " |
cb8a9bd5 PB |
497 | cat >expected-suppress-cccmd <<\EOF |
498 | 0001-Second.patch | |
499 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
500 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' | |
501 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
502 | (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>' | |
503 | Dry-OK. Log says: | |
504 | Server: relay.example.com | |
505 | MAIL FROM:<from@example.com> | |
02461e0e JP |
506 | RCPT TO:<to@example.com> |
507 | RCPT TO:<author@example.com> | |
508 | RCPT TO:<one@example.com> | |
509 | RCPT TO:<two@example.com> | |
510 | RCPT TO:<committer@example.com> | |
cb8a9bd5 PB |
511 | From: Example <from@example.com> |
512 | To: to@example.com | |
02461e0e JP |
513 | Cc: A <author@example.com>, |
514 | One <one@example.com>, | |
515 | two@example.com, | |
516 | C O Mitter <committer@example.com> | |
cb8a9bd5 PB |
517 | Subject: [PATCH 1/1] Second. |
518 | Date: DATE-STRING | |
519 | Message-Id: MESSAGE-ID-STRING | |
520 | X-Mailer: X-MAILER-STRING | |
521 | ||
522 | Result: OK | |
523 | EOF | |
f9444147 | 524 | " |
cb8a9bd5 | 525 | |
57cd35e6 | 526 | test_expect_success $PREREQ 'sendemail.cccmd' ' |
cb8a9bd5 PB |
527 | echo echo cc-cmd@example.com > cccmd && |
528 | chmod +x cccmd && | |
529 | git config sendemail.cccmd ./cccmd && | |
530 | test_suppression cccmd | |
531 | ' | |
532 | ||
f9444147 | 533 | test_expect_success $PREREQ 'setup expect' ' |
3531e270 JS |
534 | cat >expected-suppress-all <<\EOF |
535 | 0001-Second.patch | |
536 | Dry-OK. Log says: | |
537 | Server: relay.example.com | |
538 | MAIL FROM:<from@example.com> | |
539 | RCPT TO:<to@example.com> | |
540 | From: Example <from@example.com> | |
541 | To: to@example.com | |
542 | Subject: [PATCH 1/1] Second. | |
543 | Date: DATE-STRING | |
544 | Message-Id: MESSAGE-ID-STRING | |
545 | X-Mailer: X-MAILER-STRING | |
546 | ||
547 | Result: OK | |
548 | EOF | |
f9444147 | 549 | ' |
3531e270 | 550 | |
57cd35e6 | 551 | test_expect_success $PREREQ '--suppress-cc=all' ' |
3531e270 JS |
552 | test_suppression all |
553 | ' | |
554 | ||
f9444147 | 555 | test_expect_success $PREREQ 'setup expect' " |
3531e270 JS |
556 | cat >expected-suppress-body <<\EOF |
557 | 0001-Second.patch | |
558 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
559 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' | |
560 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
cb8a9bd5 | 561 | (cc-cmd) Adding cc: cc-cmd@example.com from: './cccmd' |
3531e270 JS |
562 | Dry-OK. Log says: |
563 | Server: relay.example.com | |
564 | MAIL FROM:<from@example.com> | |
02461e0e JP |
565 | RCPT TO:<to@example.com> |
566 | RCPT TO:<author@example.com> | |
567 | RCPT TO:<one@example.com> | |
568 | RCPT TO:<two@example.com> | |
569 | RCPT TO:<cc-cmd@example.com> | |
3531e270 JS |
570 | From: Example <from@example.com> |
571 | To: to@example.com | |
02461e0e JP |
572 | Cc: A <author@example.com>, |
573 | One <one@example.com>, | |
574 | two@example.com, | |
575 | cc-cmd@example.com | |
3531e270 JS |
576 | Subject: [PATCH 1/1] Second. |
577 | Date: DATE-STRING | |
578 | Message-Id: MESSAGE-ID-STRING | |
579 | X-Mailer: X-MAILER-STRING | |
580 | ||
581 | Result: OK | |
582 | EOF | |
f9444147 | 583 | " |
3531e270 | 584 | |
57cd35e6 | 585 | test_expect_success $PREREQ '--suppress-cc=body' ' |
3531e270 JS |
586 | test_suppression body |
587 | ' | |
588 | ||
f9444147 | 589 | test_expect_success $PREREQ 'setup expect' " |
cb8a9bd5 PB |
590 | cat >expected-suppress-body-cccmd <<\EOF |
591 | 0001-Second.patch | |
592 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
593 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' | |
594 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
595 | Dry-OK. Log says: | |
596 | Server: relay.example.com | |
597 | MAIL FROM:<from@example.com> | |
02461e0e JP |
598 | RCPT TO:<to@example.com> |
599 | RCPT TO:<author@example.com> | |
600 | RCPT TO:<one@example.com> | |
601 | RCPT TO:<two@example.com> | |
cb8a9bd5 PB |
602 | From: Example <from@example.com> |
603 | To: to@example.com | |
02461e0e JP |
604 | Cc: A <author@example.com>, |
605 | One <one@example.com>, | |
606 | two@example.com | |
cb8a9bd5 PB |
607 | Subject: [PATCH 1/1] Second. |
608 | Date: DATE-STRING | |
609 | Message-Id: MESSAGE-ID-STRING | |
610 | X-Mailer: X-MAILER-STRING | |
611 | ||
612 | Result: OK | |
613 | EOF | |
f9444147 | 614 | " |
cb8a9bd5 | 615 | |
57cd35e6 | 616 | test_expect_success $PREREQ '--suppress-cc=body --suppress-cc=cccmd' ' |
cb8a9bd5 PB |
617 | test_suppression body cccmd |
618 | ' | |
619 | ||
f9444147 | 620 | test_expect_success $PREREQ 'setup expect' " |
3531e270 JS |
621 | cat >expected-suppress-sob <<\EOF |
622 | 0001-Second.patch | |
623 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
624 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' | |
625 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
626 | Dry-OK. Log says: | |
627 | Server: relay.example.com | |
628 | MAIL FROM:<from@example.com> | |
02461e0e JP |
629 | RCPT TO:<to@example.com> |
630 | RCPT TO:<author@example.com> | |
631 | RCPT TO:<one@example.com> | |
632 | RCPT TO:<two@example.com> | |
3531e270 JS |
633 | From: Example <from@example.com> |
634 | To: to@example.com | |
02461e0e JP |
635 | Cc: A <author@example.com>, |
636 | One <one@example.com>, | |
637 | two@example.com | |
3531e270 JS |
638 | Subject: [PATCH 1/1] Second. |
639 | Date: DATE-STRING | |
640 | Message-Id: MESSAGE-ID-STRING | |
641 | X-Mailer: X-MAILER-STRING | |
642 | ||
643 | Result: OK | |
644 | EOF | |
f9444147 | 645 | " |
3531e270 | 646 | |
57cd35e6 | 647 | test_expect_success $PREREQ '--suppress-cc=sob' ' |
cc7e8167 | 648 | test_might_fail git config --unset sendemail.cccmd && |
3531e270 JS |
649 | test_suppression sob |
650 | ' | |
651 | ||
f9444147 | 652 | test_expect_success $PREREQ 'setup expect' " |
3531e270 JS |
653 | cat >expected-suppress-bodycc <<\EOF |
654 | 0001-Second.patch | |
655 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
656 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' | |
657 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
658 | (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>' | |
659 | Dry-OK. Log says: | |
660 | Server: relay.example.com | |
661 | MAIL FROM:<from@example.com> | |
02461e0e JP |
662 | RCPT TO:<to@example.com> |
663 | RCPT TO:<author@example.com> | |
664 | RCPT TO:<one@example.com> | |
665 | RCPT TO:<two@example.com> | |
666 | RCPT TO:<committer@example.com> | |
3531e270 JS |
667 | From: Example <from@example.com> |
668 | To: to@example.com | |
02461e0e JP |
669 | Cc: A <author@example.com>, |
670 | One <one@example.com>, | |
671 | two@example.com, | |
672 | C O Mitter <committer@example.com> | |
3531e270 JS |
673 | Subject: [PATCH 1/1] Second. |
674 | Date: DATE-STRING | |
675 | Message-Id: MESSAGE-ID-STRING | |
676 | X-Mailer: X-MAILER-STRING | |
677 | ||
678 | Result: OK | |
679 | EOF | |
f9444147 | 680 | " |
3531e270 | 681 | |
57cd35e6 | 682 | test_expect_success $PREREQ '--suppress-cc=bodycc' ' |
3531e270 JS |
683 | test_suppression bodycc |
684 | ' | |
685 | ||
f9444147 | 686 | test_expect_success $PREREQ 'setup expect' " |
3531e270 JS |
687 | cat >expected-suppress-cc <<\EOF |
688 | 0001-Second.patch | |
689 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
690 | (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>' | |
691 | Dry-OK. Log says: | |
692 | Server: relay.example.com | |
693 | MAIL FROM:<from@example.com> | |
02461e0e JP |
694 | RCPT TO:<to@example.com> |
695 | RCPT TO:<author@example.com> | |
696 | RCPT TO:<committer@example.com> | |
3531e270 JS |
697 | From: Example <from@example.com> |
698 | To: to@example.com | |
02461e0e JP |
699 | Cc: A <author@example.com>, |
700 | C O Mitter <committer@example.com> | |
3531e270 JS |
701 | Subject: [PATCH 1/1] Second. |
702 | Date: DATE-STRING | |
703 | Message-Id: MESSAGE-ID-STRING | |
704 | X-Mailer: X-MAILER-STRING | |
705 | ||
706 | Result: OK | |
707 | EOF | |
f9444147 | 708 | " |
3531e270 | 709 | |
57cd35e6 | 710 | test_expect_success $PREREQ '--suppress-cc=cc' ' |
3531e270 | 711 | test_suppression cc |
33c592dd MV |
712 | ' |
713 | ||
c1f2aa45 JS |
714 | test_confirm () { |
715 | echo y | \ | |
716 | GIT_SEND_EMAIL_NOTTY=1 \ | |
717 | git send-email \ | |
718 | --from="Example <nobody@example.com>" \ | |
719 | --to=nobody@example.com \ | |
720 | --smtp-server="$(pwd)/fake.sendmail" \ | |
c18f75a1 JS |
721 | $@ $patches > stdout && |
722 | grep "Send this email" stdout | |
c1f2aa45 JS |
723 | } |
724 | ||
57cd35e6 | 725 | test_expect_success $PREREQ '--confirm=always' ' |
c1f2aa45 JS |
726 | test_confirm --confirm=always --suppress-cc=all |
727 | ' | |
728 | ||
57cd35e6 | 729 | test_expect_success $PREREQ '--confirm=auto' ' |
c1f2aa45 JS |
730 | test_confirm --confirm=auto |
731 | ' | |
732 | ||
57cd35e6 | 733 | test_expect_success $PREREQ '--confirm=cc' ' |
c1f2aa45 JS |
734 | test_confirm --confirm=cc |
735 | ' | |
736 | ||
57cd35e6 | 737 | test_expect_success $PREREQ '--confirm=compose' ' |
c1f2aa45 JS |
738 | test_confirm --confirm=compose --compose |
739 | ' | |
740 | ||
57cd35e6 | 741 | test_expect_success $PREREQ 'confirm by default (due to cc)' ' |
c1f2aa45 JS |
742 | CONFIRM=$(git config --get sendemail.confirm) && |
743 | git config --unset sendemail.confirm && | |
c18f75a1 JS |
744 | test_confirm |
745 | ret="$?" | |
746 | git config sendemail.confirm ${CONFIRM:-never} | |
747 | test $ret = "0" | |
c1f2aa45 JS |
748 | ' |
749 | ||
57cd35e6 | 750 | test_expect_success $PREREQ 'confirm by default (due to --compose)' ' |
c1f2aa45 JS |
751 | CONFIRM=$(git config --get sendemail.confirm) && |
752 | git config --unset sendemail.confirm && | |
753 | test_confirm --suppress-cc=all --compose | |
754 | ret="$?" | |
755 | git config sendemail.confirm ${CONFIRM:-never} | |
756 | test $ret = "0" | |
757 | ' | |
758 | ||
57cd35e6 | 759 | test_expect_success $PREREQ 'confirm detects EOF (inform assumes y)' ' |
c18f75a1 JS |
760 | CONFIRM=$(git config --get sendemail.confirm) && |
761 | git config --unset sendemail.confirm && | |
dc1460aa JS |
762 | rm -fr outdir && |
763 | git format-patch -2 -o outdir && | |
c18f75a1 JS |
764 | GIT_SEND_EMAIL_NOTTY=1 \ |
765 | git send-email \ | |
766 | --from="Example <nobody@example.com>" \ | |
767 | --to=nobody@example.com \ | |
768 | --smtp-server="$(pwd)/fake.sendmail" \ | |
dc1460aa | 769 | outdir/*.patch < /dev/null |
c18f75a1 JS |
770 | ret="$?" |
771 | git config sendemail.confirm ${CONFIRM:-never} | |
772 | test $ret = "0" | |
773 | ' | |
774 | ||
57cd35e6 | 775 | test_expect_success $PREREQ 'confirm detects EOF (auto causes failure)' ' |
c18f75a1 JS |
776 | CONFIRM=$(git config --get sendemail.confirm) && |
777 | git config sendemail.confirm auto && | |
3b3637c3 JS |
778 | GIT_SEND_EMAIL_NOTTY=1 && |
779 | export GIT_SEND_EMAIL_NOTTY && | |
c18f75a1 JS |
780 | test_must_fail git send-email \ |
781 | --from="Example <nobody@example.com>" \ | |
782 | --to=nobody@example.com \ | |
783 | --smtp-server="$(pwd)/fake.sendmail" \ | |
784 | $patches < /dev/null | |
785 | ret="$?" | |
786 | git config sendemail.confirm ${CONFIRM:-never} | |
787 | test $ret = "0" | |
788 | ' | |
789 | ||
57cd35e6 | 790 | test_expect_success $PREREQ 'confirm doesnt loop forever' ' |
c18f75a1 JS |
791 | CONFIRM=$(git config --get sendemail.confirm) && |
792 | git config sendemail.confirm auto && | |
3b3637c3 JS |
793 | GIT_SEND_EMAIL_NOTTY=1 && |
794 | export GIT_SEND_EMAIL_NOTTY && | |
795 | yes "bogus" | test_must_fail git send-email \ | |
c18f75a1 JS |
796 | --from="Example <nobody@example.com>" \ |
797 | --to=nobody@example.com \ | |
798 | --smtp-server="$(pwd)/fake.sendmail" \ | |
799 | $patches | |
800 | ret="$?" | |
801 | git config sendemail.confirm ${CONFIRM:-never} | |
802 | test $ret = "0" | |
803 | ' | |
804 | ||
57cd35e6 | 805 | test_expect_success $PREREQ 'utf8 Cc is rfc2047 encoded' ' |
a61c0ffa JS |
806 | clean_fake_sendmail && |
807 | rm -fr outdir && | |
808 | git format-patch -1 -o outdir --cc="àéìöú <utf8@example.com>" && | |
809 | git send-email \ | |
810 | --from="Example <nobody@example.com>" \ | |
811 | --to=nobody@example.com \ | |
812 | --smtp-server="$(pwd)/fake.sendmail" \ | |
813 | outdir/*.patch && | |
02461e0e | 814 | grep "^ " msgtxt1 | |
d1fff6fc | 815 | grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>" |
a61c0ffa JS |
816 | ' |
817 | ||
57cd35e6 | 818 | test_expect_success $PREREQ '--compose adds MIME for utf8 body' ' |
0706bd19 | 819 | clean_fake_sendmail && |
bb3e4f03 | 820 | (echo "#!$SHELL_PATH" && |
c01cdde1 | 821 | echo "echo utf8 body: àéìöú >>\"\$1\"" |
0706bd19 JK |
822 | ) >fake-editor-utf8 && |
823 | chmod +x fake-editor-utf8 && | |
c01cdde1 | 824 | GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \ |
0706bd19 JK |
825 | git send-email \ |
826 | --compose --subject foo \ | |
827 | --from="Example <nobody@example.com>" \ | |
828 | --to=nobody@example.com \ | |
829 | --smtp-server="$(pwd)/fake.sendmail" \ | |
830 | $patches && | |
831 | grep "^utf8 body" msgtxt1 && | |
d1fff6fc | 832 | grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1 |
0706bd19 JK |
833 | ' |
834 | ||
57cd35e6 | 835 | test_expect_success $PREREQ '--compose respects user mime type' ' |
0706bd19 | 836 | clean_fake_sendmail && |
bb3e4f03 | 837 | (echo "#!$SHELL_PATH" && |
0706bd19 JK |
838 | echo "(echo MIME-Version: 1.0" |
839 | echo " echo Content-Type: text/plain\\; charset=iso-8859-1" | |
840 | echo " echo Content-Transfer-Encoding: 8bit" | |
841 | echo " echo Subject: foo" | |
842 | echo " echo " | |
c01cdde1 | 843 | echo " echo utf8 body: àéìöú) >\"\$1\"" |
0706bd19 JK |
844 | ) >fake-editor-utf8-mime && |
845 | chmod +x fake-editor-utf8-mime && | |
c01cdde1 | 846 | GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \ |
0706bd19 JK |
847 | git send-email \ |
848 | --compose --subject foo \ | |
849 | --from="Example <nobody@example.com>" \ | |
850 | --to=nobody@example.com \ | |
851 | --smtp-server="$(pwd)/fake.sendmail" \ | |
852 | $patches && | |
853 | grep "^utf8 body" msgtxt1 && | |
854 | grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 && | |
d1fff6fc | 855 | ! grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1 |
0706bd19 JK |
856 | ' |
857 | ||
57cd35e6 | 858 | test_expect_success $PREREQ '--compose adds MIME for utf8 subject' ' |
d54eaaa2 | 859 | clean_fake_sendmail && |
c01cdde1 | 860 | GIT_EDITOR="\"$(pwd)/fake-editor\"" \ |
d54eaaa2 JK |
861 | git send-email \ |
862 | --compose --subject utf8-sübjëct \ | |
863 | --from="Example <nobody@example.com>" \ | |
864 | --to=nobody@example.com \ | |
865 | --smtp-server="$(pwd)/fake.sendmail" \ | |
866 | $patches && | |
867 | grep "^fake edit" msgtxt1 && | |
d1fff6fc | 868 | grep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1 |
d54eaaa2 JK |
869 | ' |
870 | ||
b622d4d1 TR |
871 | test_expect_success $PREREQ 'utf8 author is correctly passed on' ' |
872 | clean_fake_sendmail && | |
873 | test_commit weird_author && | |
874 | test_when_finished "git reset --hard HEAD^" && | |
875 | git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" && | |
876 | git format-patch --stdout -1 >funny_name.patch && | |
877 | git send-email --from="Example <nobody@example.com>" \ | |
878 | --to=nobody@example.com \ | |
879 | --smtp-server="$(pwd)/fake.sendmail" \ | |
880 | funny_name.patch && | |
881 | grep "^From: Füñný Nâmé <odd_?=mail@example.com>" msgtxt1 | |
882 | ' | |
883 | ||
62e00690 KM |
884 | test_expect_success $PREREQ 'sendemail.composeencoding works' ' |
885 | clean_fake_sendmail && | |
886 | git config sendemail.composeencoding iso-8859-1 && | |
887 | (echo "#!$SHELL_PATH" && | |
888 | echo "echo utf8 body: àéìöú >>\"\$1\"" | |
889 | ) >fake-editor-utf8 && | |
890 | chmod +x fake-editor-utf8 && | |
891 | GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \ | |
892 | git send-email \ | |
893 | --compose --subject foo \ | |
894 | --from="Example <nobody@example.com>" \ | |
895 | --to=nobody@example.com \ | |
896 | --smtp-server="$(pwd)/fake.sendmail" \ | |
897 | $patches && | |
898 | grep "^utf8 body" msgtxt1 && | |
899 | grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 | |
900 | ' | |
901 | ||
902 | test_expect_success $PREREQ '--compose-encoding works' ' | |
903 | clean_fake_sendmail && | |
904 | (echo "#!$SHELL_PATH" && | |
905 | echo "echo utf8 body: àéìöú >>\"\$1\"" | |
906 | ) >fake-editor-utf8 && | |
907 | chmod +x fake-editor-utf8 && | |
908 | GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \ | |
909 | git send-email \ | |
910 | --compose-encoding iso-8859-1 \ | |
911 | --compose --subject foo \ | |
912 | --from="Example <nobody@example.com>" \ | |
913 | --to=nobody@example.com \ | |
914 | --smtp-server="$(pwd)/fake.sendmail" \ | |
915 | $patches && | |
916 | grep "^utf8 body" msgtxt1 && | |
917 | grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 | |
918 | ' | |
919 | ||
920 | test_expect_success $PREREQ '--compose-encoding overrides sendemail.composeencoding' ' | |
921 | clean_fake_sendmail && | |
922 | git config sendemail.composeencoding iso-8859-1 && | |
923 | (echo "#!$SHELL_PATH" && | |
924 | echo "echo utf8 body: àéìöú >>\"\$1\"" | |
925 | ) >fake-editor-utf8 && | |
926 | chmod +x fake-editor-utf8 && | |
927 | GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \ | |
928 | git send-email \ | |
929 | --compose-encoding iso-8859-2 \ | |
930 | --compose --subject foo \ | |
931 | --from="Example <nobody@example.com>" \ | |
932 | --to=nobody@example.com \ | |
933 | --smtp-server="$(pwd)/fake.sendmail" \ | |
934 | $patches && | |
935 | grep "^utf8 body" msgtxt1 && | |
936 | grep "^Content-Type: text/plain; charset=iso-8859-2" msgtxt1 | |
937 | ' | |
938 | ||
4a47a4dd KM |
939 | test_expect_success $PREREQ '--compose-encoding adds correct MIME for subject' ' |
940 | clean_fake_sendmail && | |
941 | GIT_EDITOR="\"$(pwd)/fake-editor\"" \ | |
942 | git send-email \ | |
943 | --compose-encoding iso-8859-2 \ | |
944 | --compose --subject utf8-sübjëct \ | |
945 | --from="Example <nobody@example.com>" \ | |
946 | --to=nobody@example.com \ | |
947 | --smtp-server="$(pwd)/fake.sendmail" \ | |
948 | $patches && | |
949 | grep "^fake edit" msgtxt1 && | |
950 | grep "^Subject: =?iso-8859-2?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1 | |
951 | ' | |
952 | ||
57cd35e6 | 953 | test_expect_success $PREREQ 'detects ambiguous reference/file conflict' ' |
5df9fcf6 PH |
954 | echo master > master && |
955 | git add master && | |
956 | git commit -m"add master" && | |
957 | test_must_fail git send-email --dry-run master 2>errors && | |
958 | grep disambiguate errors | |
959 | ' | |
960 | ||
57cd35e6 | 961 | test_expect_success $PREREQ 'feed two files' ' |
69f4ce55 JH |
962 | rm -fr outdir && |
963 | git format-patch -2 -o outdir && | |
c1f2aa45 | 964 | git send-email \ |
69f4ce55 JH |
965 | --dry-run \ |
966 | --from="Example <nobody@example.com>" \ | |
967 | --to=nobody@example.com \ | |
968 | outdir/000?-*.patch 2>errors >out && | |
969 | grep "^Subject: " out >subjects && | |
970 | test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." && | |
971 | test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add master" | |
972 | ' | |
973 | ||
57cd35e6 | 974 | test_expect_success $PREREQ 'in-reply-to but no threading' ' |
aaab4b9f TR |
975 | git send-email \ |
976 | --dry-run \ | |
977 | --from="Example <nobody@example.com>" \ | |
978 | --to=nobody@example.com \ | |
979 | --in-reply-to="<in-reply-id@example.com>" \ | |
84eeb687 | 980 | --nothread \ |
aaab4b9f TR |
981 | $patches | |
982 | grep "In-Reply-To: <in-reply-id@example.com>" | |
983 | ' | |
984 | ||
57cd35e6 | 985 | test_expect_success $PREREQ 'no in-reply-to and no threading' ' |
32ae8319 MH |
986 | git send-email \ |
987 | --dry-run \ | |
988 | --from="Example <nobody@example.com>" \ | |
989 | --to=nobody@example.com \ | |
990 | --nothread \ | |
991 | $patches $patches >stdout && | |
992 | ! grep "In-Reply-To: " stdout | |
993 | ' | |
994 | ||
57cd35e6 | 995 | test_expect_success $PREREQ 'threading but no chain-reply-to' ' |
d67114a5 MH |
996 | git send-email \ |
997 | --dry-run \ | |
998 | --from="Example <nobody@example.com>" \ | |
999 | --to=nobody@example.com \ | |
1000 | --thread \ | |
1001 | --nochain-reply-to \ | |
1002 | $patches $patches >stdout && | |
1003 | grep "In-Reply-To: " stdout | |
1004 | ' | |
1005 | ||
57cd35e6 | 1006 | test_expect_success $PREREQ 'warning with an implicit --chain-reply-to' ' |
528fb087 NS |
1007 | git send-email \ |
1008 | --dry-run \ | |
1009 | --from="Example <nobody@example.com>" \ | |
1010 | --to=nobody@example.com \ | |
1011 | outdir/000?-*.patch 2>errors >out && | |
1012 | grep "no-chain-reply-to" errors | |
1013 | ' | |
1014 | ||
57cd35e6 | 1015 | test_expect_success $PREREQ 'no warning with an explicit --chain-reply-to' ' |
528fb087 NS |
1016 | git send-email \ |
1017 | --dry-run \ | |
1018 | --from="Example <nobody@example.com>" \ | |
1019 | --to=nobody@example.com \ | |
1020 | --chain-reply-to \ | |
1021 | outdir/000?-*.patch 2>errors >out && | |
1022 | ! grep "no-chain-reply-to" errors | |
1023 | ' | |
1024 | ||
57cd35e6 | 1025 | test_expect_success $PREREQ 'no warning with an explicit --no-chain-reply-to' ' |
528fb087 NS |
1026 | git send-email \ |
1027 | --dry-run \ | |
1028 | --from="Example <nobody@example.com>" \ | |
1029 | --to=nobody@example.com \ | |
907a0b1e | 1030 | --nochain-reply-to \ |
528fb087 NS |
1031 | outdir/000?-*.patch 2>errors >out && |
1032 | ! grep "no-chain-reply-to" errors | |
1033 | ' | |
1034 | ||
57cd35e6 | 1035 | test_expect_success $PREREQ 'no warning with sendemail.chainreplyto = false' ' |
528fb087 NS |
1036 | git config sendemail.chainreplyto false && |
1037 | git send-email \ | |
1038 | --dry-run \ | |
1039 | --from="Example <nobody@example.com>" \ | |
1040 | --to=nobody@example.com \ | |
1041 | outdir/000?-*.patch 2>errors >out && | |
1042 | ! grep "no-chain-reply-to" errors | |
1043 | ' | |
1044 | ||
57cd35e6 | 1045 | test_expect_success $PREREQ 'no warning with sendemail.chainreplyto = true' ' |
528fb087 NS |
1046 | git config sendemail.chainreplyto true && |
1047 | git send-email \ | |
1048 | --dry-run \ | |
1049 | --from="Example <nobody@example.com>" \ | |
1050 | --to=nobody@example.com \ | |
1051 | outdir/000?-*.patch 2>errors >out && | |
1052 | ! grep "no-chain-reply-to" errors | |
1053 | ' | |
1054 | ||
57cd35e6 | 1055 | test_expect_success $PREREQ 'sendemail.to works' ' |
f434c083 SB |
1056 | git config --replace-all sendemail.to "Somebody <somebody@ex.com>" && |
1057 | git send-email \ | |
1058 | --dry-run \ | |
1059 | --from="Example <nobody@example.com>" \ | |
1060 | $patches $patches >stdout && | |
1061 | grep "To: Somebody <somebody@ex.com>" stdout | |
1062 | ' | |
1063 | ||
57cd35e6 | 1064 | test_expect_success $PREREQ '--no-to overrides sendemail.to' ' |
f434c083 SB |
1065 | git send-email \ |
1066 | --dry-run \ | |
1067 | --from="Example <nobody@example.com>" \ | |
1068 | --no-to \ | |
1069 | --to=nobody@example.com \ | |
1070 | $patches $patches >stdout && | |
1071 | grep "To: nobody@example.com" stdout && | |
1072 | ! grep "To: Somebody <somebody@ex.com>" stdout | |
1073 | ' | |
1074 | ||
57cd35e6 | 1075 | test_expect_success $PREREQ 'sendemail.cc works' ' |
f434c083 SB |
1076 | git config --replace-all sendemail.cc "Somebody <somebody@ex.com>" && |
1077 | git send-email \ | |
1078 | --dry-run \ | |
1079 | --from="Example <nobody@example.com>" \ | |
1080 | --to=nobody@example.com \ | |
1081 | $patches $patches >stdout && | |
1082 | grep "Cc: Somebody <somebody@ex.com>" stdout | |
1083 | ' | |
1084 | ||
57cd35e6 | 1085 | test_expect_success $PREREQ '--no-cc overrides sendemail.cc' ' |
f434c083 SB |
1086 | git send-email \ |
1087 | --dry-run \ | |
1088 | --from="Example <nobody@example.com>" \ | |
1089 | --no-cc \ | |
1090 | --cc=bodies@example.com \ | |
1091 | --to=nobody@example.com \ | |
1092 | $patches $patches >stdout && | |
1093 | grep "Cc: bodies@example.com" stdout && | |
1094 | ! grep "Cc: Somebody <somebody@ex.com>" stdout | |
1095 | ' | |
1096 | ||
57cd35e6 | 1097 | test_expect_success $PREREQ 'sendemail.bcc works' ' |
f434c083 SB |
1098 | git config --replace-all sendemail.bcc "Other <other@ex.com>" && |
1099 | git send-email \ | |
1100 | --dry-run \ | |
1101 | --from="Example <nobody@example.com>" \ | |
1102 | --to=nobody@example.com \ | |
1103 | --smtp-server relay.example.com \ | |
1104 | $patches $patches >stdout && | |
1105 | grep "RCPT TO:<other@ex.com>" stdout | |
1106 | ' | |
1107 | ||
57cd35e6 | 1108 | test_expect_success $PREREQ '--no-bcc overrides sendemail.bcc' ' |
f434c083 SB |
1109 | git send-email \ |
1110 | --dry-run \ | |
1111 | --from="Example <nobody@example.com>" \ | |
1112 | --no-bcc \ | |
1113 | --bcc=bodies@example.com \ | |
1114 | --to=nobody@example.com \ | |
1115 | --smtp-server relay.example.com \ | |
1116 | $patches $patches >stdout && | |
1117 | grep "RCPT TO:<bodies@example.com>" stdout && | |
1118 | ! grep "RCPT TO:<other@ex.com>" stdout | |
1119 | ' | |
1120 | ||
21802cd3 SB |
1121 | test_expect_success $PREREQ 'patches To headers are used by default' ' |
1122 | patch=`git format-patch -1 --to="bodies@example.com"` && | |
1123 | test_when_finished "rm $patch" && | |
1124 | git send-email \ | |
1125 | --dry-run \ | |
1126 | --from="Example <nobody@example.com>" \ | |
1127 | --smtp-server relay.example.com \ | |
1128 | $patch >stdout && | |
1129 | grep "RCPT TO:<bodies@example.com>" stdout | |
1130 | ' | |
1131 | ||
1132 | test_expect_success $PREREQ 'patches To headers are appended to' ' | |
1133 | patch=`git format-patch -1 --to="bodies@example.com"` && | |
1134 | test_when_finished "rm $patch" && | |
1135 | git send-email \ | |
1136 | --dry-run \ | |
1137 | --from="Example <nobody@example.com>" \ | |
1138 | --to=nobody@example.com \ | |
1139 | --smtp-server relay.example.com \ | |
1140 | $patch >stdout && | |
1141 | grep "RCPT TO:<bodies@example.com>" stdout && | |
1142 | grep "RCPT TO:<nobody@example.com>" stdout | |
1143 | ' | |
1144 | ||
3c3bb51c SB |
1145 | test_expect_success $PREREQ 'To headers from files reset each patch' ' |
1146 | patch1=`git format-patch -1 --to="bodies@example.com"` && | |
1147 | patch2=`git format-patch -1 --to="other@example.com" HEAD~` && | |
1148 | test_when_finished "rm $patch1 && rm $patch2" && | |
1149 | git send-email \ | |
1150 | --dry-run \ | |
1151 | --from="Example <nobody@example.com>" \ | |
1152 | --to="nobody@example.com" \ | |
1153 | --smtp-server relay.example.com \ | |
1154 | $patch1 $patch2 >stdout && | |
1155 | test $(grep -c "RCPT TO:<bodies@example.com>" stdout) = 1 && | |
1156 | test $(grep -c "RCPT TO:<nobody@example.com>" stdout) = 2 && | |
1157 | test $(grep -c "RCPT TO:<other@example.com>" stdout) = 1 | |
1158 | ' | |
1159 | ||
f9444147 | 1160 | test_expect_success $PREREQ 'setup expect' ' |
3cae7e5b TR |
1161 | cat >email-using-8bit <<EOF |
1162 | From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001 | |
1163 | Message-Id: <bogus-message-id@example.com> | |
1164 | From: author@example.com | |
1165 | Date: Sat, 12 Jun 2010 15:53:58 +0200 | |
1166 | Subject: subject goes here | |
1167 | ||
1168 | Dieser deutsche Text enthält einen Umlaut! | |
1169 | EOF | |
f9444147 | 1170 | ' |
3cae7e5b | 1171 | |
5637d857 KM |
1172 | test_expect_success $PREREQ 'setup expect' ' |
1173 | cat >expected <<EOF | |
1174 | Subject: subject goes here | |
1175 | EOF | |
1176 | ' | |
1177 | ||
1178 | test_expect_success $PREREQ 'ASCII subject is not RFC2047 quoted' ' | |
1179 | clean_fake_sendmail && | |
1180 | echo bogus | | |
1181 | git send-email --from=author@example.com --to=nobody@example.com \ | |
1182 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1183 | --8bit-encoding=UTF-8 \ | |
1184 | email-using-8bit >stdout && | |
1185 | grep "Subject" msgtxt1 >actual && | |
1186 | test_cmp expected actual | |
1187 | ' | |
1188 | ||
f9444147 | 1189 | test_expect_success $PREREQ 'setup expect' ' |
3cae7e5b TR |
1190 | cat >content-type-decl <<EOF |
1191 | MIME-Version: 1.0 | |
1192 | Content-Type: text/plain; charset=UTF-8 | |
1193 | Content-Transfer-Encoding: 8bit | |
1194 | EOF | |
f9444147 | 1195 | ' |
3cae7e5b | 1196 | |
57cd35e6 | 1197 | test_expect_success $PREREQ 'asks about and fixes 8bit encodings' ' |
3cae7e5b TR |
1198 | clean_fake_sendmail && |
1199 | echo | | |
1200 | git send-email --from=author@example.com --to=nobody@example.com \ | |
1201 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1202 | email-using-8bit >stdout && | |
1203 | grep "do not declare a Content-Transfer-Encoding" stdout && | |
1204 | grep email-using-8bit stdout && | |
1205 | grep "Which 8bit encoding" stdout && | |
31832862 | 1206 | egrep "Content|MIME" msgtxt1 >actual && |
3cae7e5b TR |
1207 | test_cmp actual content-type-decl |
1208 | ' | |
1209 | ||
57cd35e6 | 1210 | test_expect_success $PREREQ 'sendemail.8bitEncoding works' ' |
3cae7e5b TR |
1211 | clean_fake_sendmail && |
1212 | git config sendemail.assume8bitEncoding UTF-8 && | |
1213 | echo bogus | | |
1214 | git send-email --from=author@example.com --to=nobody@example.com \ | |
1215 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1216 | email-using-8bit >stdout && | |
31832862 | 1217 | egrep "Content|MIME" msgtxt1 >actual && |
3cae7e5b TR |
1218 | test_cmp actual content-type-decl |
1219 | ' | |
1220 | ||
57cd35e6 | 1221 | test_expect_success $PREREQ '--8bit-encoding overrides sendemail.8bitEncoding' ' |
3cae7e5b TR |
1222 | clean_fake_sendmail && |
1223 | git config sendemail.assume8bitEncoding "bogus too" && | |
1224 | echo bogus | | |
1225 | git send-email --from=author@example.com --to=nobody@example.com \ | |
1226 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1227 | --8bit-encoding=UTF-8 \ | |
1228 | email-using-8bit >stdout && | |
31832862 | 1229 | egrep "Content|MIME" msgtxt1 >actual && |
3cae7e5b TR |
1230 | test_cmp actual content-type-decl |
1231 | ' | |
1232 | ||
f9444147 | 1233 | test_expect_success $PREREQ 'setup expect' ' |
3cae7e5b TR |
1234 | cat >email-using-8bit <<EOF |
1235 | From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001 | |
1236 | Message-Id: <bogus-message-id@example.com> | |
1237 | From: author@example.com | |
1238 | Date: Sat, 12 Jun 2010 15:53:58 +0200 | |
1239 | Subject: Dieser Betreff enthält auch einen Umlaut! | |
1240 | ||
1241 | Nothing to see here. | |
1242 | EOF | |
f9444147 | 1243 | ' |
3cae7e5b | 1244 | |
f9444147 | 1245 | test_expect_success $PREREQ 'setup expect' ' |
3cae7e5b TR |
1246 | cat >expected <<EOF |
1247 | Subject: =?UTF-8?q?Dieser=20Betreff=20enth=C3=A4lt=20auch=20einen=20Umlaut!?= | |
1248 | EOF | |
f9444147 | 1249 | ' |
3cae7e5b | 1250 | |
57cd35e6 | 1251 | test_expect_success $PREREQ '--8bit-encoding also treats subject' ' |
3cae7e5b TR |
1252 | clean_fake_sendmail && |
1253 | echo bogus | | |
1254 | git send-email --from=author@example.com --to=nobody@example.com \ | |
1255 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1256 | --8bit-encoding=UTF-8 \ | |
1257 | email-using-8bit >stdout && | |
1258 | grep "Subject" msgtxt1 >actual && | |
1259 | test_cmp expected actual | |
1260 | ' | |
1261 | ||
a03bc5b6 TR |
1262 | # Note that the patches in this test are deliberately out of order; we |
1263 | # want to make sure it works even if the cover-letter is not in the | |
1264 | # first mail. | |
57da2042 | 1265 | test_expect_success $PREREQ 'refusing to send cover letter template' ' |
a03bc5b6 TR |
1266 | clean_fake_sendmail && |
1267 | rm -fr outdir && | |
1268 | git format-patch --cover-letter -2 -o outdir && | |
1269 | test_must_fail git send-email \ | |
1270 | --from="Example <nobody@example.com>" \ | |
1271 | --to=nobody@example.com \ | |
1272 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1273 | outdir/0002-*.patch \ | |
1274 | outdir/0000-*.patch \ | |
1275 | outdir/0001-*.patch \ | |
1276 | 2>errors >out && | |
1277 | grep "SUBJECT HERE" errors && | |
1278 | test -z "$(ls msgtxt*)" | |
1279 | ' | |
1280 | ||
57da2042 | 1281 | test_expect_success $PREREQ '--force sends cover letter template anyway' ' |
a03bc5b6 TR |
1282 | clean_fake_sendmail && |
1283 | rm -fr outdir && | |
1284 | git format-patch --cover-letter -2 -o outdir && | |
1285 | git send-email \ | |
1286 | --force \ | |
1287 | --from="Example <nobody@example.com>" \ | |
1288 | --to=nobody@example.com \ | |
1289 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1290 | outdir/0002-*.patch \ | |
1291 | outdir/0000-*.patch \ | |
1292 | outdir/0001-*.patch \ | |
1293 | 2>errors >out && | |
1294 | ! grep "SUBJECT HERE" errors && | |
1295 | test -n "$(ls msgtxt*)" | |
1296 | ' | |
1297 | ||
463b0ea2 CS |
1298 | test_expect_success $PREREQ 'sendemail.aliasfiletype=mailrc' ' |
1299 | clean_fake_sendmail && | |
1300 | echo "alias sbd somebody@example.org" >.mailrc && | |
1301 | git config --replace-all sendemail.aliasesfile "$(pwd)/.mailrc" && | |
1302 | git config sendemail.aliasfiletype mailrc && | |
1303 | git send-email \ | |
1304 | --from="Example <nobody@example.com>" \ | |
1305 | --to=sbd \ | |
1306 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1307 | outdir/0001-*.patch \ | |
1308 | 2>errors >out && | |
1309 | grep "^!somebody@example\.org!$" commandline1 | |
1310 | ' | |
1311 | ||
1312 | test_expect_success $PREREQ 'sendemail.aliasfile=~/.mailrc' ' | |
1313 | clean_fake_sendmail && | |
1314 | echo "alias sbd someone@example.org" >~/.mailrc && | |
1315 | git config --replace-all sendemail.aliasesfile "~/.mailrc" && | |
1316 | git config sendemail.aliasfiletype mailrc && | |
1317 | git send-email \ | |
1318 | --from="Example <nobody@example.com>" \ | |
1319 | --to=sbd \ | |
1320 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1321 | outdir/0001-*.patch \ | |
1322 | 2>errors >out && | |
1323 | grep "^!someone@example\.org!$" commandline1 | |
1324 | ' | |
1325 | ||
ce903018 | 1326 | test_done |