]>
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 && | |
cc7e8167 | 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 && | |
cc7e8167 | 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 \ |
cc7e8167 | 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 \ | |
d2559f73 | 322 | --nochain-reply-to \ |
54aae5e1 JH |
323 | --in-reply-to="$(cat expect)" \ |
324 | --smtp-server="$(pwd)/fake.sendmail" \ | |
325 | $patches $patches $patches \ | |
326 | 2>errors && | |
db54c8e7 | 327 | # The first message is a reply to --in-reply-to |
54aae5e1 JH |
328 | sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual && |
329 | test_cmp expect actual && | |
db54c8e7 AO |
330 | # Second and subsequent messages are replies to the first one |
331 | sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect && | |
54aae5e1 JH |
332 | sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual && |
333 | test_cmp expect actual && | |
334 | sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual && | |
335 | test_cmp expect actual | |
336 | ' | |
337 | ||
338 | test_expect_success $PREREQ 'In-Reply-To with --chain-reply-to' ' | |
339 | clean_fake_sendmail && | |
340 | echo "<unique-message-id@example.com>" >expect && | |
341 | git send-email \ | |
342 | --from="Example <nobody@example.com>" \ | |
343 | --to=nobody@example.com \ | |
344 | --chain-reply-to \ | |
345 | --in-reply-to="$(cat expect)" \ | |
346 | --smtp-server="$(pwd)/fake.sendmail" \ | |
347 | $patches $patches $patches \ | |
348 | 2>errors && | |
349 | sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual && | |
350 | test_cmp expect actual && | |
351 | sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect && | |
352 | sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual && | |
353 | test_cmp expect actual && | |
354 | sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt2 >expect && | |
355 | sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual && | |
356 | test_cmp expect actual | |
357 | ' | |
358 | ||
57cd35e6 | 359 | test_expect_success $PREREQ 'setup fake editor' ' |
bb3e4f03 | 360 | (echo "#!$SHELL_PATH" && |
065096c2 | 361 | echo "echo fake edit >>\"\$1\"" |
8a8bf469 JK |
362 | ) >fake-editor && |
363 | chmod +x fake-editor | |
364 | ' | |
365 | ||
7f0475c3 | 366 | test_set_editor "$(pwd)/fake-editor" |
065096c2 | 367 | |
57cd35e6 | 368 | test_expect_success $PREREQ '--compose works' ' |
8a8bf469 | 369 | clean_fake_sendmail && |
c1f2aa45 JS |
370 | git send-email \ |
371 | --compose --subject foo \ | |
372 | --from="Example <nobody@example.com>" \ | |
373 | --to=nobody@example.com \ | |
374 | --smtp-server="$(pwd)/fake.sendmail" \ | |
375 | $patches \ | |
376 | 2>errors | |
8a8bf469 JK |
377 | ' |
378 | ||
57cd35e6 | 379 | test_expect_success $PREREQ 'first message is compose text' ' |
8a8bf469 JK |
380 | grep "^fake edit" msgtxt1 |
381 | ' | |
382 | ||
57cd35e6 | 383 | test_expect_success $PREREQ 'second message is patch' ' |
8a8bf469 JK |
384 | grep "Subject:.*Second" msgtxt2 |
385 | ' | |
386 | ||
f9444147 | 387 | test_expect_success $PREREQ 'setup expect' " |
3531e270 | 388 | cat >expected-suppress-sob <<\EOF |
33c592dd MV |
389 | 0001-Second.patch |
390 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
5012699d JS |
391 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' |
392 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
33c592dd MV |
393 | Dry-OK. Log says: |
394 | Server: relay.example.com | |
395 | MAIL FROM:<from@example.com> | |
02461e0e JP |
396 | RCPT TO:<to@example.com> |
397 | RCPT TO:<cc@example.com> | |
398 | RCPT TO:<author@example.com> | |
399 | RCPT TO:<one@example.com> | |
400 | RCPT TO:<two@example.com> | |
33c592dd MV |
401 | From: Example <from@example.com> |
402 | To: to@example.com | |
02461e0e JP |
403 | Cc: cc@example.com, |
404 | A <author@example.com>, | |
405 | One <one@example.com>, | |
406 | two@example.com | |
33c592dd MV |
407 | Subject: [PATCH 1/1] Second. |
408 | Date: DATE-STRING | |
409 | Message-Id: MESSAGE-ID-STRING | |
410 | X-Mailer: X-MAILER-STRING | |
411 | ||
412 | Result: OK | |
413 | EOF | |
f9444147 | 414 | " |
33c592dd | 415 | |
3531e270 | 416 | test_suppression () { |
33c592dd MV |
417 | git send-email \ |
418 | --dry-run \ | |
cb8a9bd5 | 419 | --suppress-cc=$1 ${2+"--suppress-cc=$2"} \ |
33c592dd MV |
420 | --from="Example <from@example.com>" \ |
421 | --to=to@example.com \ | |
422 | --smtp-server relay.example.com \ | |
423 | $patches | | |
424 | sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \ | |
425 | -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \ | |
426 | -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \ | |
cb8a9bd5 PB |
427 | >actual-suppress-$1${2+"-$2"} && |
428 | test_cmp expected-suppress-$1${2+"-$2"} actual-suppress-$1${2+"-$2"} | |
3531e270 JS |
429 | } |
430 | ||
57cd35e6 | 431 | test_expect_success $PREREQ 'sendemail.cc set' ' |
3531e270 JS |
432 | git config sendemail.cc cc@example.com && |
433 | test_suppression sob | |
33c592dd MV |
434 | ' |
435 | ||
f9444147 | 436 | test_expect_success $PREREQ 'setup expect' " |
3531e270 | 437 | cat >expected-suppress-sob <<\EOF |
33c592dd MV |
438 | 0001-Second.patch |
439 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
5012699d JS |
440 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' |
441 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
33c592dd MV |
442 | Dry-OK. Log says: |
443 | Server: relay.example.com | |
444 | MAIL FROM:<from@example.com> | |
02461e0e JP |
445 | RCPT TO:<to@example.com> |
446 | RCPT TO:<author@example.com> | |
447 | RCPT TO:<one@example.com> | |
448 | RCPT TO:<two@example.com> | |
33c592dd MV |
449 | From: Example <from@example.com> |
450 | To: to@example.com | |
02461e0e JP |
451 | Cc: A <author@example.com>, |
452 | One <one@example.com>, | |
453 | two@example.com | |
33c592dd MV |
454 | Subject: [PATCH 1/1] Second. |
455 | Date: DATE-STRING | |
456 | Message-Id: MESSAGE-ID-STRING | |
457 | X-Mailer: X-MAILER-STRING | |
458 | ||
459 | Result: OK | |
460 | EOF | |
f9444147 | 461 | " |
33c592dd | 462 | |
57cd35e6 | 463 | test_expect_success $PREREQ 'sendemail.cc unset' ' |
33c592dd | 464 | git config --unset sendemail.cc && |
3531e270 JS |
465 | test_suppression sob |
466 | ' | |
467 | ||
f9444147 | 468 | test_expect_success $PREREQ 'setup expect' " |
cb8a9bd5 PB |
469 | cat >expected-suppress-cccmd <<\EOF |
470 | 0001-Second.patch | |
471 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
472 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' | |
473 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
474 | (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>' | |
475 | Dry-OK. Log says: | |
476 | Server: relay.example.com | |
477 | MAIL FROM:<from@example.com> | |
02461e0e JP |
478 | RCPT TO:<to@example.com> |
479 | RCPT TO:<author@example.com> | |
480 | RCPT TO:<one@example.com> | |
481 | RCPT TO:<two@example.com> | |
482 | RCPT TO:<committer@example.com> | |
cb8a9bd5 PB |
483 | From: Example <from@example.com> |
484 | To: to@example.com | |
02461e0e JP |
485 | Cc: A <author@example.com>, |
486 | One <one@example.com>, | |
487 | two@example.com, | |
488 | C O Mitter <committer@example.com> | |
cb8a9bd5 PB |
489 | Subject: [PATCH 1/1] Second. |
490 | Date: DATE-STRING | |
491 | Message-Id: MESSAGE-ID-STRING | |
492 | X-Mailer: X-MAILER-STRING | |
493 | ||
494 | Result: OK | |
495 | EOF | |
f9444147 | 496 | " |
cb8a9bd5 | 497 | |
57cd35e6 | 498 | test_expect_success $PREREQ 'sendemail.cccmd' ' |
cb8a9bd5 PB |
499 | echo echo cc-cmd@example.com > cccmd && |
500 | chmod +x cccmd && | |
501 | git config sendemail.cccmd ./cccmd && | |
502 | test_suppression cccmd | |
503 | ' | |
504 | ||
f9444147 | 505 | test_expect_success $PREREQ 'setup expect' ' |
3531e270 JS |
506 | cat >expected-suppress-all <<\EOF |
507 | 0001-Second.patch | |
508 | Dry-OK. Log says: | |
509 | Server: relay.example.com | |
510 | MAIL FROM:<from@example.com> | |
511 | RCPT TO:<to@example.com> | |
512 | From: Example <from@example.com> | |
513 | To: to@example.com | |
514 | Subject: [PATCH 1/1] Second. | |
515 | Date: DATE-STRING | |
516 | Message-Id: MESSAGE-ID-STRING | |
517 | X-Mailer: X-MAILER-STRING | |
518 | ||
519 | Result: OK | |
520 | EOF | |
f9444147 | 521 | ' |
3531e270 | 522 | |
57cd35e6 | 523 | test_expect_success $PREREQ '--suppress-cc=all' ' |
3531e270 JS |
524 | test_suppression all |
525 | ' | |
526 | ||
f9444147 | 527 | test_expect_success $PREREQ 'setup expect' " |
3531e270 JS |
528 | cat >expected-suppress-body <<\EOF |
529 | 0001-Second.patch | |
530 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
531 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' | |
532 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
cb8a9bd5 | 533 | (cc-cmd) Adding cc: cc-cmd@example.com from: './cccmd' |
3531e270 JS |
534 | Dry-OK. Log says: |
535 | Server: relay.example.com | |
536 | MAIL FROM:<from@example.com> | |
02461e0e JP |
537 | RCPT TO:<to@example.com> |
538 | RCPT TO:<author@example.com> | |
539 | RCPT TO:<one@example.com> | |
540 | RCPT TO:<two@example.com> | |
541 | RCPT TO:<cc-cmd@example.com> | |
3531e270 JS |
542 | From: Example <from@example.com> |
543 | To: to@example.com | |
02461e0e JP |
544 | Cc: A <author@example.com>, |
545 | One <one@example.com>, | |
546 | two@example.com, | |
547 | cc-cmd@example.com | |
3531e270 JS |
548 | Subject: [PATCH 1/1] Second. |
549 | Date: DATE-STRING | |
550 | Message-Id: MESSAGE-ID-STRING | |
551 | X-Mailer: X-MAILER-STRING | |
552 | ||
553 | Result: OK | |
554 | EOF | |
f9444147 | 555 | " |
3531e270 | 556 | |
57cd35e6 | 557 | test_expect_success $PREREQ '--suppress-cc=body' ' |
3531e270 JS |
558 | test_suppression body |
559 | ' | |
560 | ||
f9444147 | 561 | test_expect_success $PREREQ 'setup expect' " |
cb8a9bd5 PB |
562 | cat >expected-suppress-body-cccmd <<\EOF |
563 | 0001-Second.patch | |
564 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
565 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' | |
566 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
567 | Dry-OK. Log says: | |
568 | Server: relay.example.com | |
569 | MAIL FROM:<from@example.com> | |
02461e0e JP |
570 | RCPT TO:<to@example.com> |
571 | RCPT TO:<author@example.com> | |
572 | RCPT TO:<one@example.com> | |
573 | RCPT TO:<two@example.com> | |
cb8a9bd5 PB |
574 | From: Example <from@example.com> |
575 | To: to@example.com | |
02461e0e JP |
576 | Cc: A <author@example.com>, |
577 | One <one@example.com>, | |
578 | two@example.com | |
cb8a9bd5 PB |
579 | Subject: [PATCH 1/1] Second. |
580 | Date: DATE-STRING | |
581 | Message-Id: MESSAGE-ID-STRING | |
582 | X-Mailer: X-MAILER-STRING | |
583 | ||
584 | Result: OK | |
585 | EOF | |
f9444147 | 586 | " |
cb8a9bd5 | 587 | |
57cd35e6 | 588 | test_expect_success $PREREQ '--suppress-cc=body --suppress-cc=cccmd' ' |
cb8a9bd5 PB |
589 | test_suppression body cccmd |
590 | ' | |
591 | ||
f9444147 | 592 | test_expect_success $PREREQ 'setup expect' " |
3531e270 JS |
593 | cat >expected-suppress-sob <<\EOF |
594 | 0001-Second.patch | |
595 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
596 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' | |
597 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
598 | Dry-OK. Log says: | |
599 | Server: relay.example.com | |
600 | MAIL FROM:<from@example.com> | |
02461e0e JP |
601 | RCPT TO:<to@example.com> |
602 | RCPT TO:<author@example.com> | |
603 | RCPT TO:<one@example.com> | |
604 | RCPT TO:<two@example.com> | |
3531e270 JS |
605 | From: Example <from@example.com> |
606 | To: to@example.com | |
02461e0e JP |
607 | Cc: A <author@example.com>, |
608 | One <one@example.com>, | |
609 | two@example.com | |
3531e270 JS |
610 | Subject: [PATCH 1/1] Second. |
611 | Date: DATE-STRING | |
612 | Message-Id: MESSAGE-ID-STRING | |
613 | X-Mailer: X-MAILER-STRING | |
614 | ||
615 | Result: OK | |
616 | EOF | |
f9444147 | 617 | " |
3531e270 | 618 | |
57cd35e6 | 619 | test_expect_success $PREREQ '--suppress-cc=sob' ' |
cc7e8167 | 620 | test_might_fail git config --unset sendemail.cccmd && |
3531e270 JS |
621 | test_suppression sob |
622 | ' | |
623 | ||
f9444147 | 624 | test_expect_success $PREREQ 'setup expect' " |
3531e270 JS |
625 | cat >expected-suppress-bodycc <<\EOF |
626 | 0001-Second.patch | |
627 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
628 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' | |
629 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
630 | (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>' | |
631 | Dry-OK. Log says: | |
632 | Server: relay.example.com | |
633 | MAIL FROM:<from@example.com> | |
02461e0e JP |
634 | RCPT TO:<to@example.com> |
635 | RCPT TO:<author@example.com> | |
636 | RCPT TO:<one@example.com> | |
637 | RCPT TO:<two@example.com> | |
638 | RCPT TO:<committer@example.com> | |
3531e270 JS |
639 | From: Example <from@example.com> |
640 | To: to@example.com | |
02461e0e JP |
641 | Cc: A <author@example.com>, |
642 | One <one@example.com>, | |
643 | two@example.com, | |
644 | C O Mitter <committer@example.com> | |
3531e270 JS |
645 | Subject: [PATCH 1/1] Second. |
646 | Date: DATE-STRING | |
647 | Message-Id: MESSAGE-ID-STRING | |
648 | X-Mailer: X-MAILER-STRING | |
649 | ||
650 | Result: OK | |
651 | EOF | |
f9444147 | 652 | " |
3531e270 | 653 | |
57cd35e6 | 654 | test_expect_success $PREREQ '--suppress-cc=bodycc' ' |
3531e270 JS |
655 | test_suppression bodycc |
656 | ' | |
657 | ||
f9444147 | 658 | test_expect_success $PREREQ 'setup expect' " |
3531e270 JS |
659 | cat >expected-suppress-cc <<\EOF |
660 | 0001-Second.patch | |
661 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
662 | (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>' | |
663 | Dry-OK. Log says: | |
664 | Server: relay.example.com | |
665 | MAIL FROM:<from@example.com> | |
02461e0e JP |
666 | RCPT TO:<to@example.com> |
667 | RCPT TO:<author@example.com> | |
668 | RCPT TO:<committer@example.com> | |
3531e270 JS |
669 | From: Example <from@example.com> |
670 | To: to@example.com | |
02461e0e JP |
671 | Cc: A <author@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=cc' ' |
3531e270 | 683 | test_suppression cc |
33c592dd MV |
684 | ' |
685 | ||
c1f2aa45 JS |
686 | test_confirm () { |
687 | echo y | \ | |
688 | GIT_SEND_EMAIL_NOTTY=1 \ | |
689 | git send-email \ | |
690 | --from="Example <nobody@example.com>" \ | |
691 | --to=nobody@example.com \ | |
692 | --smtp-server="$(pwd)/fake.sendmail" \ | |
c18f75a1 JS |
693 | $@ $patches > stdout && |
694 | grep "Send this email" stdout | |
c1f2aa45 JS |
695 | } |
696 | ||
57cd35e6 | 697 | test_expect_success $PREREQ '--confirm=always' ' |
c1f2aa45 JS |
698 | test_confirm --confirm=always --suppress-cc=all |
699 | ' | |
700 | ||
57cd35e6 | 701 | test_expect_success $PREREQ '--confirm=auto' ' |
c1f2aa45 JS |
702 | test_confirm --confirm=auto |
703 | ' | |
704 | ||
57cd35e6 | 705 | test_expect_success $PREREQ '--confirm=cc' ' |
c1f2aa45 JS |
706 | test_confirm --confirm=cc |
707 | ' | |
708 | ||
57cd35e6 | 709 | test_expect_success $PREREQ '--confirm=compose' ' |
c1f2aa45 JS |
710 | test_confirm --confirm=compose --compose |
711 | ' | |
712 | ||
57cd35e6 | 713 | test_expect_success $PREREQ 'confirm by default (due to cc)' ' |
c1f2aa45 JS |
714 | CONFIRM=$(git config --get sendemail.confirm) && |
715 | git config --unset sendemail.confirm && | |
c18f75a1 JS |
716 | test_confirm |
717 | ret="$?" | |
718 | git config sendemail.confirm ${CONFIRM:-never} | |
719 | test $ret = "0" | |
c1f2aa45 JS |
720 | ' |
721 | ||
57cd35e6 | 722 | test_expect_success $PREREQ 'confirm by default (due to --compose)' ' |
c1f2aa45 JS |
723 | CONFIRM=$(git config --get sendemail.confirm) && |
724 | git config --unset sendemail.confirm && | |
725 | test_confirm --suppress-cc=all --compose | |
726 | ret="$?" | |
727 | git config sendemail.confirm ${CONFIRM:-never} | |
728 | test $ret = "0" | |
729 | ' | |
730 | ||
57cd35e6 | 731 | test_expect_success $PREREQ 'confirm detects EOF (inform assumes y)' ' |
c18f75a1 JS |
732 | CONFIRM=$(git config --get sendemail.confirm) && |
733 | git config --unset sendemail.confirm && | |
dc1460aa JS |
734 | rm -fr outdir && |
735 | git format-patch -2 -o outdir && | |
c18f75a1 JS |
736 | GIT_SEND_EMAIL_NOTTY=1 \ |
737 | git send-email \ | |
738 | --from="Example <nobody@example.com>" \ | |
739 | --to=nobody@example.com \ | |
740 | --smtp-server="$(pwd)/fake.sendmail" \ | |
dc1460aa | 741 | outdir/*.patch < /dev/null |
c18f75a1 JS |
742 | ret="$?" |
743 | git config sendemail.confirm ${CONFIRM:-never} | |
744 | test $ret = "0" | |
745 | ' | |
746 | ||
57cd35e6 | 747 | test_expect_success $PREREQ 'confirm detects EOF (auto causes failure)' ' |
c18f75a1 JS |
748 | CONFIRM=$(git config --get sendemail.confirm) && |
749 | git config sendemail.confirm auto && | |
3b3637c3 JS |
750 | GIT_SEND_EMAIL_NOTTY=1 && |
751 | export GIT_SEND_EMAIL_NOTTY && | |
c18f75a1 JS |
752 | test_must_fail git send-email \ |
753 | --from="Example <nobody@example.com>" \ | |
754 | --to=nobody@example.com \ | |
755 | --smtp-server="$(pwd)/fake.sendmail" \ | |
756 | $patches < /dev/null | |
757 | ret="$?" | |
758 | git config sendemail.confirm ${CONFIRM:-never} | |
759 | test $ret = "0" | |
760 | ' | |
761 | ||
57cd35e6 | 762 | test_expect_success $PREREQ 'confirm doesnt loop forever' ' |
c18f75a1 JS |
763 | CONFIRM=$(git config --get sendemail.confirm) && |
764 | git config sendemail.confirm auto && | |
3b3637c3 JS |
765 | GIT_SEND_EMAIL_NOTTY=1 && |
766 | export GIT_SEND_EMAIL_NOTTY && | |
767 | yes "bogus" | test_must_fail git send-email \ | |
c18f75a1 JS |
768 | --from="Example <nobody@example.com>" \ |
769 | --to=nobody@example.com \ | |
770 | --smtp-server="$(pwd)/fake.sendmail" \ | |
771 | $patches | |
772 | ret="$?" | |
773 | git config sendemail.confirm ${CONFIRM:-never} | |
774 | test $ret = "0" | |
775 | ' | |
776 | ||
57cd35e6 | 777 | test_expect_success $PREREQ 'utf8 Cc is rfc2047 encoded' ' |
a61c0ffa JS |
778 | clean_fake_sendmail && |
779 | rm -fr outdir && | |
780 | git format-patch -1 -o outdir --cc="àéìöú <utf8@example.com>" && | |
781 | git send-email \ | |
782 | --from="Example <nobody@example.com>" \ | |
783 | --to=nobody@example.com \ | |
784 | --smtp-server="$(pwd)/fake.sendmail" \ | |
785 | outdir/*.patch && | |
02461e0e | 786 | grep "^ " msgtxt1 | |
d1fff6fc | 787 | grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>" |
a61c0ffa JS |
788 | ' |
789 | ||
57cd35e6 | 790 | test_expect_success $PREREQ '--compose adds MIME for utf8 body' ' |
0706bd19 | 791 | clean_fake_sendmail && |
bb3e4f03 | 792 | (echo "#!$SHELL_PATH" && |
c01cdde1 | 793 | echo "echo utf8 body: àéìöú >>\"\$1\"" |
0706bd19 JK |
794 | ) >fake-editor-utf8 && |
795 | chmod +x fake-editor-utf8 && | |
c01cdde1 | 796 | GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \ |
0706bd19 JK |
797 | git send-email \ |
798 | --compose --subject foo \ | |
799 | --from="Example <nobody@example.com>" \ | |
800 | --to=nobody@example.com \ | |
801 | --smtp-server="$(pwd)/fake.sendmail" \ | |
802 | $patches && | |
803 | grep "^utf8 body" msgtxt1 && | |
d1fff6fc | 804 | grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1 |
0706bd19 JK |
805 | ' |
806 | ||
57cd35e6 | 807 | test_expect_success $PREREQ '--compose respects user mime type' ' |
0706bd19 | 808 | clean_fake_sendmail && |
bb3e4f03 | 809 | (echo "#!$SHELL_PATH" && |
0706bd19 JK |
810 | echo "(echo MIME-Version: 1.0" |
811 | echo " echo Content-Type: text/plain\\; charset=iso-8859-1" | |
812 | echo " echo Content-Transfer-Encoding: 8bit" | |
813 | echo " echo Subject: foo" | |
814 | echo " echo " | |
c01cdde1 | 815 | echo " echo utf8 body: àéìöú) >\"\$1\"" |
0706bd19 JK |
816 | ) >fake-editor-utf8-mime && |
817 | chmod +x fake-editor-utf8-mime && | |
c01cdde1 | 818 | GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \ |
0706bd19 JK |
819 | git send-email \ |
820 | --compose --subject foo \ | |
821 | --from="Example <nobody@example.com>" \ | |
822 | --to=nobody@example.com \ | |
823 | --smtp-server="$(pwd)/fake.sendmail" \ | |
824 | $patches && | |
825 | grep "^utf8 body" msgtxt1 && | |
826 | grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 && | |
d1fff6fc | 827 | ! grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1 |
0706bd19 JK |
828 | ' |
829 | ||
57cd35e6 | 830 | test_expect_success $PREREQ '--compose adds MIME for utf8 subject' ' |
d54eaaa2 | 831 | clean_fake_sendmail && |
c01cdde1 | 832 | GIT_EDITOR="\"$(pwd)/fake-editor\"" \ |
d54eaaa2 JK |
833 | git send-email \ |
834 | --compose --subject utf8-sübjëct \ | |
835 | --from="Example <nobody@example.com>" \ | |
836 | --to=nobody@example.com \ | |
837 | --smtp-server="$(pwd)/fake.sendmail" \ | |
838 | $patches && | |
839 | grep "^fake edit" msgtxt1 && | |
d1fff6fc | 840 | grep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1 |
d54eaaa2 JK |
841 | ' |
842 | ||
57cd35e6 | 843 | test_expect_success $PREREQ 'detects ambiguous reference/file conflict' ' |
5df9fcf6 PH |
844 | echo master > master && |
845 | git add master && | |
846 | git commit -m"add master" && | |
847 | test_must_fail git send-email --dry-run master 2>errors && | |
848 | grep disambiguate errors | |
849 | ' | |
850 | ||
57cd35e6 | 851 | test_expect_success $PREREQ 'feed two files' ' |
69f4ce55 JH |
852 | rm -fr outdir && |
853 | git format-patch -2 -o outdir && | |
c1f2aa45 | 854 | git send-email \ |
69f4ce55 JH |
855 | --dry-run \ |
856 | --from="Example <nobody@example.com>" \ | |
857 | --to=nobody@example.com \ | |
858 | outdir/000?-*.patch 2>errors >out && | |
859 | grep "^Subject: " out >subjects && | |
860 | test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." && | |
861 | test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add master" | |
862 | ' | |
863 | ||
57cd35e6 | 864 | test_expect_success $PREREQ 'in-reply-to but no threading' ' |
aaab4b9f TR |
865 | git send-email \ |
866 | --dry-run \ | |
867 | --from="Example <nobody@example.com>" \ | |
868 | --to=nobody@example.com \ | |
869 | --in-reply-to="<in-reply-id@example.com>" \ | |
84eeb687 | 870 | --nothread \ |
aaab4b9f TR |
871 | $patches | |
872 | grep "In-Reply-To: <in-reply-id@example.com>" | |
873 | ' | |
874 | ||
57cd35e6 | 875 | test_expect_success $PREREQ 'no in-reply-to and no threading' ' |
32ae8319 MH |
876 | git send-email \ |
877 | --dry-run \ | |
878 | --from="Example <nobody@example.com>" \ | |
879 | --to=nobody@example.com \ | |
880 | --nothread \ | |
881 | $patches $patches >stdout && | |
882 | ! grep "In-Reply-To: " stdout | |
883 | ' | |
884 | ||
57cd35e6 | 885 | test_expect_success $PREREQ 'threading but no chain-reply-to' ' |
d67114a5 MH |
886 | git send-email \ |
887 | --dry-run \ | |
888 | --from="Example <nobody@example.com>" \ | |
889 | --to=nobody@example.com \ | |
890 | --thread \ | |
891 | --nochain-reply-to \ | |
892 | $patches $patches >stdout && | |
893 | grep "In-Reply-To: " stdout | |
894 | ' | |
895 | ||
57cd35e6 | 896 | test_expect_success $PREREQ 'warning with an implicit --chain-reply-to' ' |
528fb087 NS |
897 | git send-email \ |
898 | --dry-run \ | |
899 | --from="Example <nobody@example.com>" \ | |
900 | --to=nobody@example.com \ | |
901 | outdir/000?-*.patch 2>errors >out && | |
902 | grep "no-chain-reply-to" errors | |
903 | ' | |
904 | ||
57cd35e6 | 905 | test_expect_success $PREREQ 'no warning with an explicit --chain-reply-to' ' |
528fb087 NS |
906 | git send-email \ |
907 | --dry-run \ | |
908 | --from="Example <nobody@example.com>" \ | |
909 | --to=nobody@example.com \ | |
910 | --chain-reply-to \ | |
911 | outdir/000?-*.patch 2>errors >out && | |
912 | ! grep "no-chain-reply-to" errors | |
913 | ' | |
914 | ||
57cd35e6 | 915 | test_expect_success $PREREQ 'no warning with an explicit --no-chain-reply-to' ' |
528fb087 NS |
916 | git send-email \ |
917 | --dry-run \ | |
918 | --from="Example <nobody@example.com>" \ | |
919 | --to=nobody@example.com \ | |
907a0b1e | 920 | --nochain-reply-to \ |
528fb087 NS |
921 | outdir/000?-*.patch 2>errors >out && |
922 | ! grep "no-chain-reply-to" errors | |
923 | ' | |
924 | ||
57cd35e6 | 925 | test_expect_success $PREREQ 'no warning with sendemail.chainreplyto = false' ' |
528fb087 NS |
926 | git config sendemail.chainreplyto false && |
927 | git send-email \ | |
928 | --dry-run \ | |
929 | --from="Example <nobody@example.com>" \ | |
930 | --to=nobody@example.com \ | |
931 | outdir/000?-*.patch 2>errors >out && | |
932 | ! grep "no-chain-reply-to" errors | |
933 | ' | |
934 | ||
57cd35e6 | 935 | test_expect_success $PREREQ 'no warning with sendemail.chainreplyto = true' ' |
528fb087 NS |
936 | git config sendemail.chainreplyto true && |
937 | git send-email \ | |
938 | --dry-run \ | |
939 | --from="Example <nobody@example.com>" \ | |
940 | --to=nobody@example.com \ | |
941 | outdir/000?-*.patch 2>errors >out && | |
942 | ! grep "no-chain-reply-to" errors | |
943 | ' | |
944 | ||
57cd35e6 | 945 | test_expect_success $PREREQ 'sendemail.to works' ' |
f434c083 SB |
946 | git config --replace-all sendemail.to "Somebody <somebody@ex.com>" && |
947 | git send-email \ | |
948 | --dry-run \ | |
949 | --from="Example <nobody@example.com>" \ | |
950 | $patches $patches >stdout && | |
951 | grep "To: Somebody <somebody@ex.com>" stdout | |
952 | ' | |
953 | ||
57cd35e6 | 954 | test_expect_success $PREREQ '--no-to overrides sendemail.to' ' |
f434c083 SB |
955 | git send-email \ |
956 | --dry-run \ | |
957 | --from="Example <nobody@example.com>" \ | |
958 | --no-to \ | |
959 | --to=nobody@example.com \ | |
960 | $patches $patches >stdout && | |
961 | grep "To: nobody@example.com" stdout && | |
962 | ! grep "To: Somebody <somebody@ex.com>" stdout | |
963 | ' | |
964 | ||
57cd35e6 | 965 | test_expect_success $PREREQ 'sendemail.cc works' ' |
f434c083 SB |
966 | git config --replace-all sendemail.cc "Somebody <somebody@ex.com>" && |
967 | git send-email \ | |
968 | --dry-run \ | |
969 | --from="Example <nobody@example.com>" \ | |
970 | --to=nobody@example.com \ | |
971 | $patches $patches >stdout && | |
972 | grep "Cc: Somebody <somebody@ex.com>" stdout | |
973 | ' | |
974 | ||
57cd35e6 | 975 | test_expect_success $PREREQ '--no-cc overrides sendemail.cc' ' |
f434c083 SB |
976 | git send-email \ |
977 | --dry-run \ | |
978 | --from="Example <nobody@example.com>" \ | |
979 | --no-cc \ | |
980 | --cc=bodies@example.com \ | |
981 | --to=nobody@example.com \ | |
982 | $patches $patches >stdout && | |
983 | grep "Cc: bodies@example.com" stdout && | |
984 | ! grep "Cc: Somebody <somebody@ex.com>" stdout | |
985 | ' | |
986 | ||
57cd35e6 | 987 | test_expect_success $PREREQ 'sendemail.bcc works' ' |
f434c083 SB |
988 | git config --replace-all sendemail.bcc "Other <other@ex.com>" && |
989 | git send-email \ | |
990 | --dry-run \ | |
991 | --from="Example <nobody@example.com>" \ | |
992 | --to=nobody@example.com \ | |
993 | --smtp-server relay.example.com \ | |
994 | $patches $patches >stdout && | |
995 | grep "RCPT TO:<other@ex.com>" stdout | |
996 | ' | |
997 | ||
57cd35e6 | 998 | test_expect_success $PREREQ '--no-bcc overrides sendemail.bcc' ' |
f434c083 SB |
999 | git send-email \ |
1000 | --dry-run \ | |
1001 | --from="Example <nobody@example.com>" \ | |
1002 | --no-bcc \ | |
1003 | --bcc=bodies@example.com \ | |
1004 | --to=nobody@example.com \ | |
1005 | --smtp-server relay.example.com \ | |
1006 | $patches $patches >stdout && | |
1007 | grep "RCPT TO:<bodies@example.com>" stdout && | |
1008 | ! grep "RCPT TO:<other@ex.com>" stdout | |
1009 | ' | |
1010 | ||
21802cd3 SB |
1011 | test_expect_success $PREREQ 'patches To headers are used by default' ' |
1012 | patch=`git format-patch -1 --to="bodies@example.com"` && | |
1013 | test_when_finished "rm $patch" && | |
1014 | git send-email \ | |
1015 | --dry-run \ | |
1016 | --from="Example <nobody@example.com>" \ | |
1017 | --smtp-server relay.example.com \ | |
1018 | $patch >stdout && | |
1019 | grep "RCPT TO:<bodies@example.com>" stdout | |
1020 | ' | |
1021 | ||
1022 | test_expect_success $PREREQ 'patches To headers are appended to' ' | |
1023 | patch=`git format-patch -1 --to="bodies@example.com"` && | |
1024 | test_when_finished "rm $patch" && | |
1025 | git send-email \ | |
1026 | --dry-run \ | |
1027 | --from="Example <nobody@example.com>" \ | |
1028 | --to=nobody@example.com \ | |
1029 | --smtp-server relay.example.com \ | |
1030 | $patch >stdout && | |
1031 | grep "RCPT TO:<bodies@example.com>" stdout && | |
1032 | grep "RCPT TO:<nobody@example.com>" stdout | |
1033 | ' | |
1034 | ||
3c3bb51c SB |
1035 | test_expect_success $PREREQ 'To headers from files reset each patch' ' |
1036 | patch1=`git format-patch -1 --to="bodies@example.com"` && | |
1037 | patch2=`git format-patch -1 --to="other@example.com" HEAD~` && | |
1038 | test_when_finished "rm $patch1 && rm $patch2" && | |
1039 | git send-email \ | |
1040 | --dry-run \ | |
1041 | --from="Example <nobody@example.com>" \ | |
1042 | --to="nobody@example.com" \ | |
1043 | --smtp-server relay.example.com \ | |
1044 | $patch1 $patch2 >stdout && | |
1045 | test $(grep -c "RCPT TO:<bodies@example.com>" stdout) = 1 && | |
1046 | test $(grep -c "RCPT TO:<nobody@example.com>" stdout) = 2 && | |
1047 | test $(grep -c "RCPT TO:<other@example.com>" stdout) = 1 | |
1048 | ' | |
1049 | ||
f9444147 | 1050 | test_expect_success $PREREQ 'setup expect' ' |
3cae7e5b TR |
1051 | cat >email-using-8bit <<EOF |
1052 | From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001 | |
1053 | Message-Id: <bogus-message-id@example.com> | |
1054 | From: author@example.com | |
1055 | Date: Sat, 12 Jun 2010 15:53:58 +0200 | |
1056 | Subject: subject goes here | |
1057 | ||
1058 | Dieser deutsche Text enthält einen Umlaut! | |
1059 | EOF | |
f9444147 | 1060 | ' |
3cae7e5b | 1061 | |
f9444147 | 1062 | test_expect_success $PREREQ 'setup expect' ' |
3cae7e5b TR |
1063 | cat >content-type-decl <<EOF |
1064 | MIME-Version: 1.0 | |
1065 | Content-Type: text/plain; charset=UTF-8 | |
1066 | Content-Transfer-Encoding: 8bit | |
1067 | EOF | |
f9444147 | 1068 | ' |
3cae7e5b | 1069 | |
57cd35e6 | 1070 | test_expect_success $PREREQ 'asks about and fixes 8bit encodings' ' |
3cae7e5b TR |
1071 | clean_fake_sendmail && |
1072 | echo | | |
1073 | git send-email --from=author@example.com --to=nobody@example.com \ | |
1074 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1075 | email-using-8bit >stdout && | |
1076 | grep "do not declare a Content-Transfer-Encoding" stdout && | |
1077 | grep email-using-8bit stdout && | |
1078 | grep "Which 8bit encoding" stdout && | |
31832862 | 1079 | egrep "Content|MIME" msgtxt1 >actual && |
3cae7e5b TR |
1080 | test_cmp actual content-type-decl |
1081 | ' | |
1082 | ||
57cd35e6 | 1083 | test_expect_success $PREREQ 'sendemail.8bitEncoding works' ' |
3cae7e5b TR |
1084 | clean_fake_sendmail && |
1085 | git config sendemail.assume8bitEncoding UTF-8 && | |
1086 | echo bogus | | |
1087 | git send-email --from=author@example.com --to=nobody@example.com \ | |
1088 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1089 | email-using-8bit >stdout && | |
31832862 | 1090 | egrep "Content|MIME" msgtxt1 >actual && |
3cae7e5b TR |
1091 | test_cmp actual content-type-decl |
1092 | ' | |
1093 | ||
57cd35e6 | 1094 | test_expect_success $PREREQ '--8bit-encoding overrides sendemail.8bitEncoding' ' |
3cae7e5b TR |
1095 | clean_fake_sendmail && |
1096 | git config sendemail.assume8bitEncoding "bogus too" && | |
1097 | echo bogus | | |
1098 | git send-email --from=author@example.com --to=nobody@example.com \ | |
1099 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1100 | --8bit-encoding=UTF-8 \ | |
1101 | email-using-8bit >stdout && | |
31832862 | 1102 | egrep "Content|MIME" msgtxt1 >actual && |
3cae7e5b TR |
1103 | test_cmp actual content-type-decl |
1104 | ' | |
1105 | ||
f9444147 | 1106 | test_expect_success $PREREQ 'setup expect' ' |
3cae7e5b TR |
1107 | cat >email-using-8bit <<EOF |
1108 | From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001 | |
1109 | Message-Id: <bogus-message-id@example.com> | |
1110 | From: author@example.com | |
1111 | Date: Sat, 12 Jun 2010 15:53:58 +0200 | |
1112 | Subject: Dieser Betreff enthält auch einen Umlaut! | |
1113 | ||
1114 | Nothing to see here. | |
1115 | EOF | |
f9444147 | 1116 | ' |
3cae7e5b | 1117 | |
f9444147 | 1118 | test_expect_success $PREREQ 'setup expect' ' |
3cae7e5b TR |
1119 | cat >expected <<EOF |
1120 | Subject: =?UTF-8?q?Dieser=20Betreff=20enth=C3=A4lt=20auch=20einen=20Umlaut!?= | |
1121 | EOF | |
f9444147 | 1122 | ' |
3cae7e5b | 1123 | |
57cd35e6 | 1124 | test_expect_success $PREREQ '--8bit-encoding also treats subject' ' |
3cae7e5b TR |
1125 | clean_fake_sendmail && |
1126 | echo bogus | | |
1127 | git send-email --from=author@example.com --to=nobody@example.com \ | |
1128 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1129 | --8bit-encoding=UTF-8 \ | |
1130 | email-using-8bit >stdout && | |
1131 | grep "Subject" msgtxt1 >actual && | |
1132 | test_cmp expected actual | |
1133 | ' | |
1134 | ||
a03bc5b6 TR |
1135 | # Note that the patches in this test are deliberately out of order; we |
1136 | # want to make sure it works even if the cover-letter is not in the | |
1137 | # first mail. | |
57da2042 | 1138 | test_expect_success $PREREQ 'refusing to send cover letter template' ' |
a03bc5b6 TR |
1139 | clean_fake_sendmail && |
1140 | rm -fr outdir && | |
1141 | git format-patch --cover-letter -2 -o outdir && | |
1142 | test_must_fail git send-email \ | |
1143 | --from="Example <nobody@example.com>" \ | |
1144 | --to=nobody@example.com \ | |
1145 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1146 | outdir/0002-*.patch \ | |
1147 | outdir/0000-*.patch \ | |
1148 | outdir/0001-*.patch \ | |
1149 | 2>errors >out && | |
1150 | grep "SUBJECT HERE" errors && | |
1151 | test -z "$(ls msgtxt*)" | |
1152 | ' | |
1153 | ||
57da2042 | 1154 | test_expect_success $PREREQ '--force sends cover letter template anyway' ' |
a03bc5b6 TR |
1155 | clean_fake_sendmail && |
1156 | rm -fr outdir && | |
1157 | git format-patch --cover-letter -2 -o outdir && | |
1158 | git send-email \ | |
1159 | --force \ | |
1160 | --from="Example <nobody@example.com>" \ | |
1161 | --to=nobody@example.com \ | |
1162 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1163 | outdir/0002-*.patch \ | |
1164 | outdir/0000-*.patch \ | |
1165 | outdir/0001-*.patch \ | |
1166 | 2>errors >out && | |
1167 | ! grep "SUBJECT HERE" errors && | |
1168 | test -n "$(ls msgtxt*)" | |
1169 | ' | |
1170 | ||
ce903018 | 1171 | test_done |