3 test_description
='git send-email'
6 if ! test_have_prereq PERL
; then
7 skip_all
='skipping git send-email tests, perl not available'
12 'prepare reference tree' \
13 'echo "1A quick brown fox jumps over the" >file &&
14 echo "lazy dog" >>file &&
16 GIT_AUTHOR_NAME="A" git commit -a -m "Initial."'
20 '(echo "#!$SHELL_PATH"
23 echo "while test -f commandline\$output; do output=\$((\$output+1)); done"
26 echo " echo \"!\$a!\""
27 echo "done >commandline\$output"
28 echo "cat > msgtxt\$output"
30 chmod +x ./fake.sendmail &&
31 git add fake.sendmail &&
32 GIT_AUTHOR_NAME="A" git commit -a -m "Second."'
34 clean_fake_sendmail
() {
35 rm -f commandline
* msgtxt
*
38 test_expect_success
'Extract patches' '
39 patches=`git format-patch -s --cc="One <one@example.com>" --cc=two@example.com -n HEAD^1`
42 # Test no confirm early to ensure remaining tests will not hang
46 GIT_SEND_EMAIL_NOTTY
=1 \
48 --from="Example <from@example.com>" \
49 --to=nobody@example.com \
50 --smtp-server="$(pwd)/fake.sendmail" \
53 test_must_fail
grep "Send this email" stdout
&&
57 # Exit immediately to prevent hang if a no-confirm test fails
59 test -f no_confirm_okay ||
{
60 skip_all
='confirm test failed; skipping remaining tests to prevent hanging'
65 test_expect_success
'No confirm with --suppress-cc' '
66 test_no_confirm --suppress-cc=sob
70 test_expect_success
'No confirm with --confirm=never' '
71 test_no_confirm --confirm=never
75 # leave sendemail.confirm set to never after this so that none of the
76 # remaining tests prompt unintentionally.
77 test_expect_success
'No confirm with sendemail.confirm=never' '
78 git config sendemail.confirm never &&
79 test_no_confirm --compose --subject=foo
83 test_expect_success
'Send patches' '
84 git send-email --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors
94 'Verify commandline' \
95 'test_cmp expected commandline1'
97 test_expect_success
'Send patches with --envelope-sender' '
98 clean_fake_sendmail &&
99 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
110 test_expect_success \
111 'Verify commandline' \
112 'test_cmp expected commandline1'
114 test_expect_success
'Send patches with --envelope-sender=auto' '
115 clean_fake_sendmail &&
116 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
127 test_expect_success \
128 'Verify commandline' \
129 'test_cmp expected commandline1'
131 cat >expected-show-all-headers
<<\EOF
133 (mbox
) Adding cc
: A
<author@example.com
> from line
'From: A <author@example.com>'
134 (mbox
) Adding cc
: One
<one@example.com
> from line
'Cc: One <one@example.com>, two@example.com'
135 (mbox
) Adding cc
: two@example.com from line
'Cc: One <one@example.com>, two@example.com'
137 Server
: relay.example.com
138 MAIL FROM
:<from@example.com
>
139 RCPT TO
:<to@example.com
>
140 RCPT TO
:<cc@example.com
>
141 RCPT TO
:<author@example.com
>
142 RCPT TO
:<one@example.com
>
143 RCPT TO
:<two@example.com
>
144 RCPT TO
:<bcc@example.com
>
145 From
: Example
<from@example.com
>
148 A
<author@example.com
>,
149 One
<one@example.com
>,
151 Subject
: [PATCH
1/1] Second.
153 Message-Id
: MESSAGE-ID-STRING
154 X-Mailer
: X-MAILER-STRING
155 In-Reply-To
: <unique-message-id@example.com
>
156 References
: <unique-message-id@example.com
>
161 test_expect_success
'Show all headers' '
165 --from="Example <from@example.com>" \
166 --to=to@example.com \
167 --cc=cc@example.com \
168 --bcc=bcc@example.com \
169 --in-reply-to="<unique-message-id@example.com>" \
170 --smtp-server relay.example.com \
172 sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
173 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
174 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
175 >actual-show-all-headers &&
176 test_cmp expected-show-all-headers actual-show-all-headers
179 test_expect_success
'Prompting works' '
180 clean_fake_sendmail &&
181 (echo "Example <from@example.com>"
182 echo "to@example.com"
184 ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
185 --smtp-server="$(pwd)/fake.sendmail" \
188 grep "^From: Example <from@example.com>\$" msgtxt1 &&
189 grep "^To: to@example.com\$" msgtxt1
192 test_expect_success
'cccmd works' '
193 clean_fake_sendmail &&
194 cp $patches cccmd.patch &&
195 echo cccmd--cccmd@example.com >>cccmd.patch &&
198 echo sed -n -e s/^cccmd--//p \"\$1\"
200 chmod +x cccmd-sed &&
202 --from="Example <nobody@example.com>" \
203 --to=nobody@example.com \
204 --cc-cmd=./cccmd-sed \
205 --smtp-server="$(pwd)/fake.sendmail" \
208 grep "^ cccmd@example.com" msgtxt1
212 z64
=$z8$z8$z8$z8$z8$z8$z8$z8
213 z512
=$z64$z64$z64$z64$z64$z64$z64$z64
214 test_expect_success
'reject long lines' '
215 clean_fake_sendmail &&
216 cp $patches longline.patch &&
217 echo $z512$z512 >>longline.patch &&
218 test_must_fail git send-email \
219 --from="Example <nobody@example.com>" \
220 --to=nobody@example.com \
221 --smtp-server="$(pwd)/fake.sendmail" \
222 $patches longline.patch \
224 grep longline.patch errors
227 test_expect_success
'no patch was sent' '
228 ! test -e commandline1
231 test_expect_success
'Author From: in message body' '
232 clean_fake_sendmail &&
234 --from="Example <nobody@example.com>" \
235 --to=nobody@example.com \
236 --smtp-server="$(pwd)/fake.sendmail" \
238 sed "1,/^\$/d" < msgtxt1 > msgbody1
239 grep "From: A <author@example.com>" msgbody1
242 test_expect_success
'Author From: not in message body' '
243 clean_fake_sendmail &&
245 --from="A <author@example.com>" \
246 --to=nobody@example.com \
247 --smtp-server="$(pwd)/fake.sendmail" \
249 sed "1,/^\$/d" < msgtxt1 > msgbody1
250 ! grep "From: A <author@example.com>" msgbody1
253 test_expect_success
'allow long lines with --no-validate' '
255 --from="Example <nobody@example.com>" \
256 --to=nobody@example.com \
257 --smtp-server="$(pwd)/fake.sendmail" \
259 $patches longline.patch \
263 test_expect_success
'Invalid In-Reply-To' '
264 clean_fake_sendmail &&
266 --from="Example <nobody@example.com>" \
267 --to=nobody@example.com \
269 --smtp-server="$(pwd)/fake.sendmail" \
272 ! grep "^In-Reply-To: < *>" msgtxt1
275 test_expect_success
'Valid In-Reply-To when prompting' '
276 clean_fake_sendmail &&
277 (echo "From Example <from@example.com>"
278 echo "To Example <to@example.com>"
280 ) | env GIT_SEND_EMAIL_NOTTY=1 git send-email \
281 --smtp-server="$(pwd)/fake.sendmail" \
283 ! grep "^In-Reply-To: < *>" msgtxt1
286 test_expect_success
'setup fake editor' '
287 (echo "#!$SHELL_PATH" &&
288 echo "echo fake edit >>\"\$1\""
293 test_set_editor
"$(pwd)/fake-editor"
295 test_expect_success
'--compose works' '
296 clean_fake_sendmail &&
298 --compose --subject foo \
299 --from="Example <nobody@example.com>" \
300 --to=nobody@example.com \
301 --smtp-server="$(pwd)/fake.sendmail" \
306 test_expect_success
'first message is compose text' '
307 grep "^fake edit" msgtxt1
310 test_expect_success
'second message is patch' '
311 grep "Subject:.*Second" msgtxt2
314 cat >expected-suppress-sob
<<\EOF
316 (mbox
) Adding cc
: A
<author@example.com
> from line
'From: A <author@example.com>'
317 (mbox
) Adding cc
: One
<one@example.com
> from line
'Cc: One <one@example.com>, two@example.com'
318 (mbox
) Adding cc
: two@example.com from line
'Cc: One <one@example.com>, two@example.com'
320 Server
: relay.example.com
321 MAIL FROM
:<from@example.com
>
322 RCPT TO
:<to@example.com
>
323 RCPT TO
:<cc@example.com
>
324 RCPT TO
:<author@example.com
>
325 RCPT TO
:<one@example.com
>
326 RCPT TO
:<two@example.com
>
327 From
: Example
<from@example.com
>
330 A
<author@example.com
>,
331 One
<one@example.com
>,
333 Subject
: [PATCH
1/1] Second.
335 Message-Id
: MESSAGE-ID-STRING
336 X-Mailer
: X-MAILER-STRING
341 test_suppression
() {
344 --suppress-cc=$1 ${2+"--suppress-cc=$2"} \
345 --from="Example <from@example.com>" \
346 --to=to@example.com \
347 --smtp-server relay.example.com \
349 sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
350 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
351 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
352 >actual-suppress-
$1${2+"-$2"} &&
353 test_cmp expected-suppress-
$1${2+"-$2"} actual-suppress-
$1${2+"-$2"}
356 test_expect_success
'sendemail.cc set' '
357 git config sendemail.cc cc@example.com &&
361 cat >expected-suppress-sob
<<\EOF
363 (mbox
) Adding cc
: A
<author@example.com
> from line
'From: A <author@example.com>'
364 (mbox
) Adding cc
: One
<one@example.com
> from line
'Cc: One <one@example.com>, two@example.com'
365 (mbox
) Adding cc
: two@example.com from line
'Cc: One <one@example.com>, two@example.com'
367 Server
: relay.example.com
368 MAIL FROM
:<from@example.com
>
369 RCPT TO
:<to@example.com
>
370 RCPT TO
:<author@example.com
>
371 RCPT TO
:<one@example.com
>
372 RCPT TO
:<two@example.com
>
373 From
: Example
<from@example.com
>
375 Cc
: A
<author@example.com
>,
376 One
<one@example.com
>,
378 Subject
: [PATCH
1/1] Second.
380 Message-Id
: MESSAGE-ID-STRING
381 X-Mailer
: X-MAILER-STRING
386 test_expect_success
'sendemail.cc unset' '
387 git config --unset sendemail.cc &&
391 cat >expected-suppress-cccmd
<<\EOF
393 (mbox
) Adding cc
: A
<author@example.com
> from line
'From: A <author@example.com>'
394 (mbox
) Adding cc
: One
<one@example.com
> from line
'Cc: One <one@example.com>, two@example.com'
395 (mbox
) Adding cc
: two@example.com from line
'Cc: One <one@example.com>, two@example.com'
396 (body
) Adding cc
: C O Mitter
<committer@example.com
> from line
'Signed-off-by: C O Mitter <committer@example.com>'
398 Server
: relay.example.com
399 MAIL FROM
:<from@example.com
>
400 RCPT TO
:<to@example.com
>
401 RCPT TO
:<author@example.com
>
402 RCPT TO
:<one@example.com
>
403 RCPT TO
:<two@example.com
>
404 RCPT TO
:<committer@example.com
>
405 From
: Example
<from@example.com
>
407 Cc
: A
<author@example.com
>,
408 One
<one@example.com
>,
410 C O Mitter
<committer@example.com
>
411 Subject
: [PATCH
1/1] Second.
413 Message-Id
: MESSAGE-ID-STRING
414 X-Mailer
: X-MAILER-STRING
419 test_expect_success
'sendemail.cccmd' '
420 echo echo cc-cmd@example.com > cccmd &&
422 git config sendemail.cccmd ./cccmd &&
423 test_suppression cccmd
426 cat >expected-suppress-all
<<\EOF
429 Server
: relay.example.com
430 MAIL FROM
:<from@example.com
>
431 RCPT TO
:<to@example.com
>
432 From
: Example
<from@example.com
>
434 Subject
: [PATCH
1/1] Second.
436 Message-Id
: MESSAGE-ID-STRING
437 X-Mailer
: X-MAILER-STRING
442 test_expect_success
'--suppress-cc=all' '
446 cat >expected-suppress-body
<<\EOF
448 (mbox
) Adding cc
: A
<author@example.com
> from line
'From: A <author@example.com>'
449 (mbox
) Adding cc
: One
<one@example.com
> from line
'Cc: One <one@example.com>, two@example.com'
450 (mbox
) Adding cc
: two@example.com from line
'Cc: One <one@example.com>, two@example.com'
451 (cc-cmd
) Adding cc
: cc-cmd@example.com from
: './cccmd'
453 Server
: relay.example.com
454 MAIL FROM
:<from@example.com
>
455 RCPT TO
:<to@example.com
>
456 RCPT TO
:<author@example.com
>
457 RCPT TO
:<one@example.com
>
458 RCPT TO
:<two@example.com
>
459 RCPT TO
:<cc-cmd@example.com
>
460 From
: Example
<from@example.com
>
462 Cc
: A
<author@example.com
>,
463 One
<one@example.com
>,
466 Subject
: [PATCH
1/1] Second.
468 Message-Id
: MESSAGE-ID-STRING
469 X-Mailer
: X-MAILER-STRING
474 test_expect_success
'--suppress-cc=body' '
475 test_suppression body
478 cat >expected-suppress-body-cccmd
<<\EOF
480 (mbox
) Adding cc
: A
<author@example.com
> from line
'From: A <author@example.com>'
481 (mbox
) Adding cc
: One
<one@example.com
> from line
'Cc: One <one@example.com>, two@example.com'
482 (mbox
) Adding cc
: two@example.com from line
'Cc: One <one@example.com>, two@example.com'
484 Server
: relay.example.com
485 MAIL FROM
:<from@example.com
>
486 RCPT TO
:<to@example.com
>
487 RCPT TO
:<author@example.com
>
488 RCPT TO
:<one@example.com
>
489 RCPT TO
:<two@example.com
>
490 From
: Example
<from@example.com
>
492 Cc
: A
<author@example.com
>,
493 One
<one@example.com
>,
495 Subject
: [PATCH
1/1] Second.
497 Message-Id
: MESSAGE-ID-STRING
498 X-Mailer
: X-MAILER-STRING
503 test_expect_success
'--suppress-cc=body --suppress-cc=cccmd' '
504 test_suppression body cccmd
507 cat >expected-suppress-sob
<<\EOF
509 (mbox
) Adding cc
: A
<author@example.com
> from line
'From: A <author@example.com>'
510 (mbox
) Adding cc
: One
<one@example.com
> from line
'Cc: One <one@example.com>, two@example.com'
511 (mbox
) Adding cc
: two@example.com from line
'Cc: One <one@example.com>, two@example.com'
513 Server
: relay.example.com
514 MAIL FROM
:<from@example.com
>
515 RCPT TO
:<to@example.com
>
516 RCPT TO
:<author@example.com
>
517 RCPT TO
:<one@example.com
>
518 RCPT TO
:<two@example.com
>
519 From
: Example
<from@example.com
>
521 Cc
: A
<author@example.com
>,
522 One
<one@example.com
>,
524 Subject
: [PATCH
1/1] Second.
526 Message-Id
: MESSAGE-ID-STRING
527 X-Mailer
: X-MAILER-STRING
532 test_expect_success
'--suppress-cc=sob' '
533 git config --unset sendemail.cccmd
537 cat >expected-suppress-bodycc
<<\EOF
539 (mbox
) Adding cc
: A
<author@example.com
> from line
'From: A <author@example.com>'
540 (mbox
) Adding cc
: One
<one@example.com
> from line
'Cc: One <one@example.com>, two@example.com'
541 (mbox
) Adding cc
: two@example.com from line
'Cc: One <one@example.com>, two@example.com'
542 (body
) Adding cc
: C O Mitter
<committer@example.com
> from line
'Signed-off-by: C O Mitter <committer@example.com>'
544 Server
: relay.example.com
545 MAIL FROM
:<from@example.com
>
546 RCPT TO
:<to@example.com
>
547 RCPT TO
:<author@example.com
>
548 RCPT TO
:<one@example.com
>
549 RCPT TO
:<two@example.com
>
550 RCPT TO
:<committer@example.com
>
551 From
: Example
<from@example.com
>
553 Cc
: A
<author@example.com
>,
554 One
<one@example.com
>,
556 C O Mitter
<committer@example.com
>
557 Subject
: [PATCH
1/1] Second.
559 Message-Id
: MESSAGE-ID-STRING
560 X-Mailer
: X-MAILER-STRING
565 test_expect_success
'--suppress-cc=bodycc' '
566 test_suppression bodycc
569 cat >expected-suppress-cc
<<\EOF
571 (mbox
) Adding cc
: A
<author@example.com
> from line
'From: A <author@example.com>'
572 (body
) Adding cc
: C O Mitter
<committer@example.com
> from line
'Signed-off-by: C O Mitter <committer@example.com>'
574 Server
: relay.example.com
575 MAIL FROM
:<from@example.com
>
576 RCPT TO
:<to@example.com
>
577 RCPT TO
:<author@example.com
>
578 RCPT TO
:<committer@example.com
>
579 From
: Example
<from@example.com
>
581 Cc
: A
<author@example.com
>,
582 C O Mitter
<committer@example.com
>
583 Subject
: [PATCH
1/1] Second.
585 Message-Id
: MESSAGE-ID-STRING
586 X-Mailer
: X-MAILER-STRING
591 test_expect_success
'--suppress-cc=cc' '
597 GIT_SEND_EMAIL_NOTTY
=1 \
599 --from="Example <nobody@example.com>" \
600 --to=nobody@example.com \
601 --smtp-server="$(pwd)/fake.sendmail" \
602 $@
$patches > stdout
&&
603 grep "Send this email" stdout
606 test_expect_success
'--confirm=always' '
607 test_confirm --confirm=always --suppress-cc=all
610 test_expect_success
'--confirm=auto' '
611 test_confirm --confirm=auto
614 test_expect_success
'--confirm=cc' '
615 test_confirm --confirm=cc
618 test_expect_success
'--confirm=compose' '
619 test_confirm --confirm=compose --compose
622 test_expect_success
'confirm by default (due to cc)' '
623 CONFIRM=$(git config --get sendemail.confirm) &&
624 git config --unset sendemail.confirm &&
627 git config sendemail.confirm ${CONFIRM:-never}
631 test_expect_success
'confirm by default (due to --compose)' '
632 CONFIRM=$(git config --get sendemail.confirm) &&
633 git config --unset sendemail.confirm &&
634 test_confirm --suppress-cc=all --compose
636 git config sendemail.confirm ${CONFIRM:-never}
640 test_expect_success
'confirm detects EOF (inform assumes y)' '
641 CONFIRM=$(git config --get sendemail.confirm) &&
642 git config --unset sendemail.confirm &&
644 git format-patch -2 -o outdir &&
645 GIT_SEND_EMAIL_NOTTY=1 \
647 --from="Example <nobody@example.com>" \
648 --to=nobody@example.com \
649 --smtp-server="$(pwd)/fake.sendmail" \
650 outdir/*.patch < /dev/null
652 git config sendemail.confirm ${CONFIRM:-never}
656 test_expect_success
'confirm detects EOF (auto causes failure)' '
657 CONFIRM=$(git config --get sendemail.confirm) &&
658 git config sendemail.confirm auto &&
659 GIT_SEND_EMAIL_NOTTY=1 &&
660 export GIT_SEND_EMAIL_NOTTY &&
661 test_must_fail git send-email \
662 --from="Example <nobody@example.com>" \
663 --to=nobody@example.com \
664 --smtp-server="$(pwd)/fake.sendmail" \
667 git config sendemail.confirm ${CONFIRM:-never}
671 test_expect_success
'confirm doesnt loop forever' '
672 CONFIRM=$(git config --get sendemail.confirm) &&
673 git config sendemail.confirm auto &&
674 GIT_SEND_EMAIL_NOTTY=1 &&
675 export GIT_SEND_EMAIL_NOTTY &&
676 yes "bogus" | test_must_fail git send-email \
677 --from="Example <nobody@example.com>" \
678 --to=nobody@example.com \
679 --smtp-server="$(pwd)/fake.sendmail" \
682 git config sendemail.confirm ${CONFIRM:-never}
686 test_expect_success
'utf8 Cc is rfc2047 encoded' '
687 clean_fake_sendmail &&
689 git format-patch -1 -o outdir --cc="àéìöú <utf8@example.com>" &&
691 --from="Example <nobody@example.com>" \
692 --to=nobody@example.com \
693 --smtp-server="$(pwd)/fake.sendmail" \
696 grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>"
699 test_expect_success
'--compose adds MIME for utf8 body' '
700 clean_fake_sendmail &&
701 (echo "#!$SHELL_PATH" &&
702 echo "echo utf8 body: àéìöú >>\"\$1\""
703 ) >fake-editor-utf8 &&
704 chmod +x fake-editor-utf8 &&
705 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
707 --compose --subject foo \
708 --from="Example <nobody@example.com>" \
709 --to=nobody@example.com \
710 --smtp-server="$(pwd)/fake.sendmail" \
712 grep "^utf8 body" msgtxt1 &&
713 grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
716 test_expect_success
'--compose respects user mime type' '
717 clean_fake_sendmail &&
718 (echo "#!$SHELL_PATH" &&
719 echo "(echo MIME-Version: 1.0"
720 echo " echo Content-Type: text/plain\\; charset=iso-8859-1"
721 echo " echo Content-Transfer-Encoding: 8bit"
722 echo " echo Subject: foo"
724 echo " echo utf8 body: àéìöú) >\"\$1\""
725 ) >fake-editor-utf8-mime &&
726 chmod +x fake-editor-utf8-mime &&
727 GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \
729 --compose --subject foo \
730 --from="Example <nobody@example.com>" \
731 --to=nobody@example.com \
732 --smtp-server="$(pwd)/fake.sendmail" \
734 grep "^utf8 body" msgtxt1 &&
735 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 &&
736 ! grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
739 test_expect_success
'--compose adds MIME for utf8 subject' '
740 clean_fake_sendmail &&
741 GIT_EDITOR="\"$(pwd)/fake-editor\"" \
743 --compose --subject utf8-sübjëct \
744 --from="Example <nobody@example.com>" \
745 --to=nobody@example.com \
746 --smtp-server="$(pwd)/fake.sendmail" \
748 grep "^fake edit" msgtxt1 &&
749 grep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
752 test_expect_success
'detects ambiguous reference/file conflict' '
753 echo master > master &&
755 git commit -m"add master" &&
756 test_must_fail git send-email --dry-run master 2>errors &&
757 grep disambiguate errors
760 test_expect_success
'feed two files' '
762 git format-patch -2 -o outdir &&
765 --from="Example <nobody@example.com>" \
766 --to=nobody@example.com \
767 outdir/000?-*.patch 2>errors >out &&
768 grep "^Subject: " out >subjects &&
769 test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." &&
770 test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add master"
773 test_expect_success
'in-reply-to but no threading' '
776 --from="Example <nobody@example.com>" \
777 --to=nobody@example.com \
778 --in-reply-to="<in-reply-id@example.com>" \
781 grep "In-Reply-To: <in-reply-id@example.com>"
784 test_expect_success
'no in-reply-to and no threading' '
787 --from="Example <nobody@example.com>" \
788 --to=nobody@example.com \
790 $patches $patches >stdout &&
791 ! grep "In-Reply-To: " stdout
794 test_expect_success
'threading but no chain-reply-to' '
797 --from="Example <nobody@example.com>" \
798 --to=nobody@example.com \
801 $patches $patches >stdout &&
802 grep "In-Reply-To: " stdout
805 test_expect_success
'warning with an implicit --chain-reply-to' '
808 --from="Example <nobody@example.com>" \
809 --to=nobody@example.com \
810 outdir/000?-*.patch 2>errors >out &&
811 grep "no-chain-reply-to" errors
814 test_expect_success
'no warning with an explicit --chain-reply-to' '
817 --from="Example <nobody@example.com>" \
818 --to=nobody@example.com \
820 outdir/000?-*.patch 2>errors >out &&
821 ! grep "no-chain-reply-to" errors
824 test_expect_success
'no warning with an explicit --no-chain-reply-to' '
827 --from="Example <nobody@example.com>" \
828 --to=nobody@example.com \
830 outdir/000?-*.patch 2>errors >out &&
831 ! grep "no-chain-reply-to" errors
834 test_expect_success
'no warning with sendemail.chainreplyto = false' '
835 git config sendemail.chainreplyto false &&
838 --from="Example <nobody@example.com>" \
839 --to=nobody@example.com \
840 outdir/000?-*.patch 2>errors >out &&
841 ! grep "no-chain-reply-to" errors
844 test_expect_success
'no warning with sendemail.chainreplyto = true' '
845 git config sendemail.chainreplyto true &&
848 --from="Example <nobody@example.com>" \
849 --to=nobody@example.com \
850 outdir/000?-*.patch 2>errors >out &&
851 ! grep "no-chain-reply-to" errors
854 test_expect_success
'sendemail.to works' '
855 git config --replace-all sendemail.to "Somebody <somebody@ex.com>" &&
858 --from="Example <nobody@example.com>" \
859 $patches $patches >stdout &&
860 grep "To: Somebody <somebody@ex.com>" stdout
863 test_expect_success
'--no-to overrides sendemail.to' '
866 --from="Example <nobody@example.com>" \
868 --to=nobody@example.com \
869 $patches $patches >stdout &&
870 grep "To: nobody@example.com" stdout &&
871 ! grep "To: Somebody <somebody@ex.com>" stdout
874 test_expect_success
'sendemail.cc works' '
875 git config --replace-all sendemail.cc "Somebody <somebody@ex.com>" &&
878 --from="Example <nobody@example.com>" \
879 --to=nobody@example.com \
880 $patches $patches >stdout &&
881 grep "Cc: Somebody <somebody@ex.com>" stdout
884 test_expect_success
'--no-cc overrides sendemail.cc' '
887 --from="Example <nobody@example.com>" \
889 --cc=bodies@example.com \
890 --to=nobody@example.com \
891 $patches $patches >stdout &&
892 grep "Cc: bodies@example.com" stdout &&
893 ! grep "Cc: Somebody <somebody@ex.com>" stdout
896 test_expect_success
'sendemail.bcc works' '
897 git config --replace-all sendemail.bcc "Other <other@ex.com>" &&
900 --from="Example <nobody@example.com>" \
901 --to=nobody@example.com \
902 --smtp-server relay.example.com \
903 $patches $patches >stdout &&
904 grep "RCPT TO:<other@ex.com>" stdout
907 test_expect_success
'--no-bcc overrides sendemail.bcc' '
910 --from="Example <nobody@example.com>" \
912 --bcc=bodies@example.com \
913 --to=nobody@example.com \
914 --smtp-server relay.example.com \
915 $patches $patches >stdout &&
916 grep "RCPT TO:<bodies@example.com>" stdout &&
917 ! grep "RCPT TO:<other@ex.com>" stdout
920 cat >email-using-8bit
<<EOF
921 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
922 Message-Id: <bogus-message-id@example.com>
923 From: author@example.com
924 Date: Sat, 12 Jun 2010 15:53:58 +0200
925 Subject: subject goes here
927 Dieser deutsche Text enthält einen Umlaut!
930 cat >content-type-decl
<<EOF
932 Content-Type: text/plain; charset=UTF-8
933 Content-Transfer-Encoding: 8bit
936 test_expect_success
'asks about and fixes 8bit encodings' '
937 clean_fake_sendmail &&
939 git send-email --from=author@example.com --to=nobody@example.com \
940 --smtp-server="$(pwd)/fake.sendmail" \
941 email-using-8bit >stdout &&
942 grep "do not declare a Content-Transfer-Encoding" stdout &&
943 grep email-using-8bit stdout &&
944 grep "Which 8bit encoding" stdout &&
945 egrep "Content|MIME" msgtxt1 >actual &&
946 test_cmp actual content-type-decl
949 test_expect_success
'sendemail.8bitEncoding works' '
950 clean_fake_sendmail &&
951 git config sendemail.assume8bitEncoding UTF-8 &&
953 git send-email --from=author@example.com --to=nobody@example.com \
954 --smtp-server="$(pwd)/fake.sendmail" \
955 email-using-8bit >stdout &&
956 egrep "Content|MIME" msgtxt1 >actual &&
957 test_cmp actual content-type-decl
960 test_expect_success
'--8bit-encoding overrides sendemail.8bitEncoding' '
961 clean_fake_sendmail &&
962 git config sendemail.assume8bitEncoding "bogus too" &&
964 git send-email --from=author@example.com --to=nobody@example.com \
965 --smtp-server="$(pwd)/fake.sendmail" \
966 --8bit-encoding=UTF-8 \
967 email-using-8bit >stdout &&
968 egrep "Content|MIME" msgtxt1 >actual &&
969 test_cmp actual content-type-decl
972 cat >email-using-8bit
<<EOF
973 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
974 Message-Id: <bogus-message-id@example.com>
975 From: author@example.com
976 Date: Sat, 12 Jun 2010 15:53:58 +0200
977 Subject: Dieser Betreff enthält auch einen Umlaut!
983 Subject: =?UTF-8?q?Dieser=20Betreff=20enth=C3=A4lt=20auch=20einen=20Umlaut!?=
986 test_expect_success
'--8bit-encoding also treats subject' '
987 clean_fake_sendmail &&
989 git send-email --from=author@example.com --to=nobody@example.com \
990 --smtp-server="$(pwd)/fake.sendmail" \
991 --8bit-encoding=UTF-8 \
992 email-using-8bit >stdout &&
993 grep "Subject" msgtxt1 >actual &&
994 test_cmp expected actual