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