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