3 test_description
='git send-email'
6 if ! test_have_prereq PERL
; then
7 skip_all
='skipping git send-email tests, perl not available'
13 'prepare reference tree' \
14 'echo "1A quick brown fox jumps over the" >file &&
15 echo "lazy dog" >>file &&
17 GIT_AUTHOR_NAME="A" git commit -a -m "Initial."'
21 '(echo "#!$SHELL_PATH"
24 echo "while test -f commandline\$output; do output=\$((\$output+1)); done"
27 echo " echo \"!\$a!\""
28 echo "done >commandline\$output"
29 echo "cat > msgtxt\$output"
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
47 GIT_SEND_EMAIL_NOTTY
=1 \
49 --from="Example <from@example.com>" \
50 --to=nobody@example.com \
51 --smtp-server="$(pwd)/fake.sendmail" \
54 test_must_fail
grep "Send this email" stdout
&&
58 # Exit immediately to prevent hang if a no-confirm test fails
60 test -f no_confirm_okay ||
{
61 skip_all
='confirm test failed; skipping remaining tests to prevent hanging'
66 test_expect_success
'No confirm with --suppress-cc' '
67 test_no_confirm --suppress-cc=sob
71 test_expect_success
'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
'No confirm with sendemail.confirm=never' '
79 git config sendemail.confirm never &&
80 test_no_confirm --compose --subject=foo
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
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
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
128 test_expect_success \
129 'Verify commandline' \
130 'test_cmp expected commandline1'
132 cat >expected-show-all-headers
<<\EOF
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'
138 Server
: relay.example.com
139 MAIL FROM
:<from@example.com
>
140 RCPT TO
:<to@example.com
>
141 RCPT TO
:<cc@example.com
>
142 RCPT TO
:<author@example.com
>
143 RCPT TO
:<one@example.com
>
144 RCPT TO
:<two@example.com
>
145 RCPT TO
:<bcc@example.com
>
146 From
: Example
<from@example.com
>
149 A
<author@example.com
>,
150 One
<one@example.com
>,
152 Subject
: [PATCH
1/1] Second.
154 Message-Id
: MESSAGE-ID-STRING
155 X-Mailer
: X-MAILER-STRING
156 In-Reply-To
: <unique-message-id@example.com
>
157 References
: <unique-message-id@example.com
>
162 test_expect_success
'Show all headers' '
166 --from="Example <from@example.com>" \
167 --to=to@example.com \
168 --cc=cc@example.com \
169 --bcc=bcc@example.com \
170 --in-reply-to="<unique-message-id@example.com>" \
171 --smtp-server relay.example.com \
173 sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
174 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
175 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
176 >actual-show-all-headers &&
177 test_cmp expected-show-all-headers actual-show-all-headers
180 test_expect_success
'Prompting works' '
181 clean_fake_sendmail &&
182 (echo "Example <from@example.com>"
183 echo "to@example.com"
185 ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
186 --smtp-server="$(pwd)/fake.sendmail" \
189 grep "^From: Example <from@example.com>\$" msgtxt1 &&
190 grep "^To: to@example.com\$" msgtxt1
193 test_expect_success
'cccmd works' '
194 clean_fake_sendmail &&
195 cp $patches cccmd.patch &&
196 echo cccmd--cccmd@example.com >>cccmd.patch &&
199 echo sed -n -e s/^cccmd--//p \"\$1\"
201 chmod +x cccmd-sed &&
203 --from="Example <nobody@example.com>" \
204 --to=nobody@example.com \
205 --cc-cmd=./cccmd-sed \
206 --smtp-server="$(pwd)/fake.sendmail" \
209 grep "^ cccmd@example.com" msgtxt1
213 z64
=$z8$z8$z8$z8$z8$z8$z8$z8
214 z512
=$z64$z64$z64$z64$z64$z64$z64$z64
215 test_expect_success
'reject long lines' '
216 clean_fake_sendmail &&
217 cp $patches longline.patch &&
218 echo $z512$z512 >>longline.patch &&
219 test_must_fail git send-email \
220 --from="Example <nobody@example.com>" \
221 --to=nobody@example.com \
222 --smtp-server="$(pwd)/fake.sendmail" \
223 $patches longline.patch \
225 grep longline.patch errors
228 test_expect_success
'no patch was sent' '
229 ! test -e commandline1
232 test_expect_success
'Author From: in message body' '
233 clean_fake_sendmail &&
235 --from="Example <nobody@example.com>" \
236 --to=nobody@example.com \
237 --smtp-server="$(pwd)/fake.sendmail" \
239 sed "1,/^\$/d" < msgtxt1 > msgbody1
240 grep "From: A <author@example.com>" msgbody1
243 test_expect_success
'Author From: not in message body' '
244 clean_fake_sendmail &&
246 --from="A <author@example.com>" \
247 --to=nobody@example.com \
248 --smtp-server="$(pwd)/fake.sendmail" \
250 sed "1,/^\$/d" < msgtxt1 > msgbody1
251 ! grep "From: A <author@example.com>" msgbody1
254 test_expect_success
'allow long lines with --no-validate' '
256 --from="Example <nobody@example.com>" \
257 --to=nobody@example.com \
258 --smtp-server="$(pwd)/fake.sendmail" \
260 $patches longline.patch \
264 test_expect_success
'Invalid In-Reply-To' '
265 clean_fake_sendmail &&
267 --from="Example <nobody@example.com>" \
268 --to=nobody@example.com \
270 --smtp-server="$(pwd)/fake.sendmail" \
273 ! grep "^In-Reply-To: < *>" msgtxt1
276 test_expect_success
'Valid In-Reply-To when prompting' '
277 clean_fake_sendmail &&
278 (echo "From Example <from@example.com>"
279 echo "To Example <to@example.com>"
281 ) | env GIT_SEND_EMAIL_NOTTY=1 git send-email \
282 --smtp-server="$(pwd)/fake.sendmail" \
284 ! grep "^In-Reply-To: < *>" msgtxt1
287 test_expect_success
'setup fake editor' '
288 (echo "#!$SHELL_PATH" &&
289 echo "echo fake edit >>\"\$1\""
294 test_set_editor
"$(pwd)/fake-editor"
296 test_expect_success
'--compose works' '
297 clean_fake_sendmail &&
299 --compose --subject foo \
300 --from="Example <nobody@example.com>" \
301 --to=nobody@example.com \
302 --smtp-server="$(pwd)/fake.sendmail" \
307 test_expect_success
'first message is compose text' '
308 grep "^fake edit" msgtxt1
311 test_expect_success
'second message is patch' '
312 grep "Subject:.*Second" msgtxt2
315 cat >expected-suppress-sob
<<\EOF
317 (mbox
) Adding cc
: A
<author@example.com
> from line
'From: A <author@example.com>'
318 (mbox
) Adding cc
: One
<one@example.com
> from line
'Cc: One <one@example.com>, two@example.com'
319 (mbox
) Adding cc
: two@example.com from line
'Cc: One <one@example.com>, two@example.com'
321 Server
: relay.example.com
322 MAIL FROM
:<from@example.com
>
323 RCPT TO
:<to@example.com
>
324 RCPT TO
:<cc@example.com
>
325 RCPT TO
:<author@example.com
>
326 RCPT TO
:<one@example.com
>
327 RCPT TO
:<two@example.com
>
328 From
: Example
<from@example.com
>
331 A
<author@example.com
>,
332 One
<one@example.com
>,
334 Subject
: [PATCH
1/1] Second.
336 Message-Id
: MESSAGE-ID-STRING
337 X-Mailer
: X-MAILER-STRING
342 test_suppression
() {
345 --suppress-cc=$1 ${2+"--suppress-cc=$2"} \
346 --from="Example <from@example.com>" \
347 --to=to@example.com \
348 --smtp-server relay.example.com \
350 sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
351 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
352 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
353 >actual-suppress-
$1${2+"-$2"} &&
354 test_cmp expected-suppress-
$1${2+"-$2"} actual-suppress-
$1${2+"-$2"}
357 test_expect_success
'sendemail.cc set' '
358 git config sendemail.cc cc@example.com &&
362 cat >expected-suppress-sob
<<\EOF
364 (mbox
) Adding cc
: A
<author@example.com
> from line
'From: A <author@example.com>'
365 (mbox
) Adding cc
: One
<one@example.com
> from line
'Cc: One <one@example.com>, two@example.com'
366 (mbox
) Adding cc
: two@example.com from line
'Cc: One <one@example.com>, two@example.com'
368 Server
: relay.example.com
369 MAIL FROM
:<from@example.com
>
370 RCPT TO
:<to@example.com
>
371 RCPT TO
:<author@example.com
>
372 RCPT TO
:<one@example.com
>
373 RCPT TO
:<two@example.com
>
374 From
: Example
<from@example.com
>
376 Cc
: A
<author@example.com
>,
377 One
<one@example.com
>,
379 Subject
: [PATCH
1/1] Second.
381 Message-Id
: MESSAGE-ID-STRING
382 X-Mailer
: X-MAILER-STRING
387 test_expect_success
'sendemail.cc unset' '
388 git config --unset sendemail.cc &&
392 cat >expected-suppress-cccmd
<<\EOF
394 (mbox
) Adding cc
: A
<author@example.com
> from line
'From: A <author@example.com>'
395 (mbox
) Adding cc
: One
<one@example.com
> from line
'Cc: One <one@example.com>, two@example.com'
396 (mbox
) Adding cc
: two@example.com from line
'Cc: One <one@example.com>, two@example.com'
397 (body
) Adding cc
: C O Mitter
<committer@example.com
> from line
'Signed-off-by: C O Mitter <committer@example.com>'
399 Server
: relay.example.com
400 MAIL FROM
:<from@example.com
>
401 RCPT TO
:<to@example.com
>
402 RCPT TO
:<author@example.com
>
403 RCPT TO
:<one@example.com
>
404 RCPT TO
:<two@example.com
>
405 RCPT TO
:<committer@example.com
>
406 From
: Example
<from@example.com
>
408 Cc
: A
<author@example.com
>,
409 One
<one@example.com
>,
411 C O Mitter
<committer@example.com
>
412 Subject
: [PATCH
1/1] Second.
414 Message-Id
: MESSAGE-ID-STRING
415 X-Mailer
: X-MAILER-STRING
420 test_expect_success
'sendemail.cccmd' '
421 echo echo cc-cmd@example.com > cccmd &&
423 git config sendemail.cccmd ./cccmd &&
424 test_suppression cccmd
427 cat >expected-suppress-all
<<\EOF
430 Server
: relay.example.com
431 MAIL FROM
:<from@example.com
>
432 RCPT TO
:<to@example.com
>
433 From
: Example
<from@example.com
>
435 Subject
: [PATCH
1/1] Second.
437 Message-Id
: MESSAGE-ID-STRING
438 X-Mailer
: X-MAILER-STRING
443 test_expect_success
'--suppress-cc=all' '
447 cat >expected-suppress-body
<<\EOF
449 (mbox
) Adding cc
: A
<author@example.com
> from line
'From: A <author@example.com>'
450 (mbox
) Adding cc
: One
<one@example.com
> from line
'Cc: One <one@example.com>, two@example.com'
451 (mbox
) Adding cc
: two@example.com from line
'Cc: One <one@example.com>, two@example.com'
452 (cc-cmd
) Adding cc
: cc-cmd@example.com from
: './cccmd'
454 Server
: relay.example.com
455 MAIL FROM
:<from@example.com
>
456 RCPT TO
:<to@example.com
>
457 RCPT TO
:<author@example.com
>
458 RCPT TO
:<one@example.com
>
459 RCPT TO
:<two@example.com
>
460 RCPT TO
:<cc-cmd@example.com
>
461 From
: Example
<from@example.com
>
463 Cc
: A
<author@example.com
>,
464 One
<one@example.com
>,
467 Subject
: [PATCH
1/1] Second.
469 Message-Id
: MESSAGE-ID-STRING
470 X-Mailer
: X-MAILER-STRING
475 test_expect_success
'--suppress-cc=body' '
476 test_suppression body
479 cat >expected-suppress-body-cccmd
<<\EOF
481 (mbox
) Adding cc
: A
<author@example.com
> from line
'From: A <author@example.com>'
482 (mbox
) Adding cc
: One
<one@example.com
> from line
'Cc: One <one@example.com>, two@example.com'
483 (mbox
) Adding cc
: two@example.com from line
'Cc: One <one@example.com>, two@example.com'
485 Server
: relay.example.com
486 MAIL FROM
:<from@example.com
>
487 RCPT TO
:<to@example.com
>
488 RCPT TO
:<author@example.com
>
489 RCPT TO
:<one@example.com
>
490 RCPT TO
:<two@example.com
>
491 From
: Example
<from@example.com
>
493 Cc
: A
<author@example.com
>,
494 One
<one@example.com
>,
496 Subject
: [PATCH
1/1] Second.
498 Message-Id
: MESSAGE-ID-STRING
499 X-Mailer
: X-MAILER-STRING
504 test_expect_success
'--suppress-cc=body --suppress-cc=cccmd' '
505 test_suppression body cccmd
508 cat >expected-suppress-sob
<<\EOF
510 (mbox
) Adding cc
: A
<author@example.com
> from line
'From: A <author@example.com>'
511 (mbox
) Adding cc
: One
<one@example.com
> from line
'Cc: One <one@example.com>, two@example.com'
512 (mbox
) Adding cc
: two@example.com from line
'Cc: One <one@example.com>, two@example.com'
514 Server
: relay.example.com
515 MAIL FROM
:<from@example.com
>
516 RCPT TO
:<to@example.com
>
517 RCPT TO
:<author@example.com
>
518 RCPT TO
:<one@example.com
>
519 RCPT TO
:<two@example.com
>
520 From
: Example
<from@example.com
>
522 Cc
: A
<author@example.com
>,
523 One
<one@example.com
>,
525 Subject
: [PATCH
1/1] Second.
527 Message-Id
: MESSAGE-ID-STRING
528 X-Mailer
: X-MAILER-STRING
533 test_expect_success
'--suppress-cc=sob' '
534 git config --unset sendemail.cccmd
538 cat >expected-suppress-bodycc
<<\EOF
540 (mbox
) Adding cc
: A
<author@example.com
> from line
'From: A <author@example.com>'
541 (mbox
) Adding cc
: One
<one@example.com
> from line
'Cc: One <one@example.com>, two@example.com'
542 (mbox
) Adding cc
: two@example.com from line
'Cc: One <one@example.com>, two@example.com'
543 (body
) Adding cc
: C O Mitter
<committer@example.com
> from line
'Signed-off-by: C O Mitter <committer@example.com>'
545 Server
: relay.example.com
546 MAIL FROM
:<from@example.com
>
547 RCPT TO
:<to@example.com
>
548 RCPT TO
:<author@example.com
>
549 RCPT TO
:<one@example.com
>
550 RCPT TO
:<two@example.com
>
551 RCPT TO
:<committer@example.com
>
552 From
: Example
<from@example.com
>
554 Cc
: A
<author@example.com
>,
555 One
<one@example.com
>,
557 C O Mitter
<committer@example.com
>
558 Subject
: [PATCH
1/1] Second.
560 Message-Id
: MESSAGE-ID-STRING
561 X-Mailer
: X-MAILER-STRING
566 test_expect_success
'--suppress-cc=bodycc' '
567 test_suppression bodycc
570 cat >expected-suppress-cc
<<\EOF
572 (mbox
) Adding cc
: A
<author@example.com
> from line
'From: A <author@example.com>'
573 (body
) Adding cc
: C O Mitter
<committer@example.com
> from line
'Signed-off-by: C O Mitter <committer@example.com>'
575 Server
: relay.example.com
576 MAIL FROM
:<from@example.com
>
577 RCPT TO
:<to@example.com
>
578 RCPT TO
:<author@example.com
>
579 RCPT TO
:<committer@example.com
>
580 From
: Example
<from@example.com
>
582 Cc
: A
<author@example.com
>,
583 C O Mitter
<committer@example.com
>
584 Subject
: [PATCH
1/1] Second.
586 Message-Id
: MESSAGE-ID-STRING
587 X-Mailer
: X-MAILER-STRING
592 test_expect_success
'--suppress-cc=cc' '
598 GIT_SEND_EMAIL_NOTTY
=1 \
600 --from="Example <nobody@example.com>" \
601 --to=nobody@example.com \
602 --smtp-server="$(pwd)/fake.sendmail" \
603 $@
$patches > stdout
&&
604 grep "Send this email" stdout
607 test_expect_success
'--confirm=always' '
608 test_confirm --confirm=always --suppress-cc=all
611 test_expect_success
'--confirm=auto' '
612 test_confirm --confirm=auto
615 test_expect_success
'--confirm=cc' '
616 test_confirm --confirm=cc
619 test_expect_success
'--confirm=compose' '
620 test_confirm --confirm=compose --compose
623 test_expect_success
'confirm by default (due to cc)' '
624 CONFIRM=$(git config --get sendemail.confirm) &&
625 git config --unset sendemail.confirm &&
628 git config sendemail.confirm ${CONFIRM:-never}
632 test_expect_success
'confirm by default (due to --compose)' '
633 CONFIRM=$(git config --get sendemail.confirm) &&
634 git config --unset sendemail.confirm &&
635 test_confirm --suppress-cc=all --compose
637 git config sendemail.confirm ${CONFIRM:-never}
641 test_expect_success
'confirm detects EOF (inform assumes y)' '
642 CONFIRM=$(git config --get sendemail.confirm) &&
643 git config --unset sendemail.confirm &&
645 git format-patch -2 -o outdir &&
646 GIT_SEND_EMAIL_NOTTY=1 \
648 --from="Example <nobody@example.com>" \
649 --to=nobody@example.com \
650 --smtp-server="$(pwd)/fake.sendmail" \
651 outdir/*.patch < /dev/null
653 git config sendemail.confirm ${CONFIRM:-never}
657 test_expect_success
'confirm detects EOF (auto causes failure)' '
658 CONFIRM=$(git config --get sendemail.confirm) &&
659 git config sendemail.confirm auto &&
660 GIT_SEND_EMAIL_NOTTY=1 &&
661 export GIT_SEND_EMAIL_NOTTY &&
662 test_must_fail git send-email \
663 --from="Example <nobody@example.com>" \
664 --to=nobody@example.com \
665 --smtp-server="$(pwd)/fake.sendmail" \
668 git config sendemail.confirm ${CONFIRM:-never}
672 test_expect_success
'confirm doesnt loop forever' '
673 CONFIRM=$(git config --get sendemail.confirm) &&
674 git config sendemail.confirm auto &&
675 GIT_SEND_EMAIL_NOTTY=1 &&
676 export GIT_SEND_EMAIL_NOTTY &&
677 yes "bogus" | test_must_fail git send-email \
678 --from="Example <nobody@example.com>" \
679 --to=nobody@example.com \
680 --smtp-server="$(pwd)/fake.sendmail" \
683 git config sendemail.confirm ${CONFIRM:-never}
687 test_expect_success
'utf8 Cc is rfc2047 encoded' '
688 clean_fake_sendmail &&
690 git format-patch -1 -o outdir --cc="àéìöú <utf8@example.com>" &&
692 --from="Example <nobody@example.com>" \
693 --to=nobody@example.com \
694 --smtp-server="$(pwd)/fake.sendmail" \
697 grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>"
700 test_expect_success
'--compose adds MIME for utf8 body' '
701 clean_fake_sendmail &&
702 (echo "#!$SHELL_PATH" &&
703 echo "echo utf8 body: àéìöú >>\"\$1\""
704 ) >fake-editor-utf8 &&
705 chmod +x fake-editor-utf8 &&
706 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
708 --compose --subject foo \
709 --from="Example <nobody@example.com>" \
710 --to=nobody@example.com \
711 --smtp-server="$(pwd)/fake.sendmail" \
713 grep "^utf8 body" msgtxt1 &&
714 grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
717 test_expect_success
'--compose respects user mime type' '
718 clean_fake_sendmail &&
719 (echo "#!$SHELL_PATH" &&
720 echo "(echo MIME-Version: 1.0"
721 echo " echo Content-Type: text/plain\\; charset=iso-8859-1"
722 echo " echo Content-Transfer-Encoding: 8bit"
723 echo " echo Subject: foo"
725 echo " echo utf8 body: àéìöú) >\"\$1\""
726 ) >fake-editor-utf8-mime &&
727 chmod +x fake-editor-utf8-mime &&
728 GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \
730 --compose --subject foo \
731 --from="Example <nobody@example.com>" \
732 --to=nobody@example.com \
733 --smtp-server="$(pwd)/fake.sendmail" \
735 grep "^utf8 body" msgtxt1 &&
736 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 &&
737 ! grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
740 test_expect_success
'--compose adds MIME for utf8 subject' '
741 clean_fake_sendmail &&
742 GIT_EDITOR="\"$(pwd)/fake-editor\"" \
744 --compose --subject utf8-sübjëct \
745 --from="Example <nobody@example.com>" \
746 --to=nobody@example.com \
747 --smtp-server="$(pwd)/fake.sendmail" \
749 grep "^fake edit" msgtxt1 &&
750 grep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
753 test_expect_success
'detects ambiguous reference/file conflict' '
754 echo master > master &&
756 git commit -m"add master" &&
757 test_must_fail git send-email --dry-run master 2>errors &&
758 grep disambiguate errors
761 test_expect_success
'feed two files' '
763 git format-patch -2 -o outdir &&
766 --from="Example <nobody@example.com>" \
767 --to=nobody@example.com \
768 outdir/000?-*.patch 2>errors >out &&
769 grep "^Subject: " out >subjects &&
770 test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." &&
771 test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add master"
774 test_expect_success
'in-reply-to but no threading' '
777 --from="Example <nobody@example.com>" \
778 --to=nobody@example.com \
779 --in-reply-to="<in-reply-id@example.com>" \
782 grep "In-Reply-To: <in-reply-id@example.com>"
785 test_expect_success
'no in-reply-to and no threading' '
788 --from="Example <nobody@example.com>" \
789 --to=nobody@example.com \
791 $patches $patches >stdout &&
792 ! grep "In-Reply-To: " stdout
795 test_expect_success
'threading but no chain-reply-to' '
798 --from="Example <nobody@example.com>" \
799 --to=nobody@example.com \
802 $patches $patches >stdout &&
803 grep "In-Reply-To: " stdout
806 test_expect_success
'warning with an implicit --chain-reply-to' '
809 --from="Example <nobody@example.com>" \
810 --to=nobody@example.com \
811 outdir/000?-*.patch 2>errors >out &&
812 grep "no-chain-reply-to" errors
815 test_expect_success
'no warning with an explicit --chain-reply-to' '
818 --from="Example <nobody@example.com>" \
819 --to=nobody@example.com \
821 outdir/000?-*.patch 2>errors >out &&
822 ! grep "no-chain-reply-to" errors
825 test_expect_success
'no warning with an explicit --no-chain-reply-to' '
828 --from="Example <nobody@example.com>" \
829 --to=nobody@example.com \
831 outdir/000?-*.patch 2>errors >out &&
832 ! grep "no-chain-reply-to" errors
835 test_expect_success
'no warning with sendemail.chainreplyto = false' '
836 git config sendemail.chainreplyto false &&
839 --from="Example <nobody@example.com>" \
840 --to=nobody@example.com \
841 outdir/000?-*.patch 2>errors >out &&
842 ! grep "no-chain-reply-to" errors
845 test_expect_success
'no warning with sendemail.chainreplyto = true' '
846 git config sendemail.chainreplyto true &&
849 --from="Example <nobody@example.com>" \
850 --to=nobody@example.com \
851 outdir/000?-*.patch 2>errors >out &&
852 ! grep "no-chain-reply-to" errors
855 test_expect_success
'sendemail.to works' '
856 git config --replace-all sendemail.to "Somebody <somebody@ex.com>" &&
859 --from="Example <nobody@example.com>" \
860 $patches $patches >stdout &&
861 grep "To: Somebody <somebody@ex.com>" stdout
864 test_expect_success
'--no-to overrides sendemail.to' '
867 --from="Example <nobody@example.com>" \
869 --to=nobody@example.com \
870 $patches $patches >stdout &&
871 grep "To: nobody@example.com" stdout &&
872 ! grep "To: Somebody <somebody@ex.com>" stdout
875 test_expect_success
'sendemail.cc works' '
876 git config --replace-all sendemail.cc "Somebody <somebody@ex.com>" &&
879 --from="Example <nobody@example.com>" \
880 --to=nobody@example.com \
881 $patches $patches >stdout &&
882 grep "Cc: Somebody <somebody@ex.com>" stdout
885 test_expect_success
'--no-cc overrides sendemail.cc' '
888 --from="Example <nobody@example.com>" \
890 --cc=bodies@example.com \
891 --to=nobody@example.com \
892 $patches $patches >stdout &&
893 grep "Cc: bodies@example.com" stdout &&
894 ! grep "Cc: Somebody <somebody@ex.com>" stdout
897 test_expect_success
'sendemail.bcc works' '
898 git config --replace-all sendemail.bcc "Other <other@ex.com>" &&
901 --from="Example <nobody@example.com>" \
902 --to=nobody@example.com \
903 --smtp-server relay.example.com \
904 $patches $patches >stdout &&
905 grep "RCPT TO:<other@ex.com>" stdout
908 test_expect_success
'--no-bcc overrides sendemail.bcc' '
911 --from="Example <nobody@example.com>" \
913 --bcc=bodies@example.com \
914 --to=nobody@example.com \
915 --smtp-server relay.example.com \
916 $patches $patches >stdout &&
917 grep "RCPT TO:<bodies@example.com>" stdout &&
918 ! grep "RCPT TO:<other@ex.com>" stdout
921 cat >email-using-8bit
<<EOF
922 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
923 Message-Id: <bogus-message-id@example.com>
924 From: author@example.com
925 Date: Sat, 12 Jun 2010 15:53:58 +0200
926 Subject: subject goes here
928 Dieser deutsche Text enthält einen Umlaut!
931 cat >content-type-decl
<<EOF
933 Content-Type: text/plain; charset=UTF-8
934 Content-Transfer-Encoding: 8bit
937 test_expect_success
'asks about and fixes 8bit encodings' '
938 clean_fake_sendmail &&
940 git send-email --from=author@example.com --to=nobody@example.com \
941 --smtp-server="$(pwd)/fake.sendmail" \
942 email-using-8bit >stdout &&
943 grep "do not declare a Content-Transfer-Encoding" stdout &&
944 grep email-using-8bit stdout &&
945 grep "Which 8bit encoding" stdout &&
946 egrep "Content|MIME" msgtxt1 >actual &&
947 test_cmp actual content-type-decl
950 test_expect_success
'sendemail.8bitEncoding works' '
951 clean_fake_sendmail &&
952 git config sendemail.assume8bitEncoding UTF-8 &&
954 git send-email --from=author@example.com --to=nobody@example.com \
955 --smtp-server="$(pwd)/fake.sendmail" \
956 email-using-8bit >stdout &&
957 egrep "Content|MIME" msgtxt1 >actual &&
958 test_cmp actual content-type-decl
961 test_expect_success
'--8bit-encoding overrides sendemail.8bitEncoding' '
962 clean_fake_sendmail &&
963 git config sendemail.assume8bitEncoding "bogus too" &&
965 git send-email --from=author@example.com --to=nobody@example.com \
966 --smtp-server="$(pwd)/fake.sendmail" \
967 --8bit-encoding=UTF-8 \
968 email-using-8bit >stdout &&
969 egrep "Content|MIME" msgtxt1 >actual &&
970 test_cmp actual content-type-decl
973 cat >email-using-8bit
<<EOF
974 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
975 Message-Id: <bogus-message-id@example.com>
976 From: author@example.com
977 Date: Sat, 12 Jun 2010 15:53:58 +0200
978 Subject: Dieser Betreff enthält auch einen Umlaut!
984 Subject: =?UTF-8?q?Dieser=20Betreff=20enth=C3=A4lt=20auch=20einen=20Umlaut!?=
987 test_expect_success
'--8bit-encoding also treats subject' '
988 clean_fake_sendmail &&
990 git send-email --from=author@example.com --to=nobody@example.com \
991 --smtp-server="$(pwd)/fake.sendmail" \
992 --8bit-encoding=UTF-8 \
993 email-using-8bit >stdout &&
994 grep "Subject" msgtxt1 >actual &&
995 test_cmp expected actual