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 test_expect_success
$PREREQ 'sanitized self name is suppressed' "
246 test_suppress_self_unquoted '\"A U. Thor\"' 'author@example.com' \
247 'self_name_sanitized_suppressed'
250 test_expect_success
$PREREQ 'Show all headers' '
254 --from="Example <from@example.com>" \
255 --to=to@example.com \
256 --cc=cc@example.com \
257 --bcc=bcc@example.com \
258 --in-reply-to="<unique-message-id@example.com>" \
259 --smtp-server relay.example.com \
261 sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
262 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
263 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
264 >actual-show-all-headers &&
265 test_cmp expected-show-all-headers actual-show-all-headers
268 test_expect_success
$PREREQ 'Prompting works' '
269 clean_fake_sendmail &&
270 (echo "to@example.com"
272 ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
273 --smtp-server="$(pwd)/fake.sendmail" \
276 grep "^From: A U Thor <author@example.com>\$" msgtxt1 &&
277 grep "^To: to@example.com\$" msgtxt1
280 test_expect_success
$PREREQ,AUTOIDENT
'implicit ident is allowed' '
281 clean_fake_sendmail &&
282 (sane_unset GIT_AUTHOR_NAME &&
283 sane_unset GIT_AUTHOR_EMAIL &&
284 sane_unset GIT_COMMITTER_NAME &&
285 sane_unset GIT_COMMITTER_EMAIL &&
286 GIT_SEND_EMAIL_NOTTY=1 git send-email \
287 --smtp-server="$(pwd)/fake.sendmail" \
288 --to=to@example.com \
289 $patches </dev/null 2>errors
293 test_expect_success
$PREREQ,!AUTOIDENT
'broken implicit ident aborts send-email' '
294 clean_fake_sendmail &&
295 (sane_unset GIT_AUTHOR_NAME &&
296 sane_unset GIT_AUTHOR_EMAIL &&
297 sane_unset GIT_COMMITTER_NAME &&
298 sane_unset GIT_COMMITTER_EMAIL &&
299 GIT_SEND_EMAIL_NOTTY=1 && export GIT_SEND_EMAIL_NOTTY &&
300 test_must_fail git send-email \
301 --smtp-server="$(pwd)/fake.sendmail" \
302 --to=to@example.com \
303 $patches </dev/null 2>errors &&
304 test_i18ngrep "tell me who you are" errors
308 test_expect_success
$PREREQ 'tocmd works' '
309 clean_fake_sendmail &&
310 cp $patches tocmd.patch &&
311 echo tocmd--tocmd@example.com >>tocmd.patch &&
312 write_script tocmd-sed <<-\EOF &&
313 sed -n -e "s/^tocmd--//p" "$1"
316 --from="Example <nobody@example.com>" \
317 --to-cmd=./tocmd-sed \
318 --smtp-server="$(pwd)/fake.sendmail" \
321 grep "^To: tocmd@example.com" msgtxt1
324 test_expect_success
$PREREQ 'cccmd works' '
325 clean_fake_sendmail &&
326 cp $patches cccmd.patch &&
327 echo "cccmd-- cccmd@example.com" >>cccmd.patch &&
328 write_script cccmd-sed <<-\EOF &&
329 sed -n -e "s/^cccmd--//p" "$1"
332 --from="Example <nobody@example.com>" \
333 --to=nobody@example.com \
334 --cc-cmd=./cccmd-sed \
335 --smtp-server="$(pwd)/fake.sendmail" \
338 grep "^ cccmd@example.com" msgtxt1
341 test_expect_success
$PREREQ 'reject long lines' '
343 z64=$z8$z8$z8$z8$z8$z8$z8$z8 &&
344 z512=$z64$z64$z64$z64$z64$z64$z64$z64 &&
345 clean_fake_sendmail &&
346 cp $patches longline.patch &&
347 echo $z512$z512 >>longline.patch &&
348 test_must_fail git send-email \
349 --from="Example <nobody@example.com>" \
350 --to=nobody@example.com \
351 --smtp-server="$(pwd)/fake.sendmail" \
352 $patches longline.patch \
354 grep longline.patch errors
357 test_expect_success
$PREREQ 'no patch was sent' '
358 ! test -e commandline1
361 test_expect_success
$PREREQ 'Author From: in message body' '
362 clean_fake_sendmail &&
364 --from="Example <nobody@example.com>" \
365 --to=nobody@example.com \
366 --smtp-server="$(pwd)/fake.sendmail" \
368 sed "1,/^\$/d" <msgtxt1 >msgbody1 &&
369 grep "From: A <author@example.com>" msgbody1
372 test_expect_success
$PREREQ 'Author From: not in message body' '
373 clean_fake_sendmail &&
375 --from="A <author@example.com>" \
376 --to=nobody@example.com \
377 --smtp-server="$(pwd)/fake.sendmail" \
379 sed "1,/^\$/d" <msgtxt1 >msgbody1 &&
380 ! grep "From: A <author@example.com>" msgbody1
383 test_expect_success
$PREREQ 'allow long lines with --no-validate' '
385 --from="Example <nobody@example.com>" \
386 --to=nobody@example.com \
387 --smtp-server="$(pwd)/fake.sendmail" \
389 $patches longline.patch \
393 test_expect_success
$PREREQ 'Invalid In-Reply-To' '
394 clean_fake_sendmail &&
396 --from="Example <nobody@example.com>" \
397 --to=nobody@example.com \
399 --smtp-server="$(pwd)/fake.sendmail" \
402 ! grep "^In-Reply-To: < *>" msgtxt1
405 test_expect_success
$PREREQ 'Valid In-Reply-To when prompting' '
406 clean_fake_sendmail &&
407 (echo "From Example <from@example.com>"
408 echo "To Example <to@example.com>"
410 ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
411 --smtp-server="$(pwd)/fake.sendmail" \
413 ! grep "^In-Reply-To: < *>" msgtxt1
416 test_expect_success
$PREREQ 'In-Reply-To without --chain-reply-to' '
417 clean_fake_sendmail &&
418 echo "<unique-message-id@example.com>" >expect &&
420 --from="Example <nobody@example.com>" \
421 --to=nobody@example.com \
423 --in-reply-to="$(cat expect)" \
424 --smtp-server="$(pwd)/fake.sendmail" \
425 $patches $patches $patches \
427 # The first message is a reply to --in-reply-to
428 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual &&
429 test_cmp expect actual &&
430 # Second and subsequent messages are replies to the first one
431 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect &&
432 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual &&
433 test_cmp expect actual &&
434 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual &&
435 test_cmp expect actual
438 test_expect_success
$PREREQ 'In-Reply-To with --chain-reply-to' '
439 clean_fake_sendmail &&
440 echo "<unique-message-id@example.com>" >expect &&
442 --from="Example <nobody@example.com>" \
443 --to=nobody@example.com \
445 --in-reply-to="$(cat expect)" \
446 --smtp-server="$(pwd)/fake.sendmail" \
447 $patches $patches $patches \
449 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual &&
450 test_cmp expect actual &&
451 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect &&
452 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual &&
453 test_cmp expect actual &&
454 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt2 >expect &&
455 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual &&
456 test_cmp expect actual
459 test_expect_success
$PREREQ 'setup fake editor' '
460 write_script fake-editor <<-\EOF
461 echo fake edit >>"$1"
465 test_set_editor
"$(pwd)/fake-editor"
467 test_expect_success
$PREREQ '--compose works' '
468 clean_fake_sendmail &&
470 --compose --subject foo \
471 --from="Example <nobody@example.com>" \
472 --to=nobody@example.com \
473 --smtp-server="$(pwd)/fake.sendmail" \
478 test_expect_success
$PREREQ 'first message is compose text' '
479 grep "^fake edit" msgtxt1
482 test_expect_success
$PREREQ 'second message is patch' '
483 grep "Subject:.*Second" msgtxt2
486 test_expect_success
$PREREQ 'setup expect' "
487 cat >expected-suppress-sob <<\EOF
489 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
490 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
491 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
493 Server: relay.example.com
494 MAIL FROM:<from@example.com>
495 RCPT TO:<to@example.com>
496 RCPT TO:<cc@example.com>
497 RCPT TO:<author@example.com>
498 RCPT TO:<one@example.com>
499 RCPT TO:<two@example.com>
500 From: Example <from@example.com>
503 A <author@example.com>,
504 One <one@example.com>,
506 Subject: [PATCH 1/1] Second.
508 Message-Id: MESSAGE-ID-STRING
509 X-Mailer: X-MAILER-STRING
515 test_suppression
() {
518 --suppress-cc=$1 ${2+"--suppress-cc=$2"} \
519 --from="Example <from@example.com>" \
520 --to=to@example.com \
521 --smtp-server relay.example.com \
523 sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
524 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
525 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
526 >actual-suppress-
$1${2+"-$2"} &&
527 test_cmp expected-suppress-
$1${2+"-$2"} actual-suppress-
$1${2+"-$2"}
530 test_expect_success
$PREREQ 'sendemail.cc set' '
531 git config sendemail.cc cc@example.com &&
535 test_expect_success
$PREREQ 'setup expect' "
536 cat >expected-suppress-sob <<\EOF
538 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
539 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
540 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
542 Server: relay.example.com
543 MAIL FROM:<from@example.com>
544 RCPT TO:<to@example.com>
545 RCPT TO:<author@example.com>
546 RCPT TO:<one@example.com>
547 RCPT TO:<two@example.com>
548 From: Example <from@example.com>
550 Cc: A <author@example.com>,
551 One <one@example.com>,
553 Subject: [PATCH 1/1] Second.
555 Message-Id: MESSAGE-ID-STRING
556 X-Mailer: X-MAILER-STRING
562 test_expect_success
$PREREQ 'sendemail.cc unset' '
563 git config --unset sendemail.cc &&
567 test_expect_success
$PREREQ 'setup expect' "
568 cat >expected-suppress-cccmd <<\EOF
570 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
571 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
572 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@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:<one@example.com>
580 RCPT TO:<two@example.com>
581 RCPT TO:<committer@example.com>
582 From: Example <from@example.com>
584 Cc: A <author@example.com>,
585 One <one@example.com>,
587 C O Mitter <committer@example.com>
588 Subject: [PATCH 1/1] Second.
590 Message-Id: MESSAGE-ID-STRING
591 X-Mailer: X-MAILER-STRING
597 test_expect_success
$PREREQ 'sendemail.cccmd' '
598 write_script cccmd <<-\EOF &&
599 echo cc-cmd@example.com
601 git config sendemail.cccmd ./cccmd &&
602 test_suppression cccmd
605 test_expect_success
$PREREQ 'setup expect' '
606 cat >expected-suppress-all <<\EOF
609 Server: relay.example.com
610 MAIL FROM:<from@example.com>
611 RCPT TO:<to@example.com>
612 From: Example <from@example.com>
614 Subject: [PATCH 1/1] Second.
616 Message-Id: MESSAGE-ID-STRING
617 X-Mailer: X-MAILER-STRING
623 test_expect_success
$PREREQ '--suppress-cc=all' '
627 test_expect_success
$PREREQ 'setup expect' "
628 cat >expected-suppress-body <<\EOF
630 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
631 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
632 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
633 (cc-cmd) Adding cc: cc-cmd@example.com from: './cccmd'
635 Server: relay.example.com
636 MAIL FROM:<from@example.com>
637 RCPT TO:<to@example.com>
638 RCPT TO:<author@example.com>
639 RCPT TO:<one@example.com>
640 RCPT TO:<two@example.com>
641 RCPT TO:<cc-cmd@example.com>
642 From: Example <from@example.com>
644 Cc: A <author@example.com>,
645 One <one@example.com>,
648 Subject: [PATCH 1/1] Second.
650 Message-Id: MESSAGE-ID-STRING
651 X-Mailer: X-MAILER-STRING
657 test_expect_success
$PREREQ '--suppress-cc=body' '
658 test_suppression body
661 test_expect_success
$PREREQ 'setup expect' "
662 cat >expected-suppress-body-cccmd <<\EOF
664 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
665 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
666 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
668 Server: relay.example.com
669 MAIL FROM:<from@example.com>
670 RCPT TO:<to@example.com>
671 RCPT TO:<author@example.com>
672 RCPT TO:<one@example.com>
673 RCPT TO:<two@example.com>
674 From: Example <from@example.com>
676 Cc: A <author@example.com>,
677 One <one@example.com>,
679 Subject: [PATCH 1/1] Second.
681 Message-Id: MESSAGE-ID-STRING
682 X-Mailer: X-MAILER-STRING
688 test_expect_success
$PREREQ '--suppress-cc=body --suppress-cc=cccmd' '
689 test_suppression body cccmd
692 test_expect_success
$PREREQ 'setup expect' "
693 cat >expected-suppress-sob <<\EOF
695 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
696 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
697 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
699 Server: relay.example.com
700 MAIL FROM:<from@example.com>
701 RCPT TO:<to@example.com>
702 RCPT TO:<author@example.com>
703 RCPT TO:<one@example.com>
704 RCPT TO:<two@example.com>
705 From: Example <from@example.com>
707 Cc: A <author@example.com>,
708 One <one@example.com>,
710 Subject: [PATCH 1/1] Second.
712 Message-Id: MESSAGE-ID-STRING
713 X-Mailer: X-MAILER-STRING
719 test_expect_success
$PREREQ '--suppress-cc=sob' '
720 test_might_fail git config --unset sendemail.cccmd &&
724 test_expect_success
$PREREQ 'setup expect' "
725 cat >expected-suppress-bodycc <<\EOF
727 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
728 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
729 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
730 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
732 Server: relay.example.com
733 MAIL FROM:<from@example.com>
734 RCPT TO:<to@example.com>
735 RCPT TO:<author@example.com>
736 RCPT TO:<one@example.com>
737 RCPT TO:<two@example.com>
738 RCPT TO:<committer@example.com>
739 From: Example <from@example.com>
741 Cc: A <author@example.com>,
742 One <one@example.com>,
744 C O Mitter <committer@example.com>
745 Subject: [PATCH 1/1] Second.
747 Message-Id: MESSAGE-ID-STRING
748 X-Mailer: X-MAILER-STRING
754 test_expect_success
$PREREQ '--suppress-cc=bodycc' '
755 test_suppression bodycc
758 test_expect_success
$PREREQ 'setup expect' "
759 cat >expected-suppress-cc <<\EOF
761 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
762 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
764 Server: relay.example.com
765 MAIL FROM:<from@example.com>
766 RCPT TO:<to@example.com>
767 RCPT TO:<author@example.com>
768 RCPT TO:<committer@example.com>
769 From: Example <from@example.com>
771 Cc: A <author@example.com>,
772 C O Mitter <committer@example.com>
773 Subject: [PATCH 1/1] Second.
775 Message-Id: MESSAGE-ID-STRING
776 X-Mailer: X-MAILER-STRING
782 test_expect_success
$PREREQ '--suppress-cc=cc' '
788 GIT_SEND_EMAIL_NOTTY
=1 \
790 --from="Example <nobody@example.com>" \
791 --to=nobody@example.com \
792 --smtp-server="$(pwd)/fake.sendmail" \
793 $@
$patches >stdout
&&
794 grep "Send this email" stdout
797 test_expect_success
$PREREQ '--confirm=always' '
798 test_confirm --confirm=always --suppress-cc=all
801 test_expect_success
$PREREQ '--confirm=auto' '
802 test_confirm --confirm=auto
805 test_expect_success
$PREREQ '--confirm=cc' '
806 test_confirm --confirm=cc
809 test_expect_success
$PREREQ '--confirm=compose' '
810 test_confirm --confirm=compose --compose
813 test_expect_success
$PREREQ 'confirm by default (due to cc)' '
814 CONFIRM=$(git config --get sendemail.confirm) &&
815 git config --unset sendemail.confirm &&
818 git config sendemail.confirm ${CONFIRM:-never}
822 test_expect_success
$PREREQ 'confirm by default (due to --compose)' '
823 CONFIRM=$(git config --get sendemail.confirm) &&
824 git config --unset sendemail.confirm &&
825 test_confirm --suppress-cc=all --compose
827 git config sendemail.confirm ${CONFIRM:-never}
831 test_expect_success
$PREREQ 'confirm detects EOF (inform assumes y)' '
832 CONFIRM=$(git config --get sendemail.confirm) &&
833 git config --unset sendemail.confirm &&
835 git format-patch -2 -o outdir &&
836 GIT_SEND_EMAIL_NOTTY=1 \
838 --from="Example <nobody@example.com>" \
839 --to=nobody@example.com \
840 --smtp-server="$(pwd)/fake.sendmail" \
841 outdir/*.patch </dev/null
843 git config sendemail.confirm ${CONFIRM:-never}
847 test_expect_success
$PREREQ 'confirm detects EOF (auto causes failure)' '
848 CONFIRM=$(git config --get sendemail.confirm) &&
849 git config sendemail.confirm auto &&
850 GIT_SEND_EMAIL_NOTTY=1 &&
851 export GIT_SEND_EMAIL_NOTTY &&
852 test_must_fail git send-email \
853 --from="Example <nobody@example.com>" \
854 --to=nobody@example.com \
855 --smtp-server="$(pwd)/fake.sendmail" \
858 git config sendemail.confirm ${CONFIRM:-never}
862 test_expect_success
$PREREQ 'confirm does not loop forever' '
863 CONFIRM=$(git config --get sendemail.confirm) &&
864 git config sendemail.confirm auto &&
865 GIT_SEND_EMAIL_NOTTY=1 &&
866 export GIT_SEND_EMAIL_NOTTY &&
867 yes "bogus" | test_must_fail git send-email \
868 --from="Example <nobody@example.com>" \
869 --to=nobody@example.com \
870 --smtp-server="$(pwd)/fake.sendmail" \
873 git config sendemail.confirm ${CONFIRM:-never}
877 test_expect_success
$PREREQ 'utf8 Cc is rfc2047 encoded' '
878 clean_fake_sendmail &&
880 git format-patch -1 -o outdir --cc="àéìöú <utf8@example.com>" &&
882 --from="Example <nobody@example.com>" \
883 --to=nobody@example.com \
884 --smtp-server="$(pwd)/fake.sendmail" \
887 grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>"
890 test_expect_success
$PREREQ '--compose adds MIME for utf8 body' '
891 clean_fake_sendmail &&
892 write_script fake-editor-utf8 <<-\EOF &&
893 echo "utf8 body: àéìöú" >>"$1"
895 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
897 --compose --subject foo \
898 --from="Example <nobody@example.com>" \
899 --to=nobody@example.com \
900 --smtp-server="$(pwd)/fake.sendmail" \
902 grep "^utf8 body" msgtxt1 &&
903 grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
906 test_expect_success
$PREREQ '--compose respects user mime type' '
907 clean_fake_sendmail &&
908 write_script fake-editor-utf8-mime <<-\EOF &&
911 Content-Type: text/plain; charset=iso-8859-1
912 Content-Transfer-Encoding: 8bit
918 GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \
920 --compose --subject foo \
921 --from="Example <nobody@example.com>" \
922 --to=nobody@example.com \
923 --smtp-server="$(pwd)/fake.sendmail" \
925 grep "^utf8 body" msgtxt1 &&
926 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 &&
927 ! grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
930 test_expect_success
$PREREQ '--compose adds MIME for utf8 subject' '
931 clean_fake_sendmail &&
932 GIT_EDITOR="\"$(pwd)/fake-editor\"" \
934 --compose --subject utf8-sübjëct \
935 --from="Example <nobody@example.com>" \
936 --to=nobody@example.com \
937 --smtp-server="$(pwd)/fake.sendmail" \
939 grep "^fake edit" msgtxt1 &&
940 grep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
943 test_expect_success
$PREREQ 'utf8 author is correctly passed on' '
944 clean_fake_sendmail &&
945 test_commit weird_author &&
946 test_when_finished "git reset --hard HEAD^" &&
947 git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" &&
948 git format-patch --stdout -1 >funny_name.patch &&
949 git send-email --from="Example <nobody@example.com>" \
950 --to=nobody@example.com \
951 --smtp-server="$(pwd)/fake.sendmail" \
953 grep "^From: Füñný Nâmé <odd_?=mail@example.com>" msgtxt1
956 test_expect_success
$PREREQ 'utf8 sender is not duplicated' '
957 clean_fake_sendmail &&
958 test_commit weird_sender &&
959 test_when_finished "git reset --hard HEAD^" &&
960 git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" &&
961 git format-patch --stdout -1 >funny_name.patch &&
962 git send-email --from="Füñný Nâmé <odd_?=mail@example.com>" \
963 --to=nobody@example.com \
964 --smtp-server="$(pwd)/fake.sendmail" \
966 grep "^From: " msgtxt1 >msgfrom &&
967 test_line_count = 1 msgfrom
970 test_expect_success
$PREREQ 'sendemail.composeencoding works' '
971 clean_fake_sendmail &&
972 git config sendemail.composeencoding iso-8859-1 &&
973 write_script fake-editor-utf8 <<-\EOF &&
974 echo "utf8 body: àéìöú" >>"$1"
976 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
978 --compose --subject foo \
979 --from="Example <nobody@example.com>" \
980 --to=nobody@example.com \
981 --smtp-server="$(pwd)/fake.sendmail" \
983 grep "^utf8 body" msgtxt1 &&
984 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1
987 test_expect_success
$PREREQ '--compose-encoding works' '
988 clean_fake_sendmail &&
989 write_script fake-editor-utf8 <<-\EOF &&
990 echo "utf8 body: àéìöú" >>"$1"
992 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
994 --compose-encoding iso-8859-1 \
995 --compose --subject foo \
996 --from="Example <nobody@example.com>" \
997 --to=nobody@example.com \
998 --smtp-server="$(pwd)/fake.sendmail" \
1000 grep "^utf8 body" msgtxt1 &&
1001 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1
1004 test_expect_success
$PREREQ '--compose-encoding overrides sendemail.composeencoding' '
1005 clean_fake_sendmail &&
1006 git config sendemail.composeencoding iso-8859-1 &&
1007 write_script fake-editor-utf8 <<-\EOF &&
1008 echo "utf8 body: àéìöú" >>"$1"
1010 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
1012 --compose-encoding iso-8859-2 \
1013 --compose --subject foo \
1014 --from="Example <nobody@example.com>" \
1015 --to=nobody@example.com \
1016 --smtp-server="$(pwd)/fake.sendmail" \
1018 grep "^utf8 body" msgtxt1 &&
1019 grep "^Content-Type: text/plain; charset=iso-8859-2" msgtxt1
1022 test_expect_success
$PREREQ '--compose-encoding adds correct MIME for subject' '
1023 clean_fake_sendmail &&
1024 GIT_EDITOR="\"$(pwd)/fake-editor\"" \
1026 --compose-encoding iso-8859-2 \
1027 --compose --subject utf8-sübjëct \
1028 --from="Example <nobody@example.com>" \
1029 --to=nobody@example.com \
1030 --smtp-server="$(pwd)/fake.sendmail" \
1032 grep "^fake edit" msgtxt1 &&
1033 grep "^Subject: =?iso-8859-2?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
1036 test_expect_success
$PREREQ 'detects ambiguous reference/file conflict' '
1037 echo master >master &&
1039 git commit -m"add master" &&
1040 test_must_fail git send-email --dry-run master 2>errors &&
1041 grep disambiguate errors
1044 test_expect_success
$PREREQ 'feed two files' '
1046 git format-patch -2 -o outdir &&
1049 --from="Example <nobody@example.com>" \
1050 --to=nobody@example.com \
1051 outdir/000?-*.patch 2>errors >out &&
1052 grep "^Subject: " out >subjects &&
1053 test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." &&
1054 test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add master"
1057 test_expect_success
$PREREQ 'in-reply-to but no threading' '
1060 --from="Example <nobody@example.com>" \
1061 --to=nobody@example.com \
1062 --in-reply-to="<in-reply-id@example.com>" \
1065 grep "In-Reply-To: <in-reply-id@example.com>"
1068 test_expect_success
$PREREQ 'no in-reply-to and no threading' '
1071 --from="Example <nobody@example.com>" \
1072 --to=nobody@example.com \
1074 $patches $patches >stdout &&
1075 ! grep "In-Reply-To: " stdout
1078 test_expect_success
$PREREQ 'threading but no chain-reply-to' '
1081 --from="Example <nobody@example.com>" \
1082 --to=nobody@example.com \
1084 --nochain-reply-to \
1085 $patches $patches >stdout &&
1086 grep "In-Reply-To: " stdout
1089 test_expect_success
$PREREQ 'sendemail.to works' '
1090 git config --replace-all sendemail.to "Somebody <somebody@ex.com>" &&
1093 --from="Example <nobody@example.com>" \
1094 $patches $patches >stdout &&
1095 grep "To: Somebody <somebody@ex.com>" stdout
1098 test_expect_success
$PREREQ '--no-to overrides sendemail.to' '
1101 --from="Example <nobody@example.com>" \
1103 --to=nobody@example.com \
1104 $patches $patches >stdout &&
1105 grep "To: nobody@example.com" stdout &&
1106 ! grep "To: Somebody <somebody@ex.com>" stdout
1109 test_expect_success
$PREREQ 'sendemail.cc works' '
1110 git config --replace-all sendemail.cc "Somebody <somebody@ex.com>" &&
1113 --from="Example <nobody@example.com>" \
1114 --to=nobody@example.com \
1115 $patches $patches >stdout &&
1116 grep "Cc: Somebody <somebody@ex.com>" stdout
1119 test_expect_success
$PREREQ '--no-cc overrides sendemail.cc' '
1122 --from="Example <nobody@example.com>" \
1124 --cc=bodies@example.com \
1125 --to=nobody@example.com \
1126 $patches $patches >stdout &&
1127 grep "Cc: bodies@example.com" stdout &&
1128 ! grep "Cc: Somebody <somebody@ex.com>" stdout
1131 test_expect_success
$PREREQ 'sendemail.bcc works' '
1132 git config --replace-all sendemail.bcc "Other <other@ex.com>" &&
1135 --from="Example <nobody@example.com>" \
1136 --to=nobody@example.com \
1137 --smtp-server relay.example.com \
1138 $patches $patches >stdout &&
1139 grep "RCPT TO:<other@ex.com>" stdout
1142 test_expect_success
$PREREQ '--no-bcc overrides sendemail.bcc' '
1145 --from="Example <nobody@example.com>" \
1147 --bcc=bodies@example.com \
1148 --to=nobody@example.com \
1149 --smtp-server relay.example.com \
1150 $patches $patches >stdout &&
1151 grep "RCPT TO:<bodies@example.com>" stdout &&
1152 ! grep "RCPT TO:<other@ex.com>" stdout
1155 test_expect_success
$PREREQ 'patches To headers are used by default' '
1156 patch=`git format-patch -1 --to="bodies@example.com"` &&
1157 test_when_finished "rm $patch" &&
1160 --from="Example <nobody@example.com>" \
1161 --smtp-server relay.example.com \
1163 grep "RCPT TO:<bodies@example.com>" stdout
1166 test_expect_success
$PREREQ 'patches To headers are appended to' '
1167 patch=`git format-patch -1 --to="bodies@example.com"` &&
1168 test_when_finished "rm $patch" &&
1171 --from="Example <nobody@example.com>" \
1172 --to=nobody@example.com \
1173 --smtp-server relay.example.com \
1175 grep "RCPT TO:<bodies@example.com>" stdout &&
1176 grep "RCPT TO:<nobody@example.com>" stdout
1179 test_expect_success
$PREREQ 'To headers from files reset each patch' '
1180 patch1=`git format-patch -1 --to="bodies@example.com"` &&
1181 patch2=`git format-patch -1 --to="other@example.com" HEAD~` &&
1182 test_when_finished "rm $patch1 && rm $patch2" &&
1185 --from="Example <nobody@example.com>" \
1186 --to="nobody@example.com" \
1187 --smtp-server relay.example.com \
1188 $patch1 $patch2 >stdout &&
1189 test $(grep -c "RCPT TO:<bodies@example.com>" stdout) = 1 &&
1190 test $(grep -c "RCPT TO:<nobody@example.com>" stdout) = 2 &&
1191 test $(grep -c "RCPT TO:<other@example.com>" stdout) = 1
1194 test_expect_success
$PREREQ 'setup expect' '
1195 cat >email-using-8bit <<\EOF
1196 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1197 Message-Id: <bogus-message-id@example.com>
1198 From: author@example.com
1199 Date: Sat, 12 Jun 2010 15:53:58 +0200
1200 Subject: subject goes here
1202 Dieser deutsche Text enthält einen Umlaut!
1206 test_expect_success
$PREREQ 'setup expect' '
1207 echo "Subject: subject goes here" >expected
1210 test_expect_success
$PREREQ 'ASCII subject is not RFC2047 quoted' '
1211 clean_fake_sendmail &&
1213 git send-email --from=author@example.com --to=nobody@example.com \
1214 --smtp-server="$(pwd)/fake.sendmail" \
1215 --8bit-encoding=UTF-8 \
1216 email-using-8bit >stdout &&
1217 grep "Subject" msgtxt1 >actual &&
1218 test_cmp expected actual
1221 test_expect_success
$PREREQ 'setup expect' '
1222 cat >content-type-decl <<-\EOF
1224 Content-Type: text/plain; charset=UTF-8
1225 Content-Transfer-Encoding: 8bit
1229 test_expect_success
$PREREQ 'asks about and fixes 8bit encodings' '
1230 clean_fake_sendmail &&
1232 git send-email --from=author@example.com --to=nobody@example.com \
1233 --smtp-server="$(pwd)/fake.sendmail" \
1234 email-using-8bit >stdout &&
1235 grep "do not declare a Content-Transfer-Encoding" stdout &&
1236 grep email-using-8bit stdout &&
1237 grep "Which 8bit encoding" stdout &&
1238 egrep "Content|MIME" msgtxt1 >actual &&
1239 test_cmp actual content-type-decl
1242 test_expect_success
$PREREQ 'sendemail.8bitEncoding works' '
1243 clean_fake_sendmail &&
1244 git config sendemail.assume8bitEncoding UTF-8 &&
1246 git send-email --from=author@example.com --to=nobody@example.com \
1247 --smtp-server="$(pwd)/fake.sendmail" \
1248 email-using-8bit >stdout &&
1249 egrep "Content|MIME" msgtxt1 >actual &&
1250 test_cmp actual content-type-decl
1253 test_expect_success
$PREREQ '--8bit-encoding overrides sendemail.8bitEncoding' '
1254 clean_fake_sendmail &&
1255 git config sendemail.assume8bitEncoding "bogus too" &&
1257 git send-email --from=author@example.com --to=nobody@example.com \
1258 --smtp-server="$(pwd)/fake.sendmail" \
1259 --8bit-encoding=UTF-8 \
1260 email-using-8bit >stdout &&
1261 egrep "Content|MIME" msgtxt1 >actual &&
1262 test_cmp actual content-type-decl
1265 test_expect_success
$PREREQ 'setup expect' '
1266 cat >email-using-8bit <<-\EOF
1267 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1268 Message-Id: <bogus-message-id@example.com>
1269 From: author@example.com
1270 Date: Sat, 12 Jun 2010 15:53:58 +0200
1271 Subject: Dieser Betreff enthält auch einen Umlaut!
1273 Nothing to see here.
1277 test_expect_success
$PREREQ 'setup expect' '
1278 cat >expected <<-\EOF
1279 Subject: =?UTF-8?q?Dieser=20Betreff=20enth=C3=A4lt=20auch=20einen=20Umlaut!?=
1283 test_expect_success
$PREREQ '--8bit-encoding also treats subject' '
1284 clean_fake_sendmail &&
1286 git send-email --from=author@example.com --to=nobody@example.com \
1287 --smtp-server="$(pwd)/fake.sendmail" \
1288 --8bit-encoding=UTF-8 \
1289 email-using-8bit >stdout &&
1290 grep "Subject" msgtxt1 >actual &&
1291 test_cmp expected actual
1294 test_expect_success
$PREREQ 'setup expect' '
1295 cat >email-using-8bit <<-\EOF
1296 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1297 Message-Id: <bogus-message-id@example.com>
1298 From: A U Thor <author@example.com>
1299 Date: Sat, 12 Jun 2010 15:53:58 +0200
1300 Content-Type: text/plain; charset=UTF-8
1301 Subject: Nothing to see here.
1303 Dieser Betreff enthält auch einen Umlaut!
1307 test_expect_success
$PREREQ 'sendemail.transferencoding=7bit fails on 8bit data' '
1308 clean_fake_sendmail &&
1309 git config sendemail.transferEncoding 7bit &&
1310 test_must_fail git send-email \
1311 --transfer-encoding=7bit \
1312 --smtp-server="$(pwd)/fake.sendmail" \
1315 grep "cannot send message as 7bit" errors &&
1316 test -z "$(ls msgtxt*)"
1319 test_expect_success
$PREREQ '--transfer-encoding overrides sendemail.transferEncoding' '
1320 clean_fake_sendmail &&
1321 git config sendemail.transferEncoding 8bit
1322 test_must_fail git send-email \
1323 --transfer-encoding=7bit \
1324 --smtp-server="$(pwd)/fake.sendmail" \
1327 grep "cannot send message as 7bit" errors &&
1328 test -z "$(ls msgtxt*)"
1331 test_expect_success
$PREREQ 'sendemail.transferencoding=8bit' '
1332 clean_fake_sendmail &&
1334 --transfer-encoding=8bit \
1335 --smtp-server="$(pwd)/fake.sendmail" \
1338 sed '1,/^$
/d
' msgtxt1 >actual &&
1339 sed '1,/^$
/d
' email-using-8bit >expected &&
1340 test_cmp expected actual
1343 test_expect_success
$PREREQ 'setup expect' '
1344 cat >expected <<-\EOF
1345 Dieser Betreff enth=C3=A4lt auch einen Umlaut!
1349 test_expect_success
$PREREQ '8-bit and sendemail.transferencoding=quoted-printable' '
1350 clean_fake_sendmail &&
1352 --transfer-encoding=quoted-printable \
1353 --smtp-server="$(pwd)/fake.sendmail" \
1356 sed '1,/^$
/d
' msgtxt1 >actual &&
1357 test_cmp expected actual
1360 test_expect_success
$PREREQ 'setup expect' '
1361 cat >expected <<-\EOF
1362 RGllc2VyIEJldHJlZmYgZW50aMOkbHQgYXVjaCBlaW5lbiBVbWxhdXQhCg==
1366 test_expect_success
$PREREQ '8-bit and sendemail.transferencoding=base64' '
1367 clean_fake_sendmail &&
1369 --transfer-encoding=base64 \
1370 --smtp-server="$(pwd)/fake.sendmail" \
1373 sed '1,/^$
/d
' msgtxt1 >actual &&
1374 test_cmp expected actual
1377 test_expect_success
$PREREQ 'setup expect' '
1378 cat >email-using-qp <<-\EOF
1379 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1380 Message-Id: <bogus-message-id@example.com>
1381 From: A U Thor <author@example.com>
1382 Date: Sat, 12 Jun 2010 15:53:58 +0200
1384 Content-Transfer-Encoding: quoted-printable
1385 Content-Type: text/plain; charset=UTF-8
1386 Subject: Nothing to see here.
1388 Dieser Betreff enth=C3=A4lt auch einen Umlaut!
1392 test_expect_success
$PREREQ 'convert from quoted-printable to base64' '
1393 clean_fake_sendmail &&
1395 --transfer-encoding=base64 \
1396 --smtp-server="$(pwd)/fake.sendmail" \
1399 sed '1,/^$
/d
' msgtxt1 >actual &&
1400 test_cmp expected actual
1403 test_expect_success
$PREREQ 'setup expect' "
1404 tr -d '\\015' | tr '%' '\\015' >email-using-crlf <<EOF
1405 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1406 Message-Id: <bogus-message-id@example.com>
1407 From: A U Thor <author@example.com>
1408 Date: Sat, 12 Jun 2010 15:53:58 +0200
1409 Content-Type: text/plain; charset=UTF-8
1410 Subject: Nothing to see here.
1412 Look, I have a CRLF and an = sign!%
1416 test_expect_success
$PREREQ 'setup expect' '
1417 cat >expected <<-\EOF
1418 Look, I have a CRLF and an =3D sign!=0D
1422 test_expect_success
$PREREQ 'CRLF and sendemail.transferencoding=quoted-printable' '
1423 clean_fake_sendmail &&
1425 --transfer-encoding=quoted-printable \
1426 --smtp-server="$(pwd)/fake.sendmail" \
1429 sed '1,/^$
/d
' msgtxt1 >actual &&
1430 test_cmp expected actual
1433 test_expect_success
$PREREQ 'setup expect' '
1434 cat >expected <<-\EOF
1435 TG9vaywgSSBoYXZlIGEgQ1JMRiBhbmQgYW4gPSBzaWduIQ0K
1439 test_expect_success
$PREREQ 'CRLF and sendemail.transferencoding=base64' '
1440 clean_fake_sendmail &&
1442 --transfer-encoding=base64 \
1443 --smtp-server="$(pwd)/fake.sendmail" \
1446 sed '1,/^$
/d
' msgtxt1 >actual &&
1447 test_cmp expected actual
1451 # Note that the patches in this test are deliberately out of order; we
1452 # want to make sure it works even if the cover-letter is not in the
1454 test_expect_success
$PREREQ 'refusing to send cover letter template' '
1455 clean_fake_sendmail &&
1457 git format-patch --cover-letter -2 -o outdir &&
1458 test_must_fail git send-email \
1459 --from="Example <nobody@example.com>" \
1460 --to=nobody@example.com \
1461 --smtp-server="$(pwd)/fake.sendmail" \
1462 outdir/0002-*.patch \
1463 outdir/0000-*.patch \
1464 outdir/0001-*.patch \
1466 grep "SUBJECT HERE" errors &&
1467 test -z "$(ls msgtxt*)"
1470 test_expect_success
$PREREQ '--force sends cover letter template anyway' '
1471 clean_fake_sendmail &&
1473 git format-patch --cover-letter -2 -o outdir &&
1476 --from="Example <nobody@example.com>" \
1477 --to=nobody@example.com \
1478 --smtp-server="$(pwd)/fake.sendmail" \
1479 outdir/0002-*.patch \
1480 outdir/0000-*.patch \
1481 outdir/0001-*.patch \
1483 ! grep "SUBJECT HERE" errors &&
1484 test -n "$(ls msgtxt*)"
1487 test_cover_addresses
() {
1490 clean_fake_sendmail
&&
1492 git format-patch
--cover-letter -2 -o outdir
&&
1493 cover
=`echo outdir/0000-*.patch` &&
1494 mv $cover cover-to-edit.
patch &&
1495 perl
-pe "s/^From:/$header: extra\@address.com\nFrom:/" cover-to-edit.
patch >"$cover" &&
1498 --from="Example <nobody@example.com>" \
1501 --smtp-server="$(pwd)/fake.sendmail" \
1502 outdir
/0000-*.
patch \
1503 outdir
/0001-*.
patch \
1504 outdir
/0002-*.
patch \
1506 grep "^$header: extra@address.com" msgtxt1
>to1
&&
1507 grep "^$header: extra@address.com" msgtxt2
>to2
&&
1508 grep "^$header: extra@address.com" msgtxt3
>to3
&&
1509 test_line_count
= 1 to1
&&
1510 test_line_count
= 1 to2
&&
1511 test_line_count
= 1 to3
1514 test_expect_success
$PREREQ 'to-cover adds To to all mail' '
1515 test_cover_addresses "To" --to-cover
1518 test_expect_success
$PREREQ 'cc-cover adds Cc to all mail' '
1519 test_cover_addresses "Cc" --cc-cover
1522 test_expect_success
$PREREQ 'tocover adds To to all mail' '
1523 test_config sendemail.tocover true &&
1524 test_cover_addresses "To"
1527 test_expect_success
$PREREQ 'cccover adds Cc to all mail' '
1528 test_config sendemail.cccover true &&
1529 test_cover_addresses "Cc"
1532 test_expect_success
$PREREQ 'sendemail.aliasfiletype=mailrc' '
1533 clean_fake_sendmail &&
1534 echo "alias sbd somebody@example.org" >.mailrc &&
1535 git config --replace-all sendemail.aliasesfile "$(pwd)/.mailrc" &&
1536 git config sendemail.aliasfiletype mailrc &&
1538 --from="Example <nobody@example.com>" \
1540 --smtp-server="$(pwd)/fake.sendmail" \
1541 outdir/0001-*.patch \
1543 grep "^!somebody@example\.org!$" commandline1
1546 test_expect_success
$PREREQ 'sendemail.aliasfile=~/.mailrc' '
1547 clean_fake_sendmail &&
1548 echo "alias sbd someone@example.org" >~/.mailrc &&
1549 git config --replace-all sendemail.aliasesfile "~/.mailrc" &&
1550 git config sendemail.aliasfiletype mailrc &&
1552 --from="Example <nobody@example.com>" \
1554 --smtp-server="$(pwd)/fake.sendmail" \
1555 outdir/0001-*.patch \
1557 grep "^!someone@example\.org!$" commandline1