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_text 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_text 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_text 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_text 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 'In-Reply-To without --chain-reply-to' '
317 clean_fake_sendmail &&
318 echo "<unique-message-id@example.com>" >expect &&
320 --from="Example <nobody@example.com>" \
321 --to=nobody@example.com \
323 --in-reply-to="$(cat expect)" \
324 --smtp-server="$(pwd)/fake.sendmail" \
325 $patches $patches $patches \
327 # The first message is a reply to --in-reply-to
328 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual &&
329 test_cmp_text expect actual &&
330 # Second and subsequent messages are replies to the first one
331 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect &&
332 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual &&
333 test_cmp_text expect actual &&
334 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual &&
335 test_cmp_text expect actual
338 test_expect_success
$PREREQ 'In-Reply-To with --chain-reply-to' '
339 clean_fake_sendmail &&
340 echo "<unique-message-id@example.com>" >expect &&
342 --from="Example <nobody@example.com>" \
343 --to=nobody@example.com \
345 --in-reply-to="$(cat expect)" \
346 --smtp-server="$(pwd)/fake.sendmail" \
347 $patches $patches $patches \
349 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual &&
350 test_cmp_text 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_text 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_text expect actual
359 test_expect_success
$PREREQ 'setup fake editor' '
360 (echo "#!$SHELL_PATH" &&
361 echo "echo fake edit >>\"\$1\""
366 test_set_editor
"$(pwd)/fake-editor"
368 test_expect_success
$PREREQ '--compose works' '
369 clean_fake_sendmail &&
371 --compose --subject foo \
372 --from="Example <nobody@example.com>" \
373 --to=nobody@example.com \
374 --smtp-server="$(pwd)/fake.sendmail" \
379 test_expect_success
$PREREQ 'first message is compose text' '
380 grep "^fake edit" msgtxt1
383 test_expect_success
$PREREQ 'second message is patch' '
384 grep "Subject:.*Second" msgtxt2
387 test_expect_success
$PREREQ 'setup expect' "
388 cat >expected-suppress-sob <<\EOF
390 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
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'
394 Server: relay.example.com
395 MAIL FROM:<from@example.com>
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>
401 From: Example <from@example.com>
404 A <author@example.com>,
405 One <one@example.com>,
407 Subject: [PATCH 1/1] Second.
409 Message-Id: MESSAGE-ID-STRING
410 X-Mailer: X-MAILER-STRING
416 test_suppression
() {
419 --suppress-cc=$1 ${2+"--suppress-cc=$2"} \
420 --from="Example <from@example.com>" \
421 --to=to@example.com \
422 --smtp-server relay.example.com \
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/" \
427 >actual-suppress-
$1${2+"-$2"} &&
428 test_cmp_text expected-suppress-
$1${2+"-$2"} actual-suppress-
$1${2+"-$2"}
431 test_expect_success
$PREREQ 'sendemail.cc set' '
432 git config sendemail.cc cc@example.com &&
436 test_expect_success
$PREREQ 'setup expect' "
437 cat >expected-suppress-sob <<\EOF
439 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
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'
443 Server: relay.example.com
444 MAIL FROM:<from@example.com>
445 RCPT TO:<to@example.com>
446 RCPT TO:<author@example.com>
447 RCPT TO:<one@example.com>
448 RCPT TO:<two@example.com>
449 From: Example <from@example.com>
451 Cc: A <author@example.com>,
452 One <one@example.com>,
454 Subject: [PATCH 1/1] Second.
456 Message-Id: MESSAGE-ID-STRING
457 X-Mailer: X-MAILER-STRING
463 test_expect_success
$PREREQ 'sendemail.cc unset' '
464 git config --unset sendemail.cc &&
468 test_expect_success
$PREREQ 'setup expect' "
469 cat >expected-suppress-cccmd <<\EOF
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>'
476 Server: relay.example.com
477 MAIL FROM:<from@example.com>
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>
483 From: Example <from@example.com>
485 Cc: A <author@example.com>,
486 One <one@example.com>,
488 C O Mitter <committer@example.com>
489 Subject: [PATCH 1/1] Second.
491 Message-Id: MESSAGE-ID-STRING
492 X-Mailer: X-MAILER-STRING
498 test_expect_success
$PREREQ 'sendemail.cccmd' '
499 echo echo cc-cmd@example.com > cccmd &&
501 git config sendemail.cccmd ./cccmd &&
502 test_suppression cccmd
505 test_expect_success
$PREREQ 'setup expect' '
506 cat >expected-suppress-all <<\EOF
509 Server: relay.example.com
510 MAIL FROM:<from@example.com>
511 RCPT TO:<to@example.com>
512 From: Example <from@example.com>
514 Subject: [PATCH 1/1] Second.
516 Message-Id: MESSAGE-ID-STRING
517 X-Mailer: X-MAILER-STRING
523 test_expect_success
$PREREQ '--suppress-cc=all' '
527 test_expect_success
$PREREQ 'setup expect' "
528 cat >expected-suppress-body <<\EOF
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'
533 (cc-cmd) Adding cc: cc-cmd@example.com from: './cccmd'
535 Server: relay.example.com
536 MAIL FROM:<from@example.com>
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>
542 From: Example <from@example.com>
544 Cc: A <author@example.com>,
545 One <one@example.com>,
548 Subject: [PATCH 1/1] Second.
550 Message-Id: MESSAGE-ID-STRING
551 X-Mailer: X-MAILER-STRING
557 test_expect_success
$PREREQ '--suppress-cc=body' '
558 test_suppression body
561 test_expect_success
$PREREQ 'setup expect' "
562 cat >expected-suppress-body-cccmd <<\EOF
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'
568 Server: relay.example.com
569 MAIL FROM:<from@example.com>
570 RCPT TO:<to@example.com>
571 RCPT TO:<author@example.com>
572 RCPT TO:<one@example.com>
573 RCPT TO:<two@example.com>
574 From: Example <from@example.com>
576 Cc: A <author@example.com>,
577 One <one@example.com>,
579 Subject: [PATCH 1/1] Second.
581 Message-Id: MESSAGE-ID-STRING
582 X-Mailer: X-MAILER-STRING
588 test_expect_success
$PREREQ '--suppress-cc=body --suppress-cc=cccmd' '
589 test_suppression body cccmd
592 test_expect_success
$PREREQ 'setup expect' "
593 cat >expected-suppress-sob <<\EOF
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'
599 Server: relay.example.com
600 MAIL FROM:<from@example.com>
601 RCPT TO:<to@example.com>
602 RCPT TO:<author@example.com>
603 RCPT TO:<one@example.com>
604 RCPT TO:<two@example.com>
605 From: Example <from@example.com>
607 Cc: A <author@example.com>,
608 One <one@example.com>,
610 Subject: [PATCH 1/1] Second.
612 Message-Id: MESSAGE-ID-STRING
613 X-Mailer: X-MAILER-STRING
619 test_expect_success
$PREREQ '--suppress-cc=sob' '
620 test_might_fail git config --unset sendemail.cccmd &&
624 test_expect_success
$PREREQ 'setup expect' "
625 cat >expected-suppress-bodycc <<\EOF
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>'
632 Server: relay.example.com
633 MAIL FROM:<from@example.com>
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>
639 From: Example <from@example.com>
641 Cc: A <author@example.com>,
642 One <one@example.com>,
644 C O Mitter <committer@example.com>
645 Subject: [PATCH 1/1] Second.
647 Message-Id: MESSAGE-ID-STRING
648 X-Mailer: X-MAILER-STRING
654 test_expect_success
$PREREQ '--suppress-cc=bodycc' '
655 test_suppression bodycc
658 test_expect_success
$PREREQ 'setup expect' "
659 cat >expected-suppress-cc <<\EOF
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>'
664 Server: relay.example.com
665 MAIL FROM:<from@example.com>
666 RCPT TO:<to@example.com>
667 RCPT TO:<author@example.com>
668 RCPT TO:<committer@example.com>
669 From: Example <from@example.com>
671 Cc: A <author@example.com>,
672 C O Mitter <committer@example.com>
673 Subject: [PATCH 1/1] Second.
675 Message-Id: MESSAGE-ID-STRING
676 X-Mailer: X-MAILER-STRING
682 test_expect_success
$PREREQ '--suppress-cc=cc' '
688 GIT_SEND_EMAIL_NOTTY
=1 \
690 --from="Example <nobody@example.com>" \
691 --to=nobody@example.com \
692 --smtp-server="$(pwd)/fake.sendmail" \
693 $@
$patches > stdout
&&
694 grep "Send this email" stdout
697 test_expect_success
$PREREQ '--confirm=always' '
698 test_confirm --confirm=always --suppress-cc=all
701 test_expect_success
$PREREQ '--confirm=auto' '
702 test_confirm --confirm=auto
705 test_expect_success
$PREREQ '--confirm=cc' '
706 test_confirm --confirm=cc
709 test_expect_success
$PREREQ '--confirm=compose' '
710 test_confirm --confirm=compose --compose
713 test_expect_success
$PREREQ 'confirm by default (due to cc)' '
714 CONFIRM=$(git config --get sendemail.confirm) &&
715 git config --unset sendemail.confirm &&
718 git config sendemail.confirm ${CONFIRM:-never}
722 test_expect_success
$PREREQ 'confirm by default (due to --compose)' '
723 CONFIRM=$(git config --get sendemail.confirm) &&
724 git config --unset sendemail.confirm &&
725 test_confirm --suppress-cc=all --compose
727 git config sendemail.confirm ${CONFIRM:-never}
731 test_expect_success
$PREREQ 'confirm detects EOF (inform assumes y)' '
732 CONFIRM=$(git config --get sendemail.confirm) &&
733 git config --unset sendemail.confirm &&
735 git format-patch -2 -o outdir &&
736 GIT_SEND_EMAIL_NOTTY=1 \
738 --from="Example <nobody@example.com>" \
739 --to=nobody@example.com \
740 --smtp-server="$(pwd)/fake.sendmail" \
741 outdir/*.patch < /dev/null
743 git config sendemail.confirm ${CONFIRM:-never}
747 test_expect_success
$PREREQ 'confirm detects EOF (auto causes failure)' '
748 CONFIRM=$(git config --get sendemail.confirm) &&
749 git config sendemail.confirm auto &&
750 GIT_SEND_EMAIL_NOTTY=1 &&
751 export GIT_SEND_EMAIL_NOTTY &&
752 test_must_fail git send-email \
753 --from="Example <nobody@example.com>" \
754 --to=nobody@example.com \
755 --smtp-server="$(pwd)/fake.sendmail" \
758 git config sendemail.confirm ${CONFIRM:-never}
762 test_expect_success
$PREREQ 'confirm doesnt loop forever' '
763 CONFIRM=$(git config --get sendemail.confirm) &&
764 git config sendemail.confirm auto &&
765 GIT_SEND_EMAIL_NOTTY=1 &&
766 export GIT_SEND_EMAIL_NOTTY &&
767 yes "bogus" | test_must_fail git send-email \
768 --from="Example <nobody@example.com>" \
769 --to=nobody@example.com \
770 --smtp-server="$(pwd)/fake.sendmail" \
773 git config sendemail.confirm ${CONFIRM:-never}
777 test_expect_success
$PREREQ 'utf8 Cc is rfc2047 encoded' '
778 clean_fake_sendmail &&
780 git format-patch -1 -o outdir --cc="àéìöú <utf8@example.com>" &&
782 --from="Example <nobody@example.com>" \
783 --to=nobody@example.com \
784 --smtp-server="$(pwd)/fake.sendmail" \
787 grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>"
790 test_expect_success
$PREREQ '--compose adds MIME for utf8 body' '
791 clean_fake_sendmail &&
792 (echo "#!$SHELL_PATH" &&
793 echo "echo utf8 body: àéìöú >>\"\$1\""
794 ) >fake-editor-utf8 &&
795 chmod +x fake-editor-utf8 &&
796 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
798 --compose --subject foo \
799 --from="Example <nobody@example.com>" \
800 --to=nobody@example.com \
801 --smtp-server="$(pwd)/fake.sendmail" \
803 grep "^utf8 body" msgtxt1 &&
804 grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
807 test_expect_success
$PREREQ '--compose respects user mime type' '
808 clean_fake_sendmail &&
809 (echo "#!$SHELL_PATH" &&
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"
815 echo " echo utf8 body: àéìöú) >\"\$1\""
816 ) >fake-editor-utf8-mime &&
817 chmod +x fake-editor-utf8-mime &&
818 GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \
820 --compose --subject foo \
821 --from="Example <nobody@example.com>" \
822 --to=nobody@example.com \
823 --smtp-server="$(pwd)/fake.sendmail" \
825 grep "^utf8 body" msgtxt1 &&
826 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 &&
827 ! grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
830 test_expect_success
$PREREQ '--compose adds MIME for utf8 subject' '
831 clean_fake_sendmail &&
832 GIT_EDITOR="\"$(pwd)/fake-editor\"" \
834 --compose --subject utf8-sübjëct \
835 --from="Example <nobody@example.com>" \
836 --to=nobody@example.com \
837 --smtp-server="$(pwd)/fake.sendmail" \
839 grep "^fake edit" msgtxt1 &&
840 grep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
843 test_expect_success
$PREREQ 'utf8 author is correctly passed on' '
844 clean_fake_sendmail &&
845 test_commit weird_author &&
846 test_when_finished "git reset --hard HEAD^" &&
847 git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" &&
848 git format-patch --stdout -1 >funny_name.patch &&
849 git send-email --from="Example <nobody@example.com>" \
850 --to=nobody@example.com \
851 --smtp-server="$(pwd)/fake.sendmail" \
853 grep "^From: Füñný Nâmé <odd_?=mail@example.com>" msgtxt1
856 test_expect_success
$PREREQ 'detects ambiguous reference/file conflict' '
857 echo master > master &&
859 git commit -m"add master" &&
860 test_must_fail git send-email --dry-run master 2>errors &&
861 grep disambiguate errors
864 test_expect_success
$PREREQ 'feed two files' '
866 git format-patch -2 -o outdir &&
869 --from="Example <nobody@example.com>" \
870 --to=nobody@example.com \
871 outdir/000?-*.patch 2>errors >out &&
872 grep "^Subject: " out >subjects &&
873 test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." &&
874 test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add master"
877 test_expect_success
$PREREQ 'in-reply-to but no threading' '
880 --from="Example <nobody@example.com>" \
881 --to=nobody@example.com \
882 --in-reply-to="<in-reply-id@example.com>" \
885 grep "In-Reply-To: <in-reply-id@example.com>"
888 test_expect_success
$PREREQ 'no in-reply-to and no threading' '
891 --from="Example <nobody@example.com>" \
892 --to=nobody@example.com \
894 $patches $patches >stdout &&
895 ! grep "In-Reply-To: " stdout
898 test_expect_success
$PREREQ 'threading but no chain-reply-to' '
901 --from="Example <nobody@example.com>" \
902 --to=nobody@example.com \
905 $patches $patches >stdout &&
906 grep "In-Reply-To: " stdout
909 test_expect_success
$PREREQ 'warning with an implicit --chain-reply-to' '
912 --from="Example <nobody@example.com>" \
913 --to=nobody@example.com \
914 outdir/000?-*.patch 2>errors >out &&
915 grep "no-chain-reply-to" errors
918 test_expect_success
$PREREQ 'no warning with an explicit --chain-reply-to' '
921 --from="Example <nobody@example.com>" \
922 --to=nobody@example.com \
924 outdir/000?-*.patch 2>errors >out &&
925 ! grep "no-chain-reply-to" errors
928 test_expect_success
$PREREQ 'no warning with an explicit --no-chain-reply-to' '
931 --from="Example <nobody@example.com>" \
932 --to=nobody@example.com \
934 outdir/000?-*.patch 2>errors >out &&
935 ! grep "no-chain-reply-to" errors
938 test_expect_success
$PREREQ 'no warning with sendemail.chainreplyto = false' '
939 git config sendemail.chainreplyto false &&
942 --from="Example <nobody@example.com>" \
943 --to=nobody@example.com \
944 outdir/000?-*.patch 2>errors >out &&
945 ! grep "no-chain-reply-to" errors
948 test_expect_success
$PREREQ 'no warning with sendemail.chainreplyto = true' '
949 git config sendemail.chainreplyto true &&
952 --from="Example <nobody@example.com>" \
953 --to=nobody@example.com \
954 outdir/000?-*.patch 2>errors >out &&
955 ! grep "no-chain-reply-to" errors
958 test_expect_success
$PREREQ 'sendemail.to works' '
959 git config --replace-all sendemail.to "Somebody <somebody@ex.com>" &&
962 --from="Example <nobody@example.com>" \
963 $patches $patches >stdout &&
964 grep "To: Somebody <somebody@ex.com>" stdout
967 test_expect_success
$PREREQ '--no-to overrides sendemail.to' '
970 --from="Example <nobody@example.com>" \
972 --to=nobody@example.com \
973 $patches $patches >stdout &&
974 grep "To: nobody@example.com" stdout &&
975 ! grep "To: Somebody <somebody@ex.com>" stdout
978 test_expect_success
$PREREQ 'sendemail.cc works' '
979 git config --replace-all sendemail.cc "Somebody <somebody@ex.com>" &&
982 --from="Example <nobody@example.com>" \
983 --to=nobody@example.com \
984 $patches $patches >stdout &&
985 grep "Cc: Somebody <somebody@ex.com>" stdout
988 test_expect_success
$PREREQ '--no-cc overrides sendemail.cc' '
991 --from="Example <nobody@example.com>" \
993 --cc=bodies@example.com \
994 --to=nobody@example.com \
995 $patches $patches >stdout &&
996 grep "Cc: bodies@example.com" stdout &&
997 ! grep "Cc: Somebody <somebody@ex.com>" stdout
1000 test_expect_success
$PREREQ 'sendemail.bcc works' '
1001 git config --replace-all sendemail.bcc "Other <other@ex.com>" &&
1004 --from="Example <nobody@example.com>" \
1005 --to=nobody@example.com \
1006 --smtp-server relay.example.com \
1007 $patches $patches >stdout &&
1008 grep "RCPT TO:<other@ex.com>" stdout
1011 test_expect_success
$PREREQ '--no-bcc overrides sendemail.bcc' '
1014 --from="Example <nobody@example.com>" \
1016 --bcc=bodies@example.com \
1017 --to=nobody@example.com \
1018 --smtp-server relay.example.com \
1019 $patches $patches >stdout &&
1020 grep "RCPT TO:<bodies@example.com>" stdout &&
1021 ! grep "RCPT TO:<other@ex.com>" stdout
1024 test_expect_success
$PREREQ 'patches To headers are used by default' '
1025 patch=`git format-patch -1 --to="bodies@example.com"` &&
1026 test_when_finished "rm $patch" &&
1029 --from="Example <nobody@example.com>" \
1030 --smtp-server relay.example.com \
1032 grep "RCPT TO:<bodies@example.com>" stdout
1035 test_expect_success
$PREREQ 'patches To headers are appended to' '
1036 patch=`git format-patch -1 --to="bodies@example.com"` &&
1037 test_when_finished "rm $patch" &&
1040 --from="Example <nobody@example.com>" \
1041 --to=nobody@example.com \
1042 --smtp-server relay.example.com \
1044 grep "RCPT TO:<bodies@example.com>" stdout &&
1045 grep "RCPT TO:<nobody@example.com>" stdout
1048 test_expect_success
$PREREQ 'To headers from files reset each patch' '
1049 patch1=`git format-patch -1 --to="bodies@example.com"` &&
1050 patch2=`git format-patch -1 --to="other@example.com" HEAD~` &&
1051 test_when_finished "rm $patch1 && rm $patch2" &&
1054 --from="Example <nobody@example.com>" \
1055 --to="nobody@example.com" \
1056 --smtp-server relay.example.com \
1057 $patch1 $patch2 >stdout &&
1058 test $(grep -c "RCPT TO:<bodies@example.com>" stdout) = 1 &&
1059 test $(grep -c "RCPT TO:<nobody@example.com>" stdout) = 2 &&
1060 test $(grep -c "RCPT TO:<other@example.com>" stdout) = 1
1063 test_expect_success
$PREREQ 'setup expect' '
1064 cat >email-using-8bit <<EOF
1065 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1066 Message-Id: <bogus-message-id@example.com>
1067 From: author@example.com
1068 Date: Sat, 12 Jun 2010 15:53:58 +0200
1069 Subject: subject goes here
1071 Dieser deutsche Text enthält einen Umlaut!
1075 test_expect_success
$PREREQ 'setup expect' '
1076 cat >content-type-decl <<EOF
1078 Content-Type: text/plain; charset=UTF-8
1079 Content-Transfer-Encoding: 8bit
1083 test_expect_success
$PREREQ 'asks about and fixes 8bit encodings' '
1084 clean_fake_sendmail &&
1086 git send-email --from=author@example.com --to=nobody@example.com \
1087 --smtp-server="$(pwd)/fake.sendmail" \
1088 email-using-8bit >stdout &&
1089 grep "do not declare a Content-Transfer-Encoding" stdout &&
1090 grep email-using-8bit stdout &&
1091 grep "Which 8bit encoding" stdout &&
1092 egrep "Content|MIME" msgtxt1 >actual &&
1093 test_cmp_text actual content-type-decl
1096 test_expect_success
$PREREQ 'sendemail.8bitEncoding works' '
1097 clean_fake_sendmail &&
1098 git config sendemail.assume8bitEncoding UTF-8 &&
1100 git send-email --from=author@example.com --to=nobody@example.com \
1101 --smtp-server="$(pwd)/fake.sendmail" \
1102 email-using-8bit >stdout &&
1103 egrep "Content|MIME" msgtxt1 >actual &&
1104 test_cmp_text actual content-type-decl
1107 test_expect_success
$PREREQ '--8bit-encoding overrides sendemail.8bitEncoding' '
1108 clean_fake_sendmail &&
1109 git config sendemail.assume8bitEncoding "bogus too" &&
1111 git send-email --from=author@example.com --to=nobody@example.com \
1112 --smtp-server="$(pwd)/fake.sendmail" \
1113 --8bit-encoding=UTF-8 \
1114 email-using-8bit >stdout &&
1115 egrep "Content|MIME" msgtxt1 >actual &&
1116 test_cmp_text actual content-type-decl
1119 test_expect_success
$PREREQ 'setup expect' '
1120 cat >email-using-8bit <<EOF
1121 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1122 Message-Id: <bogus-message-id@example.com>
1123 From: author@example.com
1124 Date: Sat, 12 Jun 2010 15:53:58 +0200
1125 Subject: Dieser Betreff enthält auch einen Umlaut!
1127 Nothing to see here.
1131 test_expect_success
$PREREQ 'setup expect' '
1133 Subject: =?UTF-8?q?Dieser=20Betreff=20enth=C3=A4lt=20auch=20einen=20Umlaut!?=
1137 test_expect_success
$PREREQ '--8bit-encoding also treats subject' '
1138 clean_fake_sendmail &&
1140 git send-email --from=author@example.com --to=nobody@example.com \
1141 --smtp-server="$(pwd)/fake.sendmail" \
1142 --8bit-encoding=UTF-8 \
1143 email-using-8bit >stdout &&
1144 grep "Subject" msgtxt1 >actual &&
1145 test_cmp_text expected actual
1148 # Note that the patches in this test are deliberately out of order; we
1149 # want to make sure it works even if the cover-letter is not in the
1151 test_expect_success
$PREREQ 'refusing to send cover letter template' '
1152 clean_fake_sendmail &&
1154 git format-patch --cover-letter -2 -o outdir &&
1155 test_must_fail git send-email \
1156 --from="Example <nobody@example.com>" \
1157 --to=nobody@example.com \
1158 --smtp-server="$(pwd)/fake.sendmail" \
1159 outdir/0002-*.patch \
1160 outdir/0000-*.patch \
1161 outdir/0001-*.patch \
1163 grep "SUBJECT HERE" errors &&
1164 test -z "$(ls msgtxt*)"
1167 test_expect_success
$PREREQ '--force sends cover letter template anyway' '
1168 clean_fake_sendmail &&
1170 git format-patch --cover-letter -2 -o outdir &&
1173 --from="Example <nobody@example.com>" \
1174 --to=nobody@example.com \
1175 --smtp-server="$(pwd)/fake.sendmail" \
1176 outdir/0002-*.patch \
1177 outdir/0000-*.patch \
1178 outdir/0001-*.patch \
1180 ! grep "SUBJECT HERE" errors &&
1181 test -n "$(ls msgtxt*)"
1184 test_expect_success
$PREREQ 'sendemail.aliasfiletype=mailrc' '
1185 clean_fake_sendmail &&
1186 echo "alias sbd somebody@example.org" >.mailrc &&
1187 git config --replace-all sendemail.aliasesfile "$(pwd)/.mailrc" &&
1188 git config sendemail.aliasfiletype mailrc &&
1190 --from="Example <nobody@example.com>" \
1192 --smtp-server="$(pwd)/fake.sendmail" \
1193 outdir/0001-*.patch \
1195 grep "^!somebody@example\.org!$" commandline1
1198 test_expect_success
$PREREQ 'sendemail.aliasfile=~/.mailrc' '
1199 clean_fake_sendmail &&
1200 echo "alias sbd someone@example.org" >~/.mailrc &&
1201 git config --replace-all sendemail.aliasesfile "~/.mailrc" &&
1202 git config sendemail.aliasfiletype mailrc &&
1204 --from="Example <nobody@example.com>" \
1206 --smtp-server="$(pwd)/fake.sendmail" \
1207 outdir/0001-*.patch \
1209 grep "^!someone@example\.org!$" commandline1