3 test_description='git send-email'
6 # May be altered later in the test
9 test_expect_success $PREREQ \
10 'prepare reference tree' \
11 'echo "1A quick brown fox jumps over the" >file &&
12 echo "lazy dog" >>file &&
14 GIT_AUTHOR_NAME="A" git commit -a -m "Initial."'
16 test_expect_success $PREREQ \
18 '(echo "#!$SHELL_PATH"
21 echo "while test -f commandline\$output; do output=\$((\$output+1)); done"
24 echo " echo \"!\$a!\""
25 echo "done >commandline\$output"
26 echo "cat > msgtxt\$output"
28 chmod +x ./fake.sendmail &&
29 git add fake.sendmail &&
30 GIT_AUTHOR_NAME="A" git commit -a -m "Second."'
32 clean_fake_sendmail() {
33 rm -f commandline* msgtxt*
36 test_expect_success $PREREQ 'Extract patches' '
37 patches=`git format-patch -s --cc="One <one@example.com>" --cc=two@example.com -n HEAD^1`
40 # Test no confirm early to ensure remaining tests will not hang
44 GIT_SEND_EMAIL_NOTTY=1 \
46 --from="Example <from@example.com>" \
47 --to=nobody@example.com \
48 --smtp-server="$(pwd)/fake.sendmail" \
51 test_must_fail grep "Send this email" stdout &&
55 # Exit immediately to prevent hang if a no-confirm test fails
57 if ! test -f no_confirm_okay
59 say 'confirm test failed; skipping remaining tests to prevent hanging'
60 PREREQ="$PREREQ,CHECK_NO_CONFIRM"
65 test_expect_success $PREREQ 'No confirm with --suppress-cc' '
66 test_no_confirm --suppress-cc=sob &&
71 test_expect_success $PREREQ 'No confirm with --confirm=never' '
72 test_no_confirm --confirm=never &&
76 # leave sendemail.confirm set to never after this so that none of the
77 # remaining tests prompt unintentionally.
78 test_expect_success $PREREQ 'No confirm with sendemail.confirm=never' '
79 git config sendemail.confirm never &&
80 test_no_confirm --compose --subject=foo &&
84 test_expect_success $PREREQ '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 test_expect_success $PREREQ 'setup expect' '
97 test_expect_success $PREREQ \
98 'Verify commandline' \
99 'test_cmp expected commandline1'
101 test_expect_success $PREREQ 'Send patches with --envelope-sender' '
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
106 test_expect_success $PREREQ 'setup expect' '
117 test_expect_success $PREREQ \
118 'Verify commandline' \
119 'test_cmp expected commandline1'
121 test_expect_success $PREREQ 'Send patches with --envelope-sender=auto' '
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
126 test_expect_success $PREREQ 'setup expect' '
137 test_expect_success $PREREQ \
138 'Verify commandline' \
139 'test_cmp expected commandline1'
141 test_expect_success $PREREQ 'setup expect' "
142 cat >expected-show-all-headers <<\EOF
144 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
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'
148 Server: relay.example.com
149 MAIL FROM:<from@example.com>
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>
156 From: Example <from@example.com>
159 A <author@example.com>,
160 One <one@example.com>,
162 Subject: [PATCH 1/1] Second.
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>
173 test_expect_success $PREREQ 'Show all headers' '
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 \
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 &&
188 test_cmp expected-show-all-headers actual-show-all-headers
191 test_expect_success $PREREQ 'Prompting works' '
192 clean_fake_sendmail &&
193 (echo "Example <from@example.com>"
194 echo "to@example.com"
196 ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
197 --smtp-server="$(pwd)/fake.sendmail" \
200 grep "^From: Example <from@example.com>\$" msgtxt1 &&
201 grep "^To: to@example.com\$" msgtxt1
204 test_expect_success $PREREQ 'tocmd works' '
205 clean_fake_sendmail &&
206 cp $patches tocmd.patch &&
207 echo tocmd--tocmd@example.com >>tocmd.patch &&
210 echo sed -n -e s/^tocmd--//p \"\$1\"
212 chmod +x tocmd-sed &&
214 --from="Example <nobody@example.com>" \
215 --to-cmd=./tocmd-sed \
216 --smtp-server="$(pwd)/fake.sendmail" \
219 grep "^To: tocmd@example.com" msgtxt1
222 test_expect_success $PREREQ 'cccmd works' '
223 clean_fake_sendmail &&
224 cp $patches cccmd.patch &&
225 echo cccmd--cccmd@example.com >>cccmd.patch &&
228 echo sed -n -e s/^cccmd--//p \"\$1\"
230 chmod +x cccmd-sed &&
232 --from="Example <nobody@example.com>" \
233 --to=nobody@example.com \
234 --cc-cmd=./cccmd-sed \
235 --smtp-server="$(pwd)/fake.sendmail" \
238 grep "^ cccmd@example.com" msgtxt1
241 test_expect_success $PREREQ 'reject long lines' '
243 z64=$z8$z8$z8$z8$z8$z8$z8$z8 &&
244 z512=$z64$z64$z64$z64$z64$z64$z64$z64 &&
245 clean_fake_sendmail &&
246 cp $patches longline.patch &&
247 echo $z512$z512 >>longline.patch &&
248 test_must_fail git send-email \
249 --from="Example <nobody@example.com>" \
250 --to=nobody@example.com \
251 --smtp-server="$(pwd)/fake.sendmail" \
252 $patches longline.patch \
254 grep longline.patch errors
257 test_expect_success $PREREQ 'no patch was sent' '
258 ! test -e commandline1
261 test_expect_success $PREREQ 'Author From: in message body' '
262 clean_fake_sendmail &&
264 --from="Example <nobody@example.com>" \
265 --to=nobody@example.com \
266 --smtp-server="$(pwd)/fake.sendmail" \
268 sed "1,/^\$/d" < msgtxt1 > msgbody1
269 grep "From: A <author@example.com>" msgbody1
272 test_expect_success $PREREQ 'Author From: not in message body' '
273 clean_fake_sendmail &&
275 --from="A <author@example.com>" \
276 --to=nobody@example.com \
277 --smtp-server="$(pwd)/fake.sendmail" \
279 sed "1,/^\$/d" < msgtxt1 > msgbody1
280 ! grep "From: A <author@example.com>" msgbody1
283 test_expect_success $PREREQ 'allow long lines with --no-validate' '
285 --from="Example <nobody@example.com>" \
286 --to=nobody@example.com \
287 --smtp-server="$(pwd)/fake.sendmail" \
289 $patches longline.patch \
293 test_expect_success $PREREQ 'Invalid In-Reply-To' '
294 clean_fake_sendmail &&
296 --from="Example <nobody@example.com>" \
297 --to=nobody@example.com \
299 --smtp-server="$(pwd)/fake.sendmail" \
302 ! grep "^In-Reply-To: < *>" msgtxt1
305 test_expect_success $PREREQ 'Valid In-Reply-To when prompting' '
306 clean_fake_sendmail &&
307 (echo "From Example <from@example.com>"
308 echo "To Example <to@example.com>"
310 ) | env GIT_SEND_EMAIL_NOTTY=1 git send-email \
311 --smtp-server="$(pwd)/fake.sendmail" \
313 ! grep "^In-Reply-To: < *>" msgtxt1
316 test_expect_success $PREREQ 'setup fake editor' '
317 (echo "#!$SHELL_PATH" &&
318 echo "echo fake edit >>\"\$1\""
323 test_set_editor "$(pwd)/fake-editor"
325 test_expect_success $PREREQ '--compose works' '
326 clean_fake_sendmail &&
328 --compose --subject foo \
329 --from="Example <nobody@example.com>" \
330 --to=nobody@example.com \
331 --smtp-server="$(pwd)/fake.sendmail" \
336 test_expect_success $PREREQ 'first message is compose text' '
337 grep "^fake edit" msgtxt1
340 test_expect_success $PREREQ 'second message is patch' '
341 grep "Subject:.*Second" msgtxt2
344 test_expect_success $PREREQ 'setup expect' "
345 cat >expected-suppress-sob <<\EOF
347 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
348 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
349 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
351 Server: relay.example.com
352 MAIL FROM:<from@example.com>
353 RCPT TO:<to@example.com>
354 RCPT TO:<cc@example.com>
355 RCPT TO:<author@example.com>
356 RCPT TO:<one@example.com>
357 RCPT TO:<two@example.com>
358 From: Example <from@example.com>
361 A <author@example.com>,
362 One <one@example.com>,
364 Subject: [PATCH 1/1] Second.
366 Message-Id: MESSAGE-ID-STRING
367 X-Mailer: X-MAILER-STRING
373 test_suppression () {
376 --suppress-cc=$1 ${2+"--suppress-cc=$2"} \
377 --from="Example <from@example.com>" \
378 --to=to@example.com \
379 --smtp-server relay.example.com \
381 sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
382 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
383 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
384 >actual-suppress-$1${2+"-$2"} &&
385 test_cmp expected-suppress-$1${2+"-$2"} actual-suppress-$1${2+"-$2"}
388 test_expect_success $PREREQ 'sendemail.cc set' '
389 git config sendemail.cc cc@example.com &&
393 test_expect_success $PREREQ 'setup expect' "
394 cat >expected-suppress-sob <<\EOF
396 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
397 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
398 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
400 Server: relay.example.com
401 MAIL FROM:<from@example.com>
402 RCPT TO:<to@example.com>
403 RCPT TO:<author@example.com>
404 RCPT TO:<one@example.com>
405 RCPT TO:<two@example.com>
406 From: Example <from@example.com>
408 Cc: A <author@example.com>,
409 One <one@example.com>,
411 Subject: [PATCH 1/1] Second.
413 Message-Id: MESSAGE-ID-STRING
414 X-Mailer: X-MAILER-STRING
420 test_expect_success $PREREQ 'sendemail.cc unset' '
421 git config --unset sendemail.cc &&
425 test_expect_success $PREREQ 'setup expect' "
426 cat >expected-suppress-cccmd <<\EOF
428 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
429 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
430 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
431 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
433 Server: relay.example.com
434 MAIL FROM:<from@example.com>
435 RCPT TO:<to@example.com>
436 RCPT TO:<author@example.com>
437 RCPT TO:<one@example.com>
438 RCPT TO:<two@example.com>
439 RCPT TO:<committer@example.com>
440 From: Example <from@example.com>
442 Cc: A <author@example.com>,
443 One <one@example.com>,
445 C O Mitter <committer@example.com>
446 Subject: [PATCH 1/1] Second.
448 Message-Id: MESSAGE-ID-STRING
449 X-Mailer: X-MAILER-STRING
455 test_expect_success $PREREQ 'sendemail.cccmd' '
456 echo echo cc-cmd@example.com > cccmd &&
458 git config sendemail.cccmd ./cccmd &&
459 test_suppression cccmd
462 test_expect_success $PREREQ 'setup expect' '
463 cat >expected-suppress-all <<\EOF
466 Server: relay.example.com
467 MAIL FROM:<from@example.com>
468 RCPT TO:<to@example.com>
469 From: Example <from@example.com>
471 Subject: [PATCH 1/1] Second.
473 Message-Id: MESSAGE-ID-STRING
474 X-Mailer: X-MAILER-STRING
480 test_expect_success $PREREQ '--suppress-cc=all' '
484 test_expect_success $PREREQ 'setup expect' "
485 cat >expected-suppress-body <<\EOF
487 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
488 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
489 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
490 (cc-cmd) Adding cc: cc-cmd@example.com from: './cccmd'
492 Server: relay.example.com
493 MAIL FROM:<from@example.com>
494 RCPT TO:<to@example.com>
495 RCPT TO:<author@example.com>
496 RCPT TO:<one@example.com>
497 RCPT TO:<two@example.com>
498 RCPT TO:<cc-cmd@example.com>
499 From: Example <from@example.com>
501 Cc: A <author@example.com>,
502 One <one@example.com>,
505 Subject: [PATCH 1/1] Second.
507 Message-Id: MESSAGE-ID-STRING
508 X-Mailer: X-MAILER-STRING
514 test_expect_success $PREREQ '--suppress-cc=body' '
515 test_suppression body
518 test_expect_success $PREREQ 'setup expect' "
519 cat >expected-suppress-body-cccmd <<\EOF
521 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
522 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
523 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
525 Server: relay.example.com
526 MAIL FROM:<from@example.com>
527 RCPT TO:<to@example.com>
528 RCPT TO:<author@example.com>
529 RCPT TO:<one@example.com>
530 RCPT TO:<two@example.com>
531 From: Example <from@example.com>
533 Cc: A <author@example.com>,
534 One <one@example.com>,
536 Subject: [PATCH 1/1] Second.
538 Message-Id: MESSAGE-ID-STRING
539 X-Mailer: X-MAILER-STRING
545 test_expect_success $PREREQ '--suppress-cc=body --suppress-cc=cccmd' '
546 test_suppression body cccmd
549 test_expect_success $PREREQ 'setup expect' "
550 cat >expected-suppress-sob <<\EOF
552 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
553 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
554 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
556 Server: relay.example.com
557 MAIL FROM:<from@example.com>
558 RCPT TO:<to@example.com>
559 RCPT TO:<author@example.com>
560 RCPT TO:<one@example.com>
561 RCPT TO:<two@example.com>
562 From: Example <from@example.com>
564 Cc: A <author@example.com>,
565 One <one@example.com>,
567 Subject: [PATCH 1/1] Second.
569 Message-Id: MESSAGE-ID-STRING
570 X-Mailer: X-MAILER-STRING
576 test_expect_success $PREREQ '--suppress-cc=sob' '
577 git config --unset sendemail.cccmd
581 test_expect_success $PREREQ 'setup expect' "
582 cat >expected-suppress-bodycc <<\EOF
584 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
585 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
586 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
587 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
589 Server: relay.example.com
590 MAIL FROM:<from@example.com>
591 RCPT TO:<to@example.com>
592 RCPT TO:<author@example.com>
593 RCPT TO:<one@example.com>
594 RCPT TO:<two@example.com>
595 RCPT TO:<committer@example.com>
596 From: Example <from@example.com>
598 Cc: A <author@example.com>,
599 One <one@example.com>,
601 C O Mitter <committer@example.com>
602 Subject: [PATCH 1/1] Second.
604 Message-Id: MESSAGE-ID-STRING
605 X-Mailer: X-MAILER-STRING
611 test_expect_success $PREREQ '--suppress-cc=bodycc' '
612 test_suppression bodycc
615 test_expect_success $PREREQ 'setup expect' "
616 cat >expected-suppress-cc <<\EOF
618 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
619 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
621 Server: relay.example.com
622 MAIL FROM:<from@example.com>
623 RCPT TO:<to@example.com>
624 RCPT TO:<author@example.com>
625 RCPT TO:<committer@example.com>
626 From: Example <from@example.com>
628 Cc: A <author@example.com>,
629 C O Mitter <committer@example.com>
630 Subject: [PATCH 1/1] Second.
632 Message-Id: MESSAGE-ID-STRING
633 X-Mailer: X-MAILER-STRING
639 test_expect_success $PREREQ '--suppress-cc=cc' '
645 GIT_SEND_EMAIL_NOTTY=1 \
647 --from="Example <nobody@example.com>" \
648 --to=nobody@example.com \
649 --smtp-server="$(pwd)/fake.sendmail" \
650 $@ $patches > stdout &&
651 grep "Send this email" stdout
654 test_expect_success $PREREQ '--confirm=always' '
655 test_confirm --confirm=always --suppress-cc=all
658 test_expect_success $PREREQ '--confirm=auto' '
659 test_confirm --confirm=auto
662 test_expect_success $PREREQ '--confirm=cc' '
663 test_confirm --confirm=cc
666 test_expect_success $PREREQ '--confirm=compose' '
667 test_confirm --confirm=compose --compose
670 test_expect_success $PREREQ 'confirm by default (due to cc)' '
671 CONFIRM=$(git config --get sendemail.confirm) &&
672 git config --unset sendemail.confirm &&
675 git config sendemail.confirm ${CONFIRM:-never}
679 test_expect_success $PREREQ 'confirm by default (due to --compose)' '
680 CONFIRM=$(git config --get sendemail.confirm) &&
681 git config --unset sendemail.confirm &&
682 test_confirm --suppress-cc=all --compose
684 git config sendemail.confirm ${CONFIRM:-never}
688 test_expect_success $PREREQ 'confirm detects EOF (inform assumes y)' '
689 CONFIRM=$(git config --get sendemail.confirm) &&
690 git config --unset sendemail.confirm &&
692 git format-patch -2 -o outdir &&
693 GIT_SEND_EMAIL_NOTTY=1 \
695 --from="Example <nobody@example.com>" \
696 --to=nobody@example.com \
697 --smtp-server="$(pwd)/fake.sendmail" \
698 outdir/*.patch < /dev/null
700 git config sendemail.confirm ${CONFIRM:-never}
704 test_expect_success $PREREQ 'confirm detects EOF (auto causes failure)' '
705 CONFIRM=$(git config --get sendemail.confirm) &&
706 git config sendemail.confirm auto &&
707 GIT_SEND_EMAIL_NOTTY=1 &&
708 export GIT_SEND_EMAIL_NOTTY &&
709 test_must_fail git send-email \
710 --from="Example <nobody@example.com>" \
711 --to=nobody@example.com \
712 --smtp-server="$(pwd)/fake.sendmail" \
715 git config sendemail.confirm ${CONFIRM:-never}
719 test_expect_success $PREREQ 'confirm doesnt loop forever' '
720 CONFIRM=$(git config --get sendemail.confirm) &&
721 git config sendemail.confirm auto &&
722 GIT_SEND_EMAIL_NOTTY=1 &&
723 export GIT_SEND_EMAIL_NOTTY &&
724 yes "bogus" | test_must_fail git send-email \
725 --from="Example <nobody@example.com>" \
726 --to=nobody@example.com \
727 --smtp-server="$(pwd)/fake.sendmail" \
730 git config sendemail.confirm ${CONFIRM:-never}
734 test_expect_success $PREREQ 'utf8 Cc is rfc2047 encoded' '
735 clean_fake_sendmail &&
737 git format-patch -1 -o outdir --cc="àéìöú <utf8@example.com>" &&
739 --from="Example <nobody@example.com>" \
740 --to=nobody@example.com \
741 --smtp-server="$(pwd)/fake.sendmail" \
744 grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>"
747 test_expect_success $PREREQ '--compose adds MIME for utf8 body' '
748 clean_fake_sendmail &&
749 (echo "#!$SHELL_PATH" &&
750 echo "echo utf8 body: àéìöú >>\"\$1\""
751 ) >fake-editor-utf8 &&
752 chmod +x fake-editor-utf8 &&
753 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
755 --compose --subject foo \
756 --from="Example <nobody@example.com>" \
757 --to=nobody@example.com \
758 --smtp-server="$(pwd)/fake.sendmail" \
760 grep "^utf8 body" msgtxt1 &&
761 grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
764 test_expect_success $PREREQ '--compose respects user mime type' '
765 clean_fake_sendmail &&
766 (echo "#!$SHELL_PATH" &&
767 echo "(echo MIME-Version: 1.0"
768 echo " echo Content-Type: text/plain\\; charset=iso-8859-1"
769 echo " echo Content-Transfer-Encoding: 8bit"
770 echo " echo Subject: foo"
772 echo " echo utf8 body: àéìöú) >\"\$1\""
773 ) >fake-editor-utf8-mime &&
774 chmod +x fake-editor-utf8-mime &&
775 GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \
777 --compose --subject foo \
778 --from="Example <nobody@example.com>" \
779 --to=nobody@example.com \
780 --smtp-server="$(pwd)/fake.sendmail" \
782 grep "^utf8 body" msgtxt1 &&
783 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 &&
784 ! grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
787 test_expect_success $PREREQ '--compose adds MIME for utf8 subject' '
788 clean_fake_sendmail &&
789 GIT_EDITOR="\"$(pwd)/fake-editor\"" \
791 --compose --subject utf8-sübjëct \
792 --from="Example <nobody@example.com>" \
793 --to=nobody@example.com \
794 --smtp-server="$(pwd)/fake.sendmail" \
796 grep "^fake edit" msgtxt1 &&
797 grep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
800 test_expect_success $PREREQ 'detects ambiguous reference/file conflict' '
801 echo master > master &&
803 git commit -m"add master" &&
804 test_must_fail git send-email --dry-run master 2>errors &&
805 grep disambiguate errors
808 test_expect_success $PREREQ 'feed two files' '
810 git format-patch -2 -o outdir &&
813 --from="Example <nobody@example.com>" \
814 --to=nobody@example.com \
815 outdir/000?-*.patch 2>errors >out &&
816 grep "^Subject: " out >subjects &&
817 test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." &&
818 test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add master"
821 test_expect_success $PREREQ 'in-reply-to but no threading' '
824 --from="Example <nobody@example.com>" \
825 --to=nobody@example.com \
826 --in-reply-to="<in-reply-id@example.com>" \
829 grep "In-Reply-To: <in-reply-id@example.com>"
832 test_expect_success $PREREQ 'no in-reply-to and no threading' '
835 --from="Example <nobody@example.com>" \
836 --to=nobody@example.com \
838 $patches $patches >stdout &&
839 ! grep "In-Reply-To: " stdout
842 test_expect_success $PREREQ 'threading but no chain-reply-to' '
845 --from="Example <nobody@example.com>" \
846 --to=nobody@example.com \
849 $patches $patches >stdout &&
850 grep "In-Reply-To: " stdout
853 test_expect_success $PREREQ 'warning with an implicit --chain-reply-to' '
856 --from="Example <nobody@example.com>" \
857 --to=nobody@example.com \
858 outdir/000?-*.patch 2>errors >out &&
859 grep "no-chain-reply-to" errors
862 test_expect_success $PREREQ 'no warning with an explicit --chain-reply-to' '
865 --from="Example <nobody@example.com>" \
866 --to=nobody@example.com \
868 outdir/000?-*.patch 2>errors >out &&
869 ! grep "no-chain-reply-to" errors
872 test_expect_success $PREREQ 'no warning with an explicit --no-chain-reply-to' '
875 --from="Example <nobody@example.com>" \
876 --to=nobody@example.com \
878 outdir/000?-*.patch 2>errors >out &&
879 ! grep "no-chain-reply-to" errors
882 test_expect_success $PREREQ 'no warning with sendemail.chainreplyto = false' '
883 git config sendemail.chainreplyto false &&
886 --from="Example <nobody@example.com>" \
887 --to=nobody@example.com \
888 outdir/000?-*.patch 2>errors >out &&
889 ! grep "no-chain-reply-to" errors
892 test_expect_success $PREREQ 'no warning with sendemail.chainreplyto = true' '
893 git config sendemail.chainreplyto true &&
896 --from="Example <nobody@example.com>" \
897 --to=nobody@example.com \
898 outdir/000?-*.patch 2>errors >out &&
899 ! grep "no-chain-reply-to" errors
902 test_expect_success $PREREQ 'sendemail.to works' '
903 git config --replace-all sendemail.to "Somebody <somebody@ex.com>" &&
906 --from="Example <nobody@example.com>" \
907 $patches $patches >stdout &&
908 grep "To: Somebody <somebody@ex.com>" stdout
911 test_expect_success $PREREQ '--no-to overrides sendemail.to' '
914 --from="Example <nobody@example.com>" \
916 --to=nobody@example.com \
917 $patches $patches >stdout &&
918 grep "To: nobody@example.com" stdout &&
919 ! grep "To: Somebody <somebody@ex.com>" stdout
922 test_expect_success $PREREQ 'sendemail.cc works' '
923 git config --replace-all sendemail.cc "Somebody <somebody@ex.com>" &&
926 --from="Example <nobody@example.com>" \
927 --to=nobody@example.com \
928 $patches $patches >stdout &&
929 grep "Cc: Somebody <somebody@ex.com>" stdout
932 test_expect_success $PREREQ '--no-cc overrides sendemail.cc' '
935 --from="Example <nobody@example.com>" \
937 --cc=bodies@example.com \
938 --to=nobody@example.com \
939 $patches $patches >stdout &&
940 grep "Cc: bodies@example.com" stdout &&
941 ! grep "Cc: Somebody <somebody@ex.com>" stdout
944 test_expect_success $PREREQ 'sendemail.bcc works' '
945 git config --replace-all sendemail.bcc "Other <other@ex.com>" &&
948 --from="Example <nobody@example.com>" \
949 --to=nobody@example.com \
950 --smtp-server relay.example.com \
951 $patches $patches >stdout &&
952 grep "RCPT TO:<other@ex.com>" stdout
955 test_expect_success $PREREQ '--no-bcc overrides sendemail.bcc' '
958 --from="Example <nobody@example.com>" \
960 --bcc=bodies@example.com \
961 --to=nobody@example.com \
962 --smtp-server relay.example.com \
963 $patches $patches >stdout &&
964 grep "RCPT TO:<bodies@example.com>" stdout &&
965 ! grep "RCPT TO:<other@ex.com>" stdout
968 test_expect_success $PREREQ 'setup expect' '
969 cat >email-using-8bit <<EOF
970 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
971 Message-Id: <bogus-message-id@example.com>
972 From: author@example.com
973 Date: Sat, 12 Jun 2010 15:53:58 +0200
974 Subject: subject goes here
976 Dieser deutsche Text enthält einen Umlaut!
980 test_expect_success $PREREQ 'setup expect' '
981 cat >content-type-decl <<EOF
983 Content-Type: text/plain; charset=UTF-8
984 Content-Transfer-Encoding: 8bit
988 test_expect_success $PREREQ 'asks about and fixes 8bit encodings' '
989 clean_fake_sendmail &&
991 git send-email --from=author@example.com --to=nobody@example.com \
992 --smtp-server="$(pwd)/fake.sendmail" \
993 email-using-8bit >stdout &&
994 grep "do not declare a Content-Transfer-Encoding" stdout &&
995 grep email-using-8bit stdout &&
996 grep "Which 8bit encoding" stdout &&
997 egrep "Content|MIME" msgtxt1 >actual &&
998 test_cmp actual content-type-decl
1001 test_expect_success $PREREQ 'sendemail.8bitEncoding works' '
1002 clean_fake_sendmail &&
1003 git config sendemail.assume8bitEncoding UTF-8 &&
1005 git send-email --from=author@example.com --to=nobody@example.com \
1006 --smtp-server="$(pwd)/fake.sendmail" \
1007 email-using-8bit >stdout &&
1008 egrep "Content|MIME" msgtxt1 >actual &&
1009 test_cmp actual content-type-decl
1012 test_expect_success $PREREQ '--8bit-encoding overrides sendemail.8bitEncoding' '
1013 clean_fake_sendmail &&
1014 git config sendemail.assume8bitEncoding "bogus too" &&
1016 git send-email --from=author@example.com --to=nobody@example.com \
1017 --smtp-server="$(pwd)/fake.sendmail" \
1018 --8bit-encoding=UTF-8 \
1019 email-using-8bit >stdout &&
1020 egrep "Content|MIME" msgtxt1 >actual &&
1021 test_cmp actual content-type-decl
1024 test_expect_success $PREREQ 'setup expect' '
1025 cat >email-using-8bit <<EOF
1026 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1027 Message-Id: <bogus-message-id@example.com>
1028 From: author@example.com
1029 Date: Sat, 12 Jun 2010 15:53:58 +0200
1030 Subject: Dieser Betreff enthält auch einen Umlaut!
1032 Nothing to see here.
1036 test_expect_success $PREREQ 'setup expect' '
1038 Subject: =?UTF-8?q?Dieser=20Betreff=20enth=C3=A4lt=20auch=20einen=20Umlaut!?=
1042 test_expect_success $PREREQ '--8bit-encoding also treats subject' '
1043 clean_fake_sendmail &&
1045 git send-email --from=author@example.com --to=nobody@example.com \
1046 --smtp-server="$(pwd)/fake.sendmail" \
1047 --8bit-encoding=UTF-8 \
1048 email-using-8bit >stdout &&
1049 grep "Subject" msgtxt1 >actual &&
1050 test_cmp expected actual