3 test_description='git send-email'
6 # May be altered later in the test
9 test_expect_success $PREREQ 'prepare reference tree' '
10 echo "1A quick brown fox jumps over the" >file &&
11 echo "lazy dog" >>file &&
13 GIT_AUTHOR_NAME="A" git commit -a -m "Initial."
16 test_expect_success $PREREQ 'Setup helper tool' '
17 write_script fake.sendmail <<-\EOF &&
20 while test -f commandline$output
27 done >commandline$output
30 git add fake.sendmail &&
31 GIT_AUTHOR_NAME="A" git commit -a -m "Second."
34 clean_fake_sendmail () {
35 rm -f commandline* msgtxt*
38 test_expect_success $PREREQ '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 if ! test -f no_confirm_okay
61 say 'confirm test failed; skipping remaining tests to prevent hanging'
62 PREREQ="$PREREQ,CHECK_NO_CONFIRM"
67 test_expect_success $PREREQ 'No confirm with --suppress-cc' '
68 test_no_confirm --suppress-cc=sob &&
73 test_expect_success $PREREQ 'No confirm with --confirm=never' '
74 test_no_confirm --confirm=never &&
78 # leave sendemail.confirm set to never after this so that none of the
79 # remaining tests prompt unintentionally.
80 test_expect_success $PREREQ 'No confirm with sendemail.confirm=never' '
81 git config sendemail.confirm never &&
82 test_no_confirm --compose --subject=foo &&
86 test_expect_success $PREREQ 'Send patches' '
87 git send-email --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors
90 test_expect_success $PREREQ 'setup expect' '
99 test_expect_success $PREREQ 'Verify commandline' '
100 test_cmp expected commandline1
103 test_expect_success $PREREQ 'Send patches with --envelope-sender' '
104 clean_fake_sendmail &&
105 git send-email --envelope-sender="Patch Contributor <patch@example.com>" --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors
108 test_expect_success $PREREQ 'setup expect' '
109 cat >expected <<-\EOF
119 test_expect_success $PREREQ 'Verify commandline' '
120 test_cmp expected commandline1
123 test_expect_success $PREREQ 'Send patches with --envelope-sender=auto' '
124 clean_fake_sendmail &&
125 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 $PREREQ 'setup expect' '
129 cat >expected <<-\EOF
139 test_expect_success $PREREQ 'Verify commandline' '
140 test_cmp expected commandline1
143 test_expect_success $PREREQ 'setup expect' "
144 cat >expected-show-all-headers <<\EOF
146 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
147 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
148 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
150 Server: relay.example.com
151 MAIL FROM:<from@example.com>
152 RCPT TO:<to@example.com>
153 RCPT TO:<cc@example.com>
154 RCPT TO:<author@example.com>
155 RCPT TO:<one@example.com>
156 RCPT TO:<two@example.com>
157 RCPT TO:<bcc@example.com>
158 From: Example <from@example.com>
161 A <author@example.com>,
162 One <one@example.com>,
164 Subject: [PATCH 1/1] Second.
166 Message-Id: MESSAGE-ID-STRING
167 X-Mailer: X-MAILER-STRING
168 In-Reply-To: <unique-message-id@example.com>
169 References: <unique-message-id@example.com>
175 test_suppress_self () {
177 test_when_finished "git reset --hard HEAD^" &&
179 write_script cccmd-sed <<-EOF &&
180 sed -n -e s/^cccmd--//p "\$1"
183 git commit --amend --author="$1 <$2>" -F - &&
184 clean_fake_sendmail &&
185 git format-patch --stdout -1 >"suppress-self-$3.patch" &&
187 git send-email --from="$1 <$2>" \
188 --to=nobody@example.com \
189 --cc-cmd=./cccmd-sed \
191 --smtp-server="$(pwd)/fake.sendmail" \
192 suppress-self-$3.patch &&
194 mv msgtxt1 msgtxt1-$3 &&
195 sed -e '/^$/q' msgtxt1-$3 >"msghdr1-$3" &&
196 >"expected-no-cc-$3" &&
198 (grep '^Cc:' msghdr1-$3 >"actual-no-cc-$3";
199 test_cmp expected-no-cc-$3 actual-no-cc-$3)
202 test_suppress_self_unquoted () {
203 test_suppress_self "$1" "$2" "unquoted-$3" <<-EOF
204 test suppress-cc.self unquoted-$3 with name $1 email $2
211 Signed-off-by: $1 <$2>
215 test_suppress_self_quoted () {
216 test_suppress_self "$1" "$2" "quoted-$3" <<-EOF
217 test suppress-cc.self quoted-$3 with name $1 email $2
225 Signed-off-by: $1 <$2>
226 Signed-off-by: "$1" <$2>
230 test_expect_success $PREREQ 'self name is suppressed' "
231 test_suppress_self_unquoted 'A U Thor' 'author@example.com' \
232 'self_name_suppressed'
235 test_expect_success $PREREQ 'self name with dot is suppressed' "
236 test_suppress_self_quoted 'A U. Thor' 'author@example.com' \
237 'self_name_dot_suppressed'
240 test_expect_success $PREREQ 'non-ascii self name is suppressed' "
241 test_suppress_self_quoted 'Füñný Nâmé' 'odd_?=mail@example.com' \
242 'non_ascii_self_suppressed'
245 # This name is long enough to force format-patch to split it into multiple
246 # encoded-words, assuming it uses UTF-8 with the "Q" encoding.
247 test_expect_success $PREREQ 'long non-ascii self name is suppressed' "
248 test_suppress_self_quoted 'Ƒüñníęř €. Nâṁé' 'odd_?=mail@example.com' \
249 'long_non_ascii_self_suppressed'
252 test_expect_success $PREREQ 'sanitized self name is suppressed' "
253 test_suppress_self_unquoted '\"A U. Thor\"' 'author@example.com' \
254 'self_name_sanitized_suppressed'
257 test_expect_success $PREREQ 'Show all headers' '
261 --from="Example <from@example.com>" \
262 --to=to@example.com \
263 --cc=cc@example.com \
264 --bcc=bcc@example.com \
265 --in-reply-to="<unique-message-id@example.com>" \
266 --smtp-server relay.example.com \
268 sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
269 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
270 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
271 >actual-show-all-headers &&
272 test_cmp expected-show-all-headers actual-show-all-headers
275 test_expect_success $PREREQ 'Prompting works' '
276 clean_fake_sendmail &&
277 (echo "to@example.com"
279 ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
280 --smtp-server="$(pwd)/fake.sendmail" \
283 grep "^From: A U Thor <author@example.com>\$" msgtxt1 &&
284 grep "^To: to@example.com\$" msgtxt1
287 test_expect_success $PREREQ,AUTOIDENT 'implicit ident is allowed' '
288 clean_fake_sendmail &&
289 (sane_unset GIT_AUTHOR_NAME &&
290 sane_unset GIT_AUTHOR_EMAIL &&
291 sane_unset GIT_COMMITTER_NAME &&
292 sane_unset GIT_COMMITTER_EMAIL &&
293 GIT_SEND_EMAIL_NOTTY=1 git send-email \
294 --smtp-server="$(pwd)/fake.sendmail" \
295 --to=to@example.com \
296 $patches </dev/null 2>errors
300 test_expect_success $PREREQ,!AUTOIDENT 'broken implicit ident aborts send-email' '
301 clean_fake_sendmail &&
302 (sane_unset GIT_AUTHOR_NAME &&
303 sane_unset GIT_AUTHOR_EMAIL &&
304 sane_unset GIT_COMMITTER_NAME &&
305 sane_unset GIT_COMMITTER_EMAIL &&
306 GIT_SEND_EMAIL_NOTTY=1 && export GIT_SEND_EMAIL_NOTTY &&
307 test_must_fail git send-email \
308 --smtp-server="$(pwd)/fake.sendmail" \
309 --to=to@example.com \
310 $patches </dev/null 2>errors &&
311 test_i18ngrep "tell me who you are" errors
315 test_expect_success $PREREQ 'tocmd works' '
316 clean_fake_sendmail &&
317 cp $patches tocmd.patch &&
318 echo tocmd--tocmd@example.com >>tocmd.patch &&
319 write_script tocmd-sed <<-\EOF &&
320 sed -n -e "s/^tocmd--//p" "$1"
323 --from="Example <nobody@example.com>" \
324 --to-cmd=./tocmd-sed \
325 --smtp-server="$(pwd)/fake.sendmail" \
328 grep "^To: tocmd@example.com" msgtxt1
331 test_expect_success $PREREQ 'cccmd works' '
332 clean_fake_sendmail &&
333 cp $patches cccmd.patch &&
334 echo "cccmd-- cccmd@example.com" >>cccmd.patch &&
335 write_script cccmd-sed <<-\EOF &&
336 sed -n -e "s/^cccmd--//p" "$1"
339 --from="Example <nobody@example.com>" \
340 --to=nobody@example.com \
341 --cc-cmd=./cccmd-sed \
342 --smtp-server="$(pwd)/fake.sendmail" \
345 grep "^ cccmd@example.com" msgtxt1
348 test_expect_success $PREREQ 'reject long lines' '
350 z64=$z8$z8$z8$z8$z8$z8$z8$z8 &&
351 z512=$z64$z64$z64$z64$z64$z64$z64$z64 &&
352 clean_fake_sendmail &&
353 cp $patches longline.patch &&
354 echo $z512$z512 >>longline.patch &&
355 test_must_fail git send-email \
356 --from="Example <nobody@example.com>" \
357 --to=nobody@example.com \
358 --smtp-server="$(pwd)/fake.sendmail" \
359 $patches longline.patch \
361 grep longline.patch errors
364 test_expect_success $PREREQ 'no patch was sent' '
365 ! test -e commandline1
368 test_expect_success $PREREQ 'Author From: in message body' '
369 clean_fake_sendmail &&
371 --from="Example <nobody@example.com>" \
372 --to=nobody@example.com \
373 --smtp-server="$(pwd)/fake.sendmail" \
375 sed "1,/^\$/d" <msgtxt1 >msgbody1 &&
376 grep "From: A <author@example.com>" msgbody1
379 test_expect_success $PREREQ 'Author From: not in message body' '
380 clean_fake_sendmail &&
382 --from="A <author@example.com>" \
383 --to=nobody@example.com \
384 --smtp-server="$(pwd)/fake.sendmail" \
386 sed "1,/^\$/d" <msgtxt1 >msgbody1 &&
387 ! grep "From: A <author@example.com>" msgbody1
390 test_expect_success $PREREQ 'allow long lines with --no-validate' '
392 --from="Example <nobody@example.com>" \
393 --to=nobody@example.com \
394 --smtp-server="$(pwd)/fake.sendmail" \
396 $patches longline.patch \
400 test_expect_success $PREREQ 'Invalid In-Reply-To' '
401 clean_fake_sendmail &&
403 --from="Example <nobody@example.com>" \
404 --to=nobody@example.com \
406 --smtp-server="$(pwd)/fake.sendmail" \
409 ! grep "^In-Reply-To: < *>" msgtxt1
412 test_expect_success $PREREQ 'Valid In-Reply-To when prompting' '
413 clean_fake_sendmail &&
414 (echo "From Example <from@example.com>"
415 echo "To Example <to@example.com>"
417 ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
418 --smtp-server="$(pwd)/fake.sendmail" \
420 ! grep "^In-Reply-To: < *>" msgtxt1
423 test_expect_success $PREREQ 'In-Reply-To without --chain-reply-to' '
424 clean_fake_sendmail &&
425 echo "<unique-message-id@example.com>" >expect &&
427 --from="Example <nobody@example.com>" \
428 --to=nobody@example.com \
429 --no-chain-reply-to \
430 --in-reply-to="$(cat expect)" \
431 --smtp-server="$(pwd)/fake.sendmail" \
432 $patches $patches $patches \
434 # The first message is a reply to --in-reply-to
435 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual &&
436 test_cmp expect actual &&
437 # Second and subsequent messages are replies to the first one
438 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect &&
439 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual &&
440 test_cmp expect actual &&
441 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual &&
442 test_cmp expect actual
445 test_expect_success $PREREQ 'In-Reply-To with --chain-reply-to' '
446 clean_fake_sendmail &&
447 echo "<unique-message-id@example.com>" >expect &&
449 --from="Example <nobody@example.com>" \
450 --to=nobody@example.com \
452 --in-reply-to="$(cat expect)" \
453 --smtp-server="$(pwd)/fake.sendmail" \
454 $patches $patches $patches \
456 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual &&
457 test_cmp expect actual &&
458 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect &&
459 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual &&
460 test_cmp expect actual &&
461 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt2 >expect &&
462 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual &&
463 test_cmp expect actual
466 test_expect_success $PREREQ 'setup fake editor' '
467 write_script fake-editor <<-\EOF
468 echo fake edit >>"$1"
472 test_set_editor "$(pwd)/fake-editor"
474 test_expect_success $PREREQ '--compose works' '
475 clean_fake_sendmail &&
477 --compose --subject foo \
478 --from="Example <nobody@example.com>" \
479 --to=nobody@example.com \
480 --smtp-server="$(pwd)/fake.sendmail" \
485 test_expect_success $PREREQ 'first message is compose text' '
486 grep "^fake edit" msgtxt1
489 test_expect_success $PREREQ 'second message is patch' '
490 grep "Subject:.*Second" msgtxt2
493 test_expect_success $PREREQ 'setup expect' "
494 cat >expected-suppress-sob <<\EOF
496 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
497 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
498 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
500 Server: relay.example.com
501 MAIL FROM:<from@example.com>
502 RCPT TO:<to@example.com>
503 RCPT TO:<cc@example.com>
504 RCPT TO:<author@example.com>
505 RCPT TO:<one@example.com>
506 RCPT TO:<two@example.com>
507 From: Example <from@example.com>
510 A <author@example.com>,
511 One <one@example.com>,
513 Subject: [PATCH 1/1] Second.
515 Message-Id: MESSAGE-ID-STRING
516 X-Mailer: X-MAILER-STRING
522 test_suppression () {
525 --suppress-cc=$1 ${2+"--suppress-cc=$2"} \
526 --from="Example <from@example.com>" \
527 --to=to@example.com \
528 --smtp-server relay.example.com \
530 sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
531 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
532 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
533 >actual-suppress-$1${2+"-$2"} &&
534 test_cmp expected-suppress-$1${2+"-$2"} actual-suppress-$1${2+"-$2"}
537 test_expect_success $PREREQ 'sendemail.cc set' '
538 git config sendemail.cc cc@example.com &&
542 test_expect_success $PREREQ 'setup expect' "
543 cat >expected-suppress-sob <<\EOF
545 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
546 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
547 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
549 Server: relay.example.com
550 MAIL FROM:<from@example.com>
551 RCPT TO:<to@example.com>
552 RCPT TO:<author@example.com>
553 RCPT TO:<one@example.com>
554 RCPT TO:<two@example.com>
555 From: Example <from@example.com>
557 Cc: A <author@example.com>,
558 One <one@example.com>,
560 Subject: [PATCH 1/1] Second.
562 Message-Id: MESSAGE-ID-STRING
563 X-Mailer: X-MAILER-STRING
569 test_expect_success $PREREQ 'sendemail.cc unset' '
570 git config --unset sendemail.cc &&
574 test_expect_success $PREREQ 'setup expect' "
575 cat >expected-suppress-cccmd <<\EOF
577 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
578 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
579 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
580 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
582 Server: relay.example.com
583 MAIL FROM:<from@example.com>
584 RCPT TO:<to@example.com>
585 RCPT TO:<author@example.com>
586 RCPT TO:<one@example.com>
587 RCPT TO:<two@example.com>
588 RCPT TO:<committer@example.com>
589 From: Example <from@example.com>
591 Cc: A <author@example.com>,
592 One <one@example.com>,
594 C O Mitter <committer@example.com>
595 Subject: [PATCH 1/1] Second.
597 Message-Id: MESSAGE-ID-STRING
598 X-Mailer: X-MAILER-STRING
604 test_expect_success $PREREQ 'sendemail.cccmd' '
605 write_script cccmd <<-\EOF &&
606 echo cc-cmd@example.com
608 git config sendemail.cccmd ./cccmd &&
609 test_suppression cccmd
612 test_expect_success $PREREQ 'setup expect' '
613 cat >expected-suppress-all <<\EOF
616 Server: relay.example.com
617 MAIL FROM:<from@example.com>
618 RCPT TO:<to@example.com>
619 From: Example <from@example.com>
621 Subject: [PATCH 1/1] Second.
623 Message-Id: MESSAGE-ID-STRING
624 X-Mailer: X-MAILER-STRING
630 test_expect_success $PREREQ '--suppress-cc=all' '
634 test_expect_success $PREREQ 'setup expect' "
635 cat >expected-suppress-body <<\EOF
637 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
638 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
639 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
640 (cc-cmd) Adding cc: cc-cmd@example.com from: './cccmd'
642 Server: relay.example.com
643 MAIL FROM:<from@example.com>
644 RCPT TO:<to@example.com>
645 RCPT TO:<author@example.com>
646 RCPT TO:<one@example.com>
647 RCPT TO:<two@example.com>
648 RCPT TO:<cc-cmd@example.com>
649 From: Example <from@example.com>
651 Cc: A <author@example.com>,
652 One <one@example.com>,
655 Subject: [PATCH 1/1] Second.
657 Message-Id: MESSAGE-ID-STRING
658 X-Mailer: X-MAILER-STRING
664 test_expect_success $PREREQ '--suppress-cc=body' '
665 test_suppression body
668 test_expect_success $PREREQ 'setup expect' "
669 cat >expected-suppress-body-cccmd <<\EOF
671 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
672 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
673 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
675 Server: relay.example.com
676 MAIL FROM:<from@example.com>
677 RCPT TO:<to@example.com>
678 RCPT TO:<author@example.com>
679 RCPT TO:<one@example.com>
680 RCPT TO:<two@example.com>
681 From: Example <from@example.com>
683 Cc: A <author@example.com>,
684 One <one@example.com>,
686 Subject: [PATCH 1/1] Second.
688 Message-Id: MESSAGE-ID-STRING
689 X-Mailer: X-MAILER-STRING
695 test_expect_success $PREREQ '--suppress-cc=body --suppress-cc=cccmd' '
696 test_suppression body cccmd
699 test_expect_success $PREREQ 'setup expect' "
700 cat >expected-suppress-sob <<\EOF
702 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
703 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
704 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
706 Server: relay.example.com
707 MAIL FROM:<from@example.com>
708 RCPT TO:<to@example.com>
709 RCPT TO:<author@example.com>
710 RCPT TO:<one@example.com>
711 RCPT TO:<two@example.com>
712 From: Example <from@example.com>
714 Cc: A <author@example.com>,
715 One <one@example.com>,
717 Subject: [PATCH 1/1] Second.
719 Message-Id: MESSAGE-ID-STRING
720 X-Mailer: X-MAILER-STRING
726 test_expect_success $PREREQ '--suppress-cc=sob' '
727 test_might_fail git config --unset sendemail.cccmd &&
731 test_expect_success $PREREQ 'setup expect' "
732 cat >expected-suppress-bodycc <<\EOF
734 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
735 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
736 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
737 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
739 Server: relay.example.com
740 MAIL FROM:<from@example.com>
741 RCPT TO:<to@example.com>
742 RCPT TO:<author@example.com>
743 RCPT TO:<one@example.com>
744 RCPT TO:<two@example.com>
745 RCPT TO:<committer@example.com>
746 From: Example <from@example.com>
748 Cc: A <author@example.com>,
749 One <one@example.com>,
751 C O Mitter <committer@example.com>
752 Subject: [PATCH 1/1] Second.
754 Message-Id: MESSAGE-ID-STRING
755 X-Mailer: X-MAILER-STRING
761 test_expect_success $PREREQ '--suppress-cc=bodycc' '
762 test_suppression bodycc
765 test_expect_success $PREREQ 'setup expect' "
766 cat >expected-suppress-cc <<\EOF
768 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
769 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
771 Server: relay.example.com
772 MAIL FROM:<from@example.com>
773 RCPT TO:<to@example.com>
774 RCPT TO:<author@example.com>
775 RCPT TO:<committer@example.com>
776 From: Example <from@example.com>
778 Cc: A <author@example.com>,
779 C O Mitter <committer@example.com>
780 Subject: [PATCH 1/1] Second.
782 Message-Id: MESSAGE-ID-STRING
783 X-Mailer: X-MAILER-STRING
789 test_expect_success $PREREQ '--suppress-cc=cc' '
795 GIT_SEND_EMAIL_NOTTY=1 \
797 --from="Example <nobody@example.com>" \
798 --to=nobody@example.com \
799 --smtp-server="$(pwd)/fake.sendmail" \
800 $@ $patches >stdout &&
801 grep "Send this email" stdout
804 test_expect_success $PREREQ '--confirm=always' '
805 test_confirm --confirm=always --suppress-cc=all
808 test_expect_success $PREREQ '--confirm=auto' '
809 test_confirm --confirm=auto
812 test_expect_success $PREREQ '--confirm=cc' '
813 test_confirm --confirm=cc
816 test_expect_success $PREREQ '--confirm=compose' '
817 test_confirm --confirm=compose --compose
820 test_expect_success $PREREQ 'confirm by default (due to cc)' '
821 test_when_finished git config sendemail.confirm never &&
822 git config --unset sendemail.confirm &&
826 test_expect_success $PREREQ 'confirm by default (due to --compose)' '
827 test_when_finished git config sendemail.confirm never &&
828 git config --unset sendemail.confirm &&
829 test_confirm --suppress-cc=all --compose
832 test_expect_success $PREREQ 'confirm detects EOF (inform assumes y)' '
833 test_when_finished git config sendemail.confirm never &&
834 git config --unset sendemail.confirm &&
836 git format-patch -2 -o outdir &&
837 GIT_SEND_EMAIL_NOTTY=1 \
839 --from="Example <nobody@example.com>" \
840 --to=nobody@example.com \
841 --smtp-server="$(pwd)/fake.sendmail" \
842 outdir/*.patch </dev/null
845 test_expect_success $PREREQ 'confirm detects EOF (auto causes failure)' '
846 test_when_finished git config sendemail.confirm never &&
847 git config sendemail.confirm auto &&
848 GIT_SEND_EMAIL_NOTTY=1 &&
849 export GIT_SEND_EMAIL_NOTTY &&
850 test_must_fail git send-email \
851 --from="Example <nobody@example.com>" \
852 --to=nobody@example.com \
853 --smtp-server="$(pwd)/fake.sendmail" \
857 test_expect_success $PREREQ 'confirm does not loop forever' '
858 test_when_finished git config sendemail.confirm never &&
859 git config sendemail.confirm auto &&
860 GIT_SEND_EMAIL_NOTTY=1 &&
861 export GIT_SEND_EMAIL_NOTTY &&
862 yes "bogus" | test_must_fail git send-email \
863 --from="Example <nobody@example.com>" \
864 --to=nobody@example.com \
865 --smtp-server="$(pwd)/fake.sendmail" \
869 test_expect_success $PREREQ 'utf8 Cc is rfc2047 encoded' '
870 clean_fake_sendmail &&
872 git format-patch -1 -o outdir --cc="àéìöú <utf8@example.com>" &&
874 --from="Example <nobody@example.com>" \
875 --to=nobody@example.com \
876 --smtp-server="$(pwd)/fake.sendmail" \
879 grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>"
882 test_expect_success $PREREQ '--compose adds MIME for utf8 body' '
883 clean_fake_sendmail &&
884 write_script fake-editor-utf8 <<-\EOF &&
885 echo "utf8 body: àéìöú" >>"$1"
887 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
889 --compose --subject foo \
890 --from="Example <nobody@example.com>" \
891 --to=nobody@example.com \
892 --smtp-server="$(pwd)/fake.sendmail" \
894 grep "^utf8 body" msgtxt1 &&
895 grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
898 test_expect_success $PREREQ '--compose respects user mime type' '
899 clean_fake_sendmail &&
900 write_script fake-editor-utf8-mime <<-\EOF &&
903 Content-Type: text/plain; charset=iso-8859-1
904 Content-Transfer-Encoding: 8bit
910 GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \
912 --compose --subject foo \
913 --from="Example <nobody@example.com>" \
914 --to=nobody@example.com \
915 --smtp-server="$(pwd)/fake.sendmail" \
917 grep "^utf8 body" msgtxt1 &&
918 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 &&
919 ! grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
922 test_expect_success $PREREQ '--compose adds MIME for utf8 subject' '
923 clean_fake_sendmail &&
924 GIT_EDITOR="\"$(pwd)/fake-editor\"" \
926 --compose --subject utf8-sübjëct \
927 --from="Example <nobody@example.com>" \
928 --to=nobody@example.com \
929 --smtp-server="$(pwd)/fake.sendmail" \
931 grep "^fake edit" msgtxt1 &&
932 grep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
935 test_expect_success $PREREQ 'utf8 author is correctly passed on' '
936 clean_fake_sendmail &&
937 test_commit weird_author &&
938 test_when_finished "git reset --hard HEAD^" &&
939 git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" &&
940 git format-patch --stdout -1 >funny_name.patch &&
941 git send-email --from="Example <nobody@example.com>" \
942 --to=nobody@example.com \
943 --smtp-server="$(pwd)/fake.sendmail" \
945 grep "^From: Füñný Nâmé <odd_?=mail@example.com>" msgtxt1
948 test_expect_success $PREREQ 'utf8 sender is not duplicated' '
949 clean_fake_sendmail &&
950 test_commit weird_sender &&
951 test_when_finished "git reset --hard HEAD^" &&
952 git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" &&
953 git format-patch --stdout -1 >funny_name.patch &&
954 git send-email --from="Füñný Nâmé <odd_?=mail@example.com>" \
955 --to=nobody@example.com \
956 --smtp-server="$(pwd)/fake.sendmail" \
958 grep "^From: " msgtxt1 >msgfrom &&
959 test_line_count = 1 msgfrom
962 test_expect_success $PREREQ 'sendemail.composeencoding works' '
963 clean_fake_sendmail &&
964 git config sendemail.composeencoding iso-8859-1 &&
965 write_script fake-editor-utf8 <<-\EOF &&
966 echo "utf8 body: àéìöú" >>"$1"
968 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
970 --compose --subject foo \
971 --from="Example <nobody@example.com>" \
972 --to=nobody@example.com \
973 --smtp-server="$(pwd)/fake.sendmail" \
975 grep "^utf8 body" msgtxt1 &&
976 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1
979 test_expect_success $PREREQ '--compose-encoding works' '
980 clean_fake_sendmail &&
981 write_script fake-editor-utf8 <<-\EOF &&
982 echo "utf8 body: àéìöú" >>"$1"
984 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
986 --compose-encoding iso-8859-1 \
987 --compose --subject foo \
988 --from="Example <nobody@example.com>" \
989 --to=nobody@example.com \
990 --smtp-server="$(pwd)/fake.sendmail" \
992 grep "^utf8 body" msgtxt1 &&
993 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1
996 test_expect_success $PREREQ '--compose-encoding overrides sendemail.composeencoding' '
997 clean_fake_sendmail &&
998 git config sendemail.composeencoding iso-8859-1 &&
999 write_script fake-editor-utf8 <<-\EOF &&
1000 echo "utf8 body: àéìöú" >>"$1"
1002 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
1004 --compose-encoding iso-8859-2 \
1005 --compose --subject foo \
1006 --from="Example <nobody@example.com>" \
1007 --to=nobody@example.com \
1008 --smtp-server="$(pwd)/fake.sendmail" \
1010 grep "^utf8 body" msgtxt1 &&
1011 grep "^Content-Type: text/plain; charset=iso-8859-2" msgtxt1
1014 test_expect_success $PREREQ '--compose-encoding adds correct MIME for subject' '
1015 clean_fake_sendmail &&
1016 GIT_EDITOR="\"$(pwd)/fake-editor\"" \
1018 --compose-encoding iso-8859-2 \
1019 --compose --subject utf8-sübjëct \
1020 --from="Example <nobody@example.com>" \
1021 --to=nobody@example.com \
1022 --smtp-server="$(pwd)/fake.sendmail" \
1024 grep "^fake edit" msgtxt1 &&
1025 grep "^Subject: =?iso-8859-2?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
1028 test_expect_success $PREREQ 'detects ambiguous reference/file conflict' '
1029 echo master >master &&
1031 git commit -m"add master" &&
1032 test_must_fail git send-email --dry-run master 2>errors &&
1033 grep disambiguate errors
1036 test_expect_success $PREREQ 'feed two files' '
1038 git format-patch -2 -o outdir &&
1041 --from="Example <nobody@example.com>" \
1042 --to=nobody@example.com \
1043 outdir/000?-*.patch 2>errors >out &&
1044 grep "^Subject: " out >subjects &&
1045 test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." &&
1046 test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add master"
1049 test_expect_success $PREREQ 'in-reply-to but no threading' '
1052 --from="Example <nobody@example.com>" \
1053 --to=nobody@example.com \
1054 --in-reply-to="<in-reply-id@example.com>" \
1057 grep "In-Reply-To: <in-reply-id@example.com>"
1060 test_expect_success $PREREQ 'no in-reply-to and no threading' '
1063 --from="Example <nobody@example.com>" \
1064 --to=nobody@example.com \
1066 $patches $patches >stdout &&
1067 ! grep "In-Reply-To: " stdout
1070 test_expect_success $PREREQ 'threading but no chain-reply-to' '
1073 --from="Example <nobody@example.com>" \
1074 --to=nobody@example.com \
1076 --no-chain-reply-to \
1077 $patches $patches >stdout &&
1078 grep "In-Reply-To: " stdout
1081 test_expect_success $PREREQ 'sendemail.to works' '
1082 git config --replace-all sendemail.to "Somebody <somebody@ex.com>" &&
1085 --from="Example <nobody@example.com>" \
1086 $patches $patches >stdout &&
1087 grep "To: Somebody <somebody@ex.com>" stdout
1090 test_expect_success $PREREQ '--no-to overrides sendemail.to' '
1093 --from="Example <nobody@example.com>" \
1095 --to=nobody@example.com \
1096 $patches $patches >stdout &&
1097 grep "To: nobody@example.com" stdout &&
1098 ! grep "To: Somebody <somebody@ex.com>" stdout
1101 test_expect_success $PREREQ 'sendemail.cc works' '
1102 git config --replace-all sendemail.cc "Somebody <somebody@ex.com>" &&
1105 --from="Example <nobody@example.com>" \
1106 --to=nobody@example.com \
1107 $patches $patches >stdout &&
1108 grep "Cc: Somebody <somebody@ex.com>" stdout
1111 test_expect_success $PREREQ '--no-cc overrides sendemail.cc' '
1114 --from="Example <nobody@example.com>" \
1116 --cc=bodies@example.com \
1117 --to=nobody@example.com \
1118 $patches $patches >stdout &&
1119 grep "Cc: bodies@example.com" stdout &&
1120 ! grep "Cc: Somebody <somebody@ex.com>" stdout
1123 test_expect_success $PREREQ 'sendemail.bcc works' '
1124 git config --replace-all sendemail.bcc "Other <other@ex.com>" &&
1127 --from="Example <nobody@example.com>" \
1128 --to=nobody@example.com \
1129 --smtp-server relay.example.com \
1130 $patches $patches >stdout &&
1131 grep "RCPT TO:<other@ex.com>" stdout
1134 test_expect_success $PREREQ '--no-bcc overrides sendemail.bcc' '
1137 --from="Example <nobody@example.com>" \
1139 --bcc=bodies@example.com \
1140 --to=nobody@example.com \
1141 --smtp-server relay.example.com \
1142 $patches $patches >stdout &&
1143 grep "RCPT TO:<bodies@example.com>" stdout &&
1144 ! grep "RCPT TO:<other@ex.com>" stdout
1147 test_expect_success $PREREQ 'patches To headers are used by default' '
1148 patch=`git format-patch -1 --to="bodies@example.com"` &&
1149 test_when_finished "rm $patch" &&
1152 --from="Example <nobody@example.com>" \
1153 --smtp-server relay.example.com \
1155 grep "RCPT TO:<bodies@example.com>" stdout
1158 test_expect_success $PREREQ 'patches To headers are appended to' '
1159 patch=`git format-patch -1 --to="bodies@example.com"` &&
1160 test_when_finished "rm $patch" &&
1163 --from="Example <nobody@example.com>" \
1164 --to=nobody@example.com \
1165 --smtp-server relay.example.com \
1167 grep "RCPT TO:<bodies@example.com>" stdout &&
1168 grep "RCPT TO:<nobody@example.com>" stdout
1171 test_expect_success $PREREQ 'To headers from files reset each patch' '
1172 patch1=`git format-patch -1 --to="bodies@example.com"` &&
1173 patch2=`git format-patch -1 --to="other@example.com" HEAD~` &&
1174 test_when_finished "rm $patch1 && rm $patch2" &&
1177 --from="Example <nobody@example.com>" \
1178 --to="nobody@example.com" \
1179 --smtp-server relay.example.com \
1180 $patch1 $patch2 >stdout &&
1181 test $(grep -c "RCPT TO:<bodies@example.com>" stdout) = 1 &&
1182 test $(grep -c "RCPT TO:<nobody@example.com>" stdout) = 2 &&
1183 test $(grep -c "RCPT TO:<other@example.com>" stdout) = 1
1186 test_expect_success $PREREQ 'setup expect' '
1187 cat >email-using-8bit <<\EOF
1188 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1189 Message-Id: <bogus-message-id@example.com>
1190 From: author@example.com
1191 Date: Sat, 12 Jun 2010 15:53:58 +0200
1192 Subject: subject goes here
1194 Dieser deutsche Text enthält einen Umlaut!
1198 test_expect_success $PREREQ 'setup expect' '
1199 echo "Subject: subject goes here" >expected
1202 test_expect_success $PREREQ 'ASCII subject is not RFC2047 quoted' '
1203 clean_fake_sendmail &&
1205 git send-email --from=author@example.com --to=nobody@example.com \
1206 --smtp-server="$(pwd)/fake.sendmail" \
1207 --8bit-encoding=UTF-8 \
1208 email-using-8bit >stdout &&
1209 grep "Subject" msgtxt1 >actual &&
1210 test_cmp expected actual
1213 test_expect_success $PREREQ 'setup expect' '
1214 cat >content-type-decl <<-\EOF
1216 Content-Type: text/plain; charset=UTF-8
1217 Content-Transfer-Encoding: 8bit
1221 test_expect_success $PREREQ 'asks about and fixes 8bit encodings' '
1222 clean_fake_sendmail &&
1224 git send-email --from=author@example.com --to=nobody@example.com \
1225 --smtp-server="$(pwd)/fake.sendmail" \
1226 email-using-8bit >stdout &&
1227 grep "do not declare a Content-Transfer-Encoding" stdout &&
1228 grep email-using-8bit stdout &&
1229 grep "Which 8bit encoding" stdout &&
1230 egrep "Content|MIME" msgtxt1 >actual &&
1231 test_cmp actual content-type-decl
1234 test_expect_success $PREREQ 'sendemail.8bitEncoding works' '
1235 clean_fake_sendmail &&
1236 git config sendemail.assume8bitEncoding UTF-8 &&
1238 git send-email --from=author@example.com --to=nobody@example.com \
1239 --smtp-server="$(pwd)/fake.sendmail" \
1240 email-using-8bit >stdout &&
1241 egrep "Content|MIME" msgtxt1 >actual &&
1242 test_cmp actual content-type-decl
1245 test_expect_success $PREREQ '--8bit-encoding overrides sendemail.8bitEncoding' '
1246 clean_fake_sendmail &&
1247 git config sendemail.assume8bitEncoding "bogus too" &&
1249 git send-email --from=author@example.com --to=nobody@example.com \
1250 --smtp-server="$(pwd)/fake.sendmail" \
1251 --8bit-encoding=UTF-8 \
1252 email-using-8bit >stdout &&
1253 egrep "Content|MIME" msgtxt1 >actual &&
1254 test_cmp actual content-type-decl
1257 test_expect_success $PREREQ 'setup expect' '
1258 cat >email-using-8bit <<-\EOF
1259 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1260 Message-Id: <bogus-message-id@example.com>
1261 From: author@example.com
1262 Date: Sat, 12 Jun 2010 15:53:58 +0200
1263 Subject: Dieser Betreff enthält auch einen Umlaut!
1265 Nothing to see here.
1269 test_expect_success $PREREQ 'setup expect' '
1270 cat >expected <<-\EOF
1271 Subject: =?UTF-8?q?Dieser=20Betreff=20enth=C3=A4lt=20auch=20einen=20Umlaut!?=
1275 test_expect_success $PREREQ '--8bit-encoding also treats subject' '
1276 clean_fake_sendmail &&
1278 git send-email --from=author@example.com --to=nobody@example.com \
1279 --smtp-server="$(pwd)/fake.sendmail" \
1280 --8bit-encoding=UTF-8 \
1281 email-using-8bit >stdout &&
1282 grep "Subject" msgtxt1 >actual &&
1283 test_cmp expected actual
1286 test_expect_success $PREREQ 'setup expect' '
1287 cat >email-using-8bit <<-\EOF
1288 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1289 Message-Id: <bogus-message-id@example.com>
1290 From: A U Thor <author@example.com>
1291 Date: Sat, 12 Jun 2010 15:53:58 +0200
1292 Content-Type: text/plain; charset=UTF-8
1293 Subject: Nothing to see here.
1295 Dieser Betreff enthält auch einen Umlaut!
1299 test_expect_success $PREREQ 'sendemail.transferencoding=7bit fails on 8bit data' '
1300 clean_fake_sendmail &&
1301 git config sendemail.transferEncoding 7bit &&
1302 test_must_fail git send-email \
1303 --transfer-encoding=7bit \
1304 --smtp-server="$(pwd)/fake.sendmail" \
1307 grep "cannot send message as 7bit" errors &&
1308 test -z "$(ls msgtxt*)"
1311 test_expect_success $PREREQ '--transfer-encoding overrides sendemail.transferEncoding' '
1312 clean_fake_sendmail &&
1313 git config sendemail.transferEncoding 8bit &&
1314 test_must_fail git send-email \
1315 --transfer-encoding=7bit \
1316 --smtp-server="$(pwd)/fake.sendmail" \
1319 grep "cannot send message as 7bit" errors &&
1320 test -z "$(ls msgtxt*)"
1323 test_expect_success $PREREQ 'sendemail.transferencoding=8bit' '
1324 clean_fake_sendmail &&
1326 --transfer-encoding=8bit \
1327 --smtp-server="$(pwd)/fake.sendmail" \
1330 sed '1,/^$/d' msgtxt1 >actual &&
1331 sed '1,/^$/d' email-using-8bit >expected &&
1332 test_cmp expected actual
1335 test_expect_success $PREREQ 'setup expect' '
1336 cat >expected <<-\EOF
1337 Dieser Betreff enth=C3=A4lt auch einen Umlaut!
1341 test_expect_success $PREREQ '8-bit and sendemail.transferencoding=quoted-printable' '
1342 clean_fake_sendmail &&
1344 --transfer-encoding=quoted-printable \
1345 --smtp-server="$(pwd)/fake.sendmail" \
1348 sed '1,/^$/d' msgtxt1 >actual &&
1349 test_cmp expected actual
1352 test_expect_success $PREREQ 'setup expect' '
1353 cat >expected <<-\EOF
1354 RGllc2VyIEJldHJlZmYgZW50aMOkbHQgYXVjaCBlaW5lbiBVbWxhdXQhCg==
1358 test_expect_success $PREREQ '8-bit and sendemail.transferencoding=base64' '
1359 clean_fake_sendmail &&
1361 --transfer-encoding=base64 \
1362 --smtp-server="$(pwd)/fake.sendmail" \
1365 sed '1,/^$/d' msgtxt1 >actual &&
1366 test_cmp expected actual
1369 test_expect_success $PREREQ 'setup expect' '
1370 cat >email-using-qp <<-\EOF
1371 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1372 Message-Id: <bogus-message-id@example.com>
1373 From: A U Thor <author@example.com>
1374 Date: Sat, 12 Jun 2010 15:53:58 +0200
1376 Content-Transfer-Encoding: quoted-printable
1377 Content-Type: text/plain; charset=UTF-8
1378 Subject: Nothing to see here.
1380 Dieser Betreff enth=C3=A4lt auch einen Umlaut!
1384 test_expect_success $PREREQ 'convert from quoted-printable to base64' '
1385 clean_fake_sendmail &&
1387 --transfer-encoding=base64 \
1388 --smtp-server="$(pwd)/fake.sendmail" \
1391 sed '1,/^$/d' msgtxt1 >actual &&
1392 test_cmp expected actual
1395 test_expect_success $PREREQ 'setup expect' "
1396 tr -d '\\015' | tr '%' '\\015' >email-using-crlf <<EOF
1397 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1398 Message-Id: <bogus-message-id@example.com>
1399 From: A U Thor <author@example.com>
1400 Date: Sat, 12 Jun 2010 15:53:58 +0200
1401 Content-Type: text/plain; charset=UTF-8
1402 Subject: Nothing to see here.
1404 Look, I have a CRLF and an = sign!%
1408 test_expect_success $PREREQ 'setup expect' '
1409 cat >expected <<-\EOF
1410 Look, I have a CRLF and an =3D sign!=0D
1414 test_expect_success $PREREQ 'CRLF and sendemail.transferencoding=quoted-printable' '
1415 clean_fake_sendmail &&
1417 --transfer-encoding=quoted-printable \
1418 --smtp-server="$(pwd)/fake.sendmail" \
1421 sed '1,/^$/d' msgtxt1 >actual &&
1422 test_cmp expected actual
1425 test_expect_success $PREREQ 'setup expect' '
1426 cat >expected <<-\EOF
1427 TG9vaywgSSBoYXZlIGEgQ1JMRiBhbmQgYW4gPSBzaWduIQ0K
1431 test_expect_success $PREREQ 'CRLF and sendemail.transferencoding=base64' '
1432 clean_fake_sendmail &&
1434 --transfer-encoding=base64 \
1435 --smtp-server="$(pwd)/fake.sendmail" \
1438 sed '1,/^$/d' msgtxt1 >actual &&
1439 test_cmp expected actual
1443 # Note that the patches in this test are deliberately out of order; we
1444 # want to make sure it works even if the cover-letter is not in the
1446 test_expect_success $PREREQ 'refusing to send cover letter template' '
1447 clean_fake_sendmail &&
1449 git format-patch --cover-letter -2 -o outdir &&
1450 test_must_fail git send-email \
1451 --from="Example <nobody@example.com>" \
1452 --to=nobody@example.com \
1453 --smtp-server="$(pwd)/fake.sendmail" \
1454 outdir/0002-*.patch \
1455 outdir/0000-*.patch \
1456 outdir/0001-*.patch \
1458 grep "SUBJECT HERE" errors &&
1459 test -z "$(ls msgtxt*)"
1462 test_expect_success $PREREQ '--force sends cover letter template anyway' '
1463 clean_fake_sendmail &&
1465 git format-patch --cover-letter -2 -o outdir &&
1468 --from="Example <nobody@example.com>" \
1469 --to=nobody@example.com \
1470 --smtp-server="$(pwd)/fake.sendmail" \
1471 outdir/0002-*.patch \
1472 outdir/0000-*.patch \
1473 outdir/0001-*.patch \
1475 ! grep "SUBJECT HERE" errors &&
1476 test -n "$(ls msgtxt*)"
1479 test_cover_addresses () {
1482 clean_fake_sendmail &&
1484 git format-patch --cover-letter -2 -o outdir &&
1485 cover=`echo outdir/0000-*.patch` &&
1486 mv $cover cover-to-edit.patch &&
1487 perl -pe "s/^From:/$header: extra\@address.com\nFrom:/" cover-to-edit.patch >"$cover" &&
1490 --from="Example <nobody@example.com>" \
1493 --smtp-server="$(pwd)/fake.sendmail" \
1494 outdir/0000-*.patch \
1495 outdir/0001-*.patch \
1496 outdir/0002-*.patch \
1498 grep "^$header: extra@address.com" msgtxt1 >to1 &&
1499 grep "^$header: extra@address.com" msgtxt2 >to2 &&
1500 grep "^$header: extra@address.com" msgtxt3 >to3 &&
1501 test_line_count = 1 to1 &&
1502 test_line_count = 1 to2 &&
1503 test_line_count = 1 to3
1506 test_expect_success $PREREQ 'to-cover adds To to all mail' '
1507 test_cover_addresses "To" --to-cover
1510 test_expect_success $PREREQ 'cc-cover adds Cc to all mail' '
1511 test_cover_addresses "Cc" --cc-cover
1514 test_expect_success $PREREQ 'tocover adds To to all mail' '
1515 test_config sendemail.tocover true &&
1516 test_cover_addresses "To"
1519 test_expect_success $PREREQ 'cccover adds Cc to all mail' '
1520 test_config sendemail.cccover true &&
1521 test_cover_addresses "Cc"
1524 test_expect_success $PREREQ 'sendemail.aliasfiletype=mailrc' '
1525 clean_fake_sendmail &&
1526 echo "alias sbd somebody@example.org" >.mailrc &&
1527 git config --replace-all sendemail.aliasesfile "$(pwd)/.mailrc" &&
1528 git config sendemail.aliasfiletype mailrc &&
1530 --from="Example <nobody@example.com>" \
1532 --smtp-server="$(pwd)/fake.sendmail" \
1533 outdir/0001-*.patch \
1535 grep "^!somebody@example\.org!$" commandline1
1538 test_expect_success $PREREQ 'sendemail.aliasfile=~/.mailrc' '
1539 clean_fake_sendmail &&
1540 echo "alias sbd someone@example.org" >~/.mailrc &&
1541 git config --replace-all sendemail.aliasesfile "~/.mailrc" &&
1542 git config sendemail.aliasfiletype mailrc &&
1544 --from="Example <nobody@example.com>" \
1546 --smtp-server="$(pwd)/fake.sendmail" \
1547 outdir/0001-*.patch \
1549 grep "^!someone@example\.org!$" commandline1
1552 do_xmailer_test () {
1553 expected=$1 params=$2 &&
1554 git format-patch -1 &&
1556 --from="Example <nobody@example.com>" \
1557 --to=someone@example.com \
1558 --smtp-server="$(pwd)/fake.sendmail" \
1562 { grep '^X-Mailer:' out || :; } >mailer &&
1563 test_line_count = $expected mailer
1566 test_expect_success $PREREQ '--[no-]xmailer without any configuration' '
1567 do_xmailer_test 1 "--xmailer" &&
1568 do_xmailer_test 0 "--no-xmailer"
1571 test_expect_success $PREREQ '--[no-]xmailer with sendemail.xmailer=true' '
1572 test_config sendemail.xmailer true &&
1573 do_xmailer_test 1 "" &&
1574 do_xmailer_test 0 "--no-xmailer" &&
1575 do_xmailer_test 1 "--xmailer"
1578 test_expect_success $PREREQ '--[no-]xmailer with sendemail.xmailer=false' '
1579 test_config sendemail.xmailer false &&
1580 do_xmailer_test 0 "" &&
1581 do_xmailer_test 0 "--no-xmailer" &&
1582 do_xmailer_test 1 "--xmailer"