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 ! 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 for cc trailer' "
144 cat >expected-cc <<\EOF
145 !recipient@example.com!
154 test_expect_success
$PREREQ 'cc trailer with various syntax' '
155 test_commit cc-trailer &&
156 test_when_finished "git reset --hard HEAD^" &&
157 git commit --amend -F - <<-EOF &&
161 Cc: <two@example.com> # trailing comments are ignored
162 Cc: <three@example.com>, <not.four@example.com> one address per line
163 Cc: "Some # Body" <four@example.com> [ <also.a.comment> ]
165 clean_fake_sendmail &&
166 git send-email -1 --to=recipient@example.com \
167 --smtp-server="$(pwd)/fake.sendmail" &&
168 test_cmp expected-cc commandline1
171 test_expect_success
$PREREQ 'setup expect' "
172 cat >expected-show-all-headers <<\EOF
174 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
175 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
176 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
178 Server: relay.example.com
179 MAIL FROM:<from@example.com>
180 RCPT TO:<to@example.com>
181 RCPT TO:<cc@example.com>
182 RCPT TO:<author@example.com>
183 RCPT TO:<one@example.com>
184 RCPT TO:<two@example.com>
185 RCPT TO:<bcc@example.com>
186 From: Example <from@example.com>
189 A <author@example.com>,
190 One <one@example.com>,
192 Subject: [PATCH 1/1] Second.
194 Message-Id: MESSAGE-ID-STRING
195 X-Mailer: X-MAILER-STRING
196 In-Reply-To: <unique-message-id@example.com>
197 References: <unique-message-id@example.com>
203 test_suppress_self
() {
205 test_when_finished
"git reset --hard HEAD^" &&
207 write_script cccmd-sed
<<-EOF &&
208 sed -n -e s/^cccmd--//p "\$1"
211 git commit
--amend --author="$1 <$2>" -F - &&
212 clean_fake_sendmail
&&
213 git format-patch
--stdout -1 >"suppress-self-$3.patch" &&
215 git send-email
--from="$1 <$2>" \
216 --to=nobody@example.com \
217 --cc-cmd=.
/cccmd-sed \
219 --smtp-server="$(pwd)/fake.sendmail" \
220 suppress-self-
$3.
patch &&
222 mv msgtxt1 msgtxt1-
$3 &&
223 sed -e '/^$/q' msgtxt1-
$3 >"msghdr1-$3" &&
224 >"expected-no-cc-$3" &&
226 (grep '^Cc:' msghdr1-
$3 >"actual-no-cc-$3";
227 test_cmp expected-no-cc-
$3 actual-no-cc-
$3)
230 test_suppress_self_unquoted
() {
231 test_suppress_self
"$1" "$2" "unquoted-$3" <<-EOF
232 test suppress-cc.self unquoted-$3 with name $1 email $2
239 Signed-off-by: $1 <$2>
243 test_suppress_self_quoted
() {
244 test_suppress_self
"$1" "$2" "quoted-$3" <<-EOF
245 test suppress-cc.self quoted-$3 with name $1 email $2
253 Signed-off-by: $1 <$2>
254 Signed-off-by: "$1" <$2>
258 test_expect_success
$PREREQ 'self name is suppressed' "
259 test_suppress_self_unquoted 'A U Thor' 'author@example.com' \
260 'self_name_suppressed'
263 test_expect_success
$PREREQ 'self name with dot is suppressed' "
264 test_suppress_self_quoted 'A U. Thor' 'author@example.com' \
265 'self_name_dot_suppressed'
268 test_expect_success
$PREREQ 'non-ascii self name is suppressed' "
269 test_suppress_self_quoted 'Füñný Nâmé' 'odd_?=mail@example.com' \
270 'non_ascii_self_suppressed'
273 # This name is long enough to force format-patch to split it into multiple
274 # encoded-words, assuming it uses UTF-8 with the "Q" encoding.
275 test_expect_success
$PREREQ 'long non-ascii self name is suppressed' "
276 test_suppress_self_quoted 'Ƒüñníęř €. Nâṁé' 'odd_?=mail@example.com' \
277 'long_non_ascii_self_suppressed'
280 test_expect_success
$PREREQ 'sanitized self name is suppressed' "
281 test_suppress_self_unquoted '\"A U. Thor\"' 'author@example.com' \
282 'self_name_sanitized_suppressed'
285 test_expect_success
$PREREQ 'Show all headers' '
289 --from="Example <from@example.com>" \
290 --to=to@example.com \
291 --cc=cc@example.com \
292 --bcc=bcc@example.com \
293 --in-reply-to="<unique-message-id@example.com>" \
294 --smtp-server relay.example.com \
296 sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
297 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
298 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
299 >actual-show-all-headers &&
300 test_cmp expected-show-all-headers actual-show-all-headers
303 test_expect_success
$PREREQ 'Prompting works' '
304 clean_fake_sendmail &&
305 (echo "to@example.com"
307 ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
308 --smtp-server="$(pwd)/fake.sendmail" \
311 grep "^From: A U Thor <author@example.com>\$" msgtxt1 &&
312 grep "^To: to@example.com\$" msgtxt1
315 test_expect_success
$PREREQ,AUTOIDENT
'implicit ident is allowed' '
316 clean_fake_sendmail &&
317 (sane_unset GIT_AUTHOR_NAME &&
318 sane_unset GIT_AUTHOR_EMAIL &&
319 sane_unset GIT_COMMITTER_NAME &&
320 sane_unset GIT_COMMITTER_EMAIL &&
321 GIT_SEND_EMAIL_NOTTY=1 git send-email \
322 --smtp-server="$(pwd)/fake.sendmail" \
323 --to=to@example.com \
324 $patches </dev/null 2>errors
328 test_expect_success
$PREREQ,!AUTOIDENT
'broken implicit ident aborts send-email' '
329 clean_fake_sendmail &&
330 (sane_unset GIT_AUTHOR_NAME &&
331 sane_unset GIT_AUTHOR_EMAIL &&
332 sane_unset GIT_COMMITTER_NAME &&
333 sane_unset GIT_COMMITTER_EMAIL &&
334 GIT_SEND_EMAIL_NOTTY=1 && export GIT_SEND_EMAIL_NOTTY &&
335 test_must_fail git send-email \
336 --smtp-server="$(pwd)/fake.sendmail" \
337 --to=to@example.com \
338 $patches </dev/null 2>errors &&
339 test_i18ngrep "tell me who you are" errors
343 test_expect_success
$PREREQ 'setup tocmd and cccmd scripts' '
344 write_script tocmd-sed <<-\EOF &&
345 sed -n -e "s/^tocmd--//p" "$1"
347 write_script cccmd-sed <<-\EOF
348 sed -n -e "s/^cccmd--//p" "$1"
352 test_expect_success
$PREREQ 'tocmd works' '
353 clean_fake_sendmail &&
354 cp $patches tocmd.patch &&
355 echo tocmd--tocmd@example.com >>tocmd.patch &&
357 --from="Example <nobody@example.com>" \
358 --to-cmd=./tocmd-sed \
359 --smtp-server="$(pwd)/fake.sendmail" \
362 grep "^To: tocmd@example.com" msgtxt1
365 test_expect_success
$PREREQ 'cccmd works' '
366 clean_fake_sendmail &&
367 cp $patches cccmd.patch &&
368 echo "cccmd-- cccmd@example.com" >>cccmd.patch &&
370 --from="Example <nobody@example.com>" \
371 --to=nobody@example.com \
372 --cc-cmd=./cccmd-sed \
373 --smtp-server="$(pwd)/fake.sendmail" \
376 grep "^ cccmd@example.com" msgtxt1
379 test_expect_success
$PREREQ 'reject long lines' '
381 z64=$z8$z8$z8$z8$z8$z8$z8$z8 &&
382 z512=$z64$z64$z64$z64$z64$z64$z64$z64 &&
383 clean_fake_sendmail &&
384 cp $patches longline.patch &&
385 echo $z512$z512 >>longline.patch &&
386 test_must_fail git send-email \
387 --from="Example <nobody@example.com>" \
388 --to=nobody@example.com \
389 --smtp-server="$(pwd)/fake.sendmail" \
390 $patches longline.patch \
392 grep longline.patch errors
395 test_expect_success
$PREREQ 'no patch was sent' '
396 ! test -e commandline1
399 test_expect_success
$PREREQ 'Author From: in message body' '
400 clean_fake_sendmail &&
402 --from="Example <nobody@example.com>" \
403 --to=nobody@example.com \
404 --smtp-server="$(pwd)/fake.sendmail" \
406 sed "1,/^\$/d" <msgtxt1 >msgbody1 &&
407 grep "From: A <author@example.com>" msgbody1
410 test_expect_success
$PREREQ 'Author From: not in message body' '
411 clean_fake_sendmail &&
413 --from="A <author@example.com>" \
414 --to=nobody@example.com \
415 --smtp-server="$(pwd)/fake.sendmail" \
417 sed "1,/^\$/d" <msgtxt1 >msgbody1 &&
418 ! grep "From: A <author@example.com>" msgbody1
421 test_expect_success
$PREREQ 'allow long lines with --no-validate' '
423 --from="Example <nobody@example.com>" \
424 --to=nobody@example.com \
425 --smtp-server="$(pwd)/fake.sendmail" \
427 $patches longline.patch \
431 test_expect_success
$PREREQ 'Invalid In-Reply-To' '
432 clean_fake_sendmail &&
434 --from="Example <nobody@example.com>" \
435 --to=nobody@example.com \
437 --smtp-server="$(pwd)/fake.sendmail" \
440 ! grep "^In-Reply-To: < *>" msgtxt1
443 test_expect_success
$PREREQ 'Valid In-Reply-To when prompting' '
444 clean_fake_sendmail &&
445 (echo "From Example <from@example.com>"
446 echo "To Example <to@example.com>"
448 ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
449 --smtp-server="$(pwd)/fake.sendmail" \
451 ! grep "^In-Reply-To: < *>" msgtxt1
454 test_expect_success
$PREREQ 'In-Reply-To without --chain-reply-to' '
455 clean_fake_sendmail &&
456 echo "<unique-message-id@example.com>" >expect &&
458 --from="Example <nobody@example.com>" \
459 --to=nobody@example.com \
460 --no-chain-reply-to \
461 --in-reply-to="$(cat expect)" \
462 --smtp-server="$(pwd)/fake.sendmail" \
463 $patches $patches $patches \
465 # The first message is a reply to --in-reply-to
466 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual &&
467 test_cmp expect actual &&
468 # Second and subsequent messages are replies to the first one
469 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect &&
470 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual &&
471 test_cmp expect actual &&
472 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual &&
473 test_cmp expect actual
476 test_expect_success
$PREREQ 'In-Reply-To with --chain-reply-to' '
477 clean_fake_sendmail &&
478 echo "<unique-message-id@example.com>" >expect &&
480 --from="Example <nobody@example.com>" \
481 --to=nobody@example.com \
483 --in-reply-to="$(cat expect)" \
484 --smtp-server="$(pwd)/fake.sendmail" \
485 $patches $patches $patches \
487 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual &&
488 test_cmp expect actual &&
489 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect &&
490 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual &&
491 test_cmp expect actual &&
492 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt2 >expect &&
493 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual &&
494 test_cmp expect actual
497 test_expect_success
$PREREQ 'setup fake editor' '
498 write_script fake-editor <<-\EOF
499 echo fake edit >>"$1"
503 test_set_editor
"$(pwd)/fake-editor"
505 test_expect_success
$PREREQ '--compose works' '
506 clean_fake_sendmail &&
508 --compose --subject foo \
509 --from="Example <nobody@example.com>" \
510 --to=nobody@example.com \
511 --smtp-server="$(pwd)/fake.sendmail" \
516 test_expect_success
$PREREQ 'first message is compose text' '
517 grep "^fake edit" msgtxt1
520 test_expect_success
$PREREQ 'second message is patch' '
521 grep "Subject:.*Second" msgtxt2
524 test_expect_success
$PREREQ 'setup expect' "
525 cat >expected-suppress-sob <<\EOF
527 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
528 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
529 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
531 Server: relay.example.com
532 MAIL FROM:<from@example.com>
533 RCPT TO:<to@example.com>
534 RCPT TO:<cc@example.com>
535 RCPT TO:<author@example.com>
536 RCPT TO:<one@example.com>
537 RCPT TO:<two@example.com>
538 From: Example <from@example.com>
541 A <author@example.com>,
542 One <one@example.com>,
544 Subject: [PATCH 1/1] Second.
546 Message-Id: MESSAGE-ID-STRING
547 X-Mailer: X-MAILER-STRING
553 replace_variable_fields
() {
554 sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
555 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
556 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/"
559 test_suppression
() {
562 --suppress-cc=$1 ${2+"--suppress-cc=$2"} \
563 --from="Example <from@example.com>" \
564 --to=to@example.com \
565 --smtp-server relay.example.com \
566 $patches | replace_variable_fields \
567 >actual-suppress-
$1${2+"-$2"} &&
568 test_cmp expected-suppress-
$1${2+"-$2"} actual-suppress-
$1${2+"-$2"}
571 test_expect_success
$PREREQ 'sendemail.cc set' '
572 git config sendemail.cc cc@example.com &&
576 test_expect_success
$PREREQ 'setup expect' "
577 cat >expected-suppress-sob <<\EOF
579 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
580 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
581 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
583 Server: relay.example.com
584 MAIL FROM:<from@example.com>
585 RCPT TO:<to@example.com>
586 RCPT TO:<author@example.com>
587 RCPT TO:<one@example.com>
588 RCPT TO:<two@example.com>
589 From: Example <from@example.com>
591 Cc: A <author@example.com>,
592 One <one@example.com>,
594 Subject: [PATCH 1/1] Second.
596 Message-Id: MESSAGE-ID-STRING
597 X-Mailer: X-MAILER-STRING
603 test_expect_success
$PREREQ 'sendemail.cc unset' '
604 git config --unset sendemail.cc &&
608 test_expect_success
$PREREQ 'setup expect' "
609 cat >expected-suppress-cccmd <<\EOF
611 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
612 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
613 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
614 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
616 Server: relay.example.com
617 MAIL FROM:<from@example.com>
618 RCPT TO:<to@example.com>
619 RCPT TO:<author@example.com>
620 RCPT TO:<one@example.com>
621 RCPT TO:<two@example.com>
622 RCPT TO:<committer@example.com>
623 From: Example <from@example.com>
625 Cc: A <author@example.com>,
626 One <one@example.com>,
628 C O Mitter <committer@example.com>
629 Subject: [PATCH 1/1] Second.
631 Message-Id: MESSAGE-ID-STRING
632 X-Mailer: X-MAILER-STRING
638 test_expect_success
$PREREQ 'sendemail.cccmd' '
639 write_script cccmd <<-\EOF &&
640 echo cc-cmd@example.com
642 git config sendemail.cccmd ./cccmd &&
643 test_suppression cccmd
646 test_expect_success
$PREREQ 'setup expect' '
647 cat >expected-suppress-all <<\EOF
650 Server: relay.example.com
651 MAIL FROM:<from@example.com>
652 RCPT TO:<to@example.com>
653 From: Example <from@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=all' '
668 test_expect_success
$PREREQ 'setup expect' "
669 cat >expected-suppress-body <<\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'
674 (cc-cmd) Adding cc: cc-cmd@example.com from: './cccmd'
676 Server: relay.example.com
677 MAIL FROM:<from@example.com>
678 RCPT TO:<to@example.com>
679 RCPT TO:<author@example.com>
680 RCPT TO:<one@example.com>
681 RCPT TO:<two@example.com>
682 RCPT TO:<cc-cmd@example.com>
683 From: Example <from@example.com>
685 Cc: A <author@example.com>,
686 One <one@example.com>,
689 Subject: [PATCH 1/1] Second.
691 Message-Id: MESSAGE-ID-STRING
692 X-Mailer: X-MAILER-STRING
698 test_expect_success
$PREREQ '--suppress-cc=body' '
699 test_suppression body
702 test_expect_success
$PREREQ 'setup expect' "
703 cat >expected-suppress-body-cccmd <<\EOF
705 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
706 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
707 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
709 Server: relay.example.com
710 MAIL FROM:<from@example.com>
711 RCPT TO:<to@example.com>
712 RCPT TO:<author@example.com>
713 RCPT TO:<one@example.com>
714 RCPT TO:<two@example.com>
715 From: Example <from@example.com>
717 Cc: A <author@example.com>,
718 One <one@example.com>,
720 Subject: [PATCH 1/1] Second.
722 Message-Id: MESSAGE-ID-STRING
723 X-Mailer: X-MAILER-STRING
729 test_expect_success
$PREREQ '--suppress-cc=body --suppress-cc=cccmd' '
730 test_suppression body cccmd
733 test_expect_success
$PREREQ 'setup expect' "
734 cat >expected-suppress-sob <<\EOF
736 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
737 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
738 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
740 Server: relay.example.com
741 MAIL FROM:<from@example.com>
742 RCPT TO:<to@example.com>
743 RCPT TO:<author@example.com>
744 RCPT TO:<one@example.com>
745 RCPT TO:<two@example.com>
746 From: Example <from@example.com>
748 Cc: A <author@example.com>,
749 One <one@example.com>,
751 Subject: [PATCH 1/1] Second.
753 Message-Id: MESSAGE-ID-STRING
754 X-Mailer: X-MAILER-STRING
760 test_expect_success
$PREREQ '--suppress-cc=sob' '
761 test_might_fail git config --unset sendemail.cccmd &&
765 test_expect_success
$PREREQ 'setup expect' "
766 cat >expected-suppress-bodycc <<\EOF
768 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
769 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
770 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
771 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
773 Server: relay.example.com
774 MAIL FROM:<from@example.com>
775 RCPT TO:<to@example.com>
776 RCPT TO:<author@example.com>
777 RCPT TO:<one@example.com>
778 RCPT TO:<two@example.com>
779 RCPT TO:<committer@example.com>
780 From: Example <from@example.com>
782 Cc: A <author@example.com>,
783 One <one@example.com>,
785 C O Mitter <committer@example.com>
786 Subject: [PATCH 1/1] Second.
788 Message-Id: MESSAGE-ID-STRING
789 X-Mailer: X-MAILER-STRING
795 test_expect_success
$PREREQ '--suppress-cc=bodycc' '
796 test_suppression bodycc
799 test_expect_success
$PREREQ 'setup expect' "
800 cat >expected-suppress-cc <<\EOF
802 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
803 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
805 Server: relay.example.com
806 MAIL FROM:<from@example.com>
807 RCPT TO:<to@example.com>
808 RCPT TO:<author@example.com>
809 RCPT TO:<committer@example.com>
810 From: Example <from@example.com>
812 Cc: A <author@example.com>,
813 C O Mitter <committer@example.com>
814 Subject: [PATCH 1/1] Second.
816 Message-Id: MESSAGE-ID-STRING
817 X-Mailer: X-MAILER-STRING
823 test_expect_success
$PREREQ '--suppress-cc=cc' '
829 GIT_SEND_EMAIL_NOTTY
=1 \
831 --from="Example <nobody@example.com>" \
832 --to=nobody@example.com \
833 --smtp-server="$(pwd)/fake.sendmail" \
834 $@
$patches >stdout
&&
835 grep "Send this email" stdout
838 test_expect_success
$PREREQ '--confirm=always' '
839 test_confirm --confirm=always --suppress-cc=all
842 test_expect_success
$PREREQ '--confirm=auto' '
843 test_confirm --confirm=auto
846 test_expect_success
$PREREQ '--confirm=cc' '
847 test_confirm --confirm=cc
850 test_expect_success
$PREREQ '--confirm=compose' '
851 test_confirm --confirm=compose --compose
854 test_expect_success
$PREREQ 'confirm by default (due to cc)' '
855 test_when_finished git config sendemail.confirm never &&
856 git config --unset sendemail.confirm &&
860 test_expect_success
$PREREQ 'confirm by default (due to --compose)' '
861 test_when_finished git config sendemail.confirm never &&
862 git config --unset sendemail.confirm &&
863 test_confirm --suppress-cc=all --compose
866 test_expect_success
$PREREQ 'confirm detects EOF (inform assumes y)' '
867 test_when_finished git config sendemail.confirm never &&
868 git config --unset sendemail.confirm &&
870 git format-patch -2 -o outdir &&
871 GIT_SEND_EMAIL_NOTTY=1 \
873 --from="Example <nobody@example.com>" \
874 --to=nobody@example.com \
875 --smtp-server="$(pwd)/fake.sendmail" \
876 outdir/*.patch </dev/null
879 test_expect_success
$PREREQ 'confirm detects EOF (auto causes failure)' '
880 test_when_finished git config sendemail.confirm never &&
881 git config sendemail.confirm auto &&
882 GIT_SEND_EMAIL_NOTTY=1 &&
883 export GIT_SEND_EMAIL_NOTTY &&
884 test_must_fail git send-email \
885 --from="Example <nobody@example.com>" \
886 --to=nobody@example.com \
887 --smtp-server="$(pwd)/fake.sendmail" \
891 test_expect_success
$PREREQ 'confirm does not loop forever' '
892 test_when_finished git config sendemail.confirm never &&
893 git config sendemail.confirm auto &&
894 GIT_SEND_EMAIL_NOTTY=1 &&
895 export GIT_SEND_EMAIL_NOTTY &&
896 yes "bogus" | test_must_fail git send-email \
897 --from="Example <nobody@example.com>" \
898 --to=nobody@example.com \
899 --smtp-server="$(pwd)/fake.sendmail" \
903 test_expect_success
$PREREQ 'utf8 Cc is rfc2047 encoded' '
904 clean_fake_sendmail &&
906 git format-patch -1 -o outdir --cc="àéìöú <utf8@example.com>" &&
908 --from="Example <nobody@example.com>" \
909 --to=nobody@example.com \
910 --smtp-server="$(pwd)/fake.sendmail" \
913 grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>"
916 test_expect_success
$PREREQ '--compose adds MIME for utf8 body' '
917 clean_fake_sendmail &&
918 write_script fake-editor-utf8 <<-\EOF &&
919 echo "utf8 body: àéìöú" >>"$1"
921 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
923 --compose --subject foo \
924 --from="Example <nobody@example.com>" \
925 --to=nobody@example.com \
926 --smtp-server="$(pwd)/fake.sendmail" \
928 grep "^utf8 body" msgtxt1 &&
929 grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
932 test_expect_success
$PREREQ '--compose respects user mime type' '
933 clean_fake_sendmail &&
934 write_script fake-editor-utf8-mime <<-\EOF &&
937 Content-Type: text/plain; charset=iso-8859-1
938 Content-Transfer-Encoding: 8bit
944 GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \
946 --compose --subject foo \
947 --from="Example <nobody@example.com>" \
948 --to=nobody@example.com \
949 --smtp-server="$(pwd)/fake.sendmail" \
951 grep "^utf8 body" msgtxt1 &&
952 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 &&
953 ! grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
956 test_expect_success
$PREREQ '--compose adds MIME for utf8 subject' '
957 clean_fake_sendmail &&
958 GIT_EDITOR="\"$(pwd)/fake-editor\"" \
960 --compose --subject utf8-sübjëct \
961 --from="Example <nobody@example.com>" \
962 --to=nobody@example.com \
963 --smtp-server="$(pwd)/fake.sendmail" \
965 grep "^fake edit" msgtxt1 &&
966 grep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
969 test_expect_success
$PREREQ 'utf8 author is correctly passed on' '
970 clean_fake_sendmail &&
971 test_commit weird_author &&
972 test_when_finished "git reset --hard HEAD^" &&
973 git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" &&
974 git format-patch --stdout -1 >funny_name.patch &&
975 git send-email --from="Example <nobody@example.com>" \
976 --to=nobody@example.com \
977 --smtp-server="$(pwd)/fake.sendmail" \
979 grep "^From: Füñný Nâmé <odd_?=mail@example.com>" msgtxt1
982 test_expect_success
$PREREQ 'utf8 sender is not duplicated' '
983 clean_fake_sendmail &&
984 test_commit weird_sender &&
985 test_when_finished "git reset --hard HEAD^" &&
986 git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" &&
987 git format-patch --stdout -1 >funny_name.patch &&
988 git send-email --from="Füñný Nâmé <odd_?=mail@example.com>" \
989 --to=nobody@example.com \
990 --smtp-server="$(pwd)/fake.sendmail" \
992 grep "^From: " msgtxt1 >msgfrom &&
993 test_line_count = 1 msgfrom
996 test_expect_success
$PREREQ 'sendemail.composeencoding works' '
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 --subject foo \
1005 --from="Example <nobody@example.com>" \
1006 --to=nobody@example.com \
1007 --smtp-server="$(pwd)/fake.sendmail" \
1009 grep "^utf8 body" msgtxt1 &&
1010 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1
1013 test_expect_success
$PREREQ '--compose-encoding works' '
1014 clean_fake_sendmail &&
1015 write_script fake-editor-utf8 <<-\EOF &&
1016 echo "utf8 body: àéìöú" >>"$1"
1018 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
1020 --compose-encoding iso-8859-1 \
1021 --compose --subject foo \
1022 --from="Example <nobody@example.com>" \
1023 --to=nobody@example.com \
1024 --smtp-server="$(pwd)/fake.sendmail" \
1026 grep "^utf8 body" msgtxt1 &&
1027 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1
1030 test_expect_success
$PREREQ '--compose-encoding overrides sendemail.composeencoding' '
1031 clean_fake_sendmail &&
1032 git config sendemail.composeencoding iso-8859-1 &&
1033 write_script fake-editor-utf8 <<-\EOF &&
1034 echo "utf8 body: àéìöú" >>"$1"
1036 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
1038 --compose-encoding iso-8859-2 \
1039 --compose --subject foo \
1040 --from="Example <nobody@example.com>" \
1041 --to=nobody@example.com \
1042 --smtp-server="$(pwd)/fake.sendmail" \
1044 grep "^utf8 body" msgtxt1 &&
1045 grep "^Content-Type: text/plain; charset=iso-8859-2" msgtxt1
1048 test_expect_success
$PREREQ '--compose-encoding adds correct MIME for subject' '
1049 clean_fake_sendmail &&
1050 GIT_EDITOR="\"$(pwd)/fake-editor\"" \
1052 --compose-encoding iso-8859-2 \
1053 --compose --subject utf8-sübjëct \
1054 --from="Example <nobody@example.com>" \
1055 --to=nobody@example.com \
1056 --smtp-server="$(pwd)/fake.sendmail" \
1058 grep "^fake edit" msgtxt1 &&
1059 grep "^Subject: =?iso-8859-2?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
1062 test_expect_success
$PREREQ 'detects ambiguous reference/file conflict' '
1063 echo master >master &&
1065 git commit -m"add master" &&
1066 test_must_fail git send-email --dry-run master 2>errors &&
1067 grep disambiguate errors
1070 test_expect_success
$PREREQ 'feed two files' '
1072 git format-patch -2 -o outdir &&
1075 --from="Example <nobody@example.com>" \
1076 --to=nobody@example.com \
1077 outdir/000?-*.patch 2>errors >out &&
1078 grep "^Subject: " out >subjects &&
1079 test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." &&
1080 test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add master"
1083 test_expect_success
$PREREQ 'in-reply-to but no threading' '
1086 --from="Example <nobody@example.com>" \
1087 --to=nobody@example.com \
1088 --in-reply-to="<in-reply-id@example.com>" \
1091 grep "In-Reply-To: <in-reply-id@example.com>"
1094 test_expect_success
$PREREQ 'no in-reply-to and no threading' '
1097 --from="Example <nobody@example.com>" \
1098 --to=nobody@example.com \
1100 $patches $patches >stdout &&
1101 ! grep "In-Reply-To: " stdout
1104 test_expect_success
$PREREQ 'threading but no chain-reply-to' '
1107 --from="Example <nobody@example.com>" \
1108 --to=nobody@example.com \
1110 --no-chain-reply-to \
1111 $patches $patches >stdout &&
1112 grep "In-Reply-To: " stdout
1115 test_expect_success
$PREREQ 'sendemail.to works' '
1116 git config --replace-all sendemail.to "Somebody <somebody@ex.com>" &&
1119 --from="Example <nobody@example.com>" \
1120 $patches $patches >stdout &&
1121 grep "To: Somebody <somebody@ex.com>" stdout
1124 test_expect_success
$PREREQ '--no-to overrides sendemail.to' '
1127 --from="Example <nobody@example.com>" \
1129 --to=nobody@example.com \
1130 $patches $patches >stdout &&
1131 grep "To: nobody@example.com" stdout &&
1132 ! grep "To: Somebody <somebody@ex.com>" stdout
1135 test_expect_success
$PREREQ 'sendemail.cc works' '
1136 git config --replace-all sendemail.cc "Somebody <somebody@ex.com>" &&
1139 --from="Example <nobody@example.com>" \
1140 --to=nobody@example.com \
1141 $patches $patches >stdout &&
1142 grep "Cc: Somebody <somebody@ex.com>" stdout
1145 test_expect_success
$PREREQ '--no-cc overrides sendemail.cc' '
1148 --from="Example <nobody@example.com>" \
1150 --cc=bodies@example.com \
1151 --to=nobody@example.com \
1152 $patches $patches >stdout &&
1153 grep "Cc: bodies@example.com" stdout &&
1154 ! grep "Cc: Somebody <somebody@ex.com>" stdout
1157 test_expect_success
$PREREQ 'sendemail.bcc works' '
1158 git config --replace-all sendemail.bcc "Other <other@ex.com>" &&
1161 --from="Example <nobody@example.com>" \
1162 --to=nobody@example.com \
1163 --smtp-server relay.example.com \
1164 $patches $patches >stdout &&
1165 grep "RCPT TO:<other@ex.com>" stdout
1168 test_expect_success
$PREREQ '--no-bcc overrides sendemail.bcc' '
1171 --from="Example <nobody@example.com>" \
1173 --bcc=bodies@example.com \
1174 --to=nobody@example.com \
1175 --smtp-server relay.example.com \
1176 $patches $patches >stdout &&
1177 grep "RCPT TO:<bodies@example.com>" stdout &&
1178 ! grep "RCPT TO:<other@ex.com>" stdout
1181 test_expect_success
$PREREQ 'patches To headers are used by default' '
1182 patch=$(git format-patch -1 --to="bodies@example.com") &&
1183 test_when_finished "rm $patch" &&
1186 --from="Example <nobody@example.com>" \
1187 --smtp-server relay.example.com \
1189 grep "RCPT TO:<bodies@example.com>" stdout
1192 test_expect_success
$PREREQ 'patches To headers are appended to' '
1193 patch=$(git format-patch -1 --to="bodies@example.com") &&
1194 test_when_finished "rm $patch" &&
1197 --from="Example <nobody@example.com>" \
1198 --to=nobody@example.com \
1199 --smtp-server relay.example.com \
1201 grep "RCPT TO:<bodies@example.com>" stdout &&
1202 grep "RCPT TO:<nobody@example.com>" stdout
1205 test_expect_success
$PREREQ 'To headers from files reset each patch' '
1206 patch1=$(git format-patch -1 --to="bodies@example.com") &&
1207 patch2=$(git format-patch -1 --to="other@example.com" HEAD~) &&
1208 test_when_finished "rm $patch1 && rm $patch2" &&
1211 --from="Example <nobody@example.com>" \
1212 --to="nobody@example.com" \
1213 --smtp-server relay.example.com \
1214 $patch1 $patch2 >stdout &&
1215 test $(grep -c "RCPT TO:<bodies@example.com>" stdout) = 1 &&
1216 test $(grep -c "RCPT TO:<nobody@example.com>" stdout) = 2 &&
1217 test $(grep -c "RCPT TO:<other@example.com>" stdout) = 1
1220 test_expect_success
$PREREQ 'setup expect' '
1221 cat >email-using-8bit <<\EOF
1222 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1223 Message-Id: <bogus-message-id@example.com>
1224 From: author@example.com
1225 Date: Sat, 12 Jun 2010 15:53:58 +0200
1226 Subject: subject goes here
1228 Dieser deutsche Text enthält einen Umlaut!
1232 test_expect_success
$PREREQ 'setup expect' '
1233 echo "Subject: subject goes here" >expected
1236 test_expect_success
$PREREQ 'ASCII subject is not RFC2047 quoted' '
1237 clean_fake_sendmail &&
1239 git send-email --from=author@example.com --to=nobody@example.com \
1240 --smtp-server="$(pwd)/fake.sendmail" \
1241 --8bit-encoding=UTF-8 \
1242 email-using-8bit >stdout &&
1243 grep "Subject" msgtxt1 >actual &&
1244 test_cmp expected actual
1247 test_expect_success
$PREREQ 'setup expect' '
1248 cat >content-type-decl <<-\EOF
1250 Content-Type: text/plain; charset=UTF-8
1251 Content-Transfer-Encoding: 8bit
1255 test_expect_success
$PREREQ 'asks about and fixes 8bit encodings' '
1256 clean_fake_sendmail &&
1258 git send-email --from=author@example.com --to=nobody@example.com \
1259 --smtp-server="$(pwd)/fake.sendmail" \
1260 email-using-8bit >stdout &&
1261 grep "do not declare a Content-Transfer-Encoding" stdout &&
1262 grep email-using-8bit stdout &&
1263 grep "Which 8bit encoding" stdout &&
1264 egrep "Content|MIME" msgtxt1 >actual &&
1265 test_cmp actual content-type-decl
1268 test_expect_success
$PREREQ 'sendemail.8bitEncoding works' '
1269 clean_fake_sendmail &&
1270 git config sendemail.assume8bitEncoding UTF-8 &&
1272 git send-email --from=author@example.com --to=nobody@example.com \
1273 --smtp-server="$(pwd)/fake.sendmail" \
1274 email-using-8bit >stdout &&
1275 egrep "Content|MIME" msgtxt1 >actual &&
1276 test_cmp actual content-type-decl
1279 test_expect_success
$PREREQ '--8bit-encoding overrides sendemail.8bitEncoding' '
1280 clean_fake_sendmail &&
1281 git config sendemail.assume8bitEncoding "bogus too" &&
1283 git send-email --from=author@example.com --to=nobody@example.com \
1284 --smtp-server="$(pwd)/fake.sendmail" \
1285 --8bit-encoding=UTF-8 \
1286 email-using-8bit >stdout &&
1287 egrep "Content|MIME" msgtxt1 >actual &&
1288 test_cmp actual content-type-decl
1291 test_expect_success
$PREREQ 'setup expect' '
1292 cat >email-using-8bit <<-\EOF
1293 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1294 Message-Id: <bogus-message-id@example.com>
1295 From: author@example.com
1296 Date: Sat, 12 Jun 2010 15:53:58 +0200
1297 Subject: Dieser Betreff enthält auch einen Umlaut!
1299 Nothing to see here.
1303 test_expect_success
$PREREQ 'setup expect' '
1304 cat >expected <<-\EOF
1305 Subject: =?UTF-8?q?Dieser=20Betreff=20enth=C3=A4lt=20auch=20einen=20Umlaut!?=
1309 test_expect_success
$PREREQ '--8bit-encoding also treats subject' '
1310 clean_fake_sendmail &&
1312 git send-email --from=author@example.com --to=nobody@example.com \
1313 --smtp-server="$(pwd)/fake.sendmail" \
1314 --8bit-encoding=UTF-8 \
1315 email-using-8bit >stdout &&
1316 grep "Subject" msgtxt1 >actual &&
1317 test_cmp expected actual
1320 test_expect_success
$PREREQ 'setup expect' '
1321 cat >email-using-8bit <<-\EOF
1322 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1323 Message-Id: <bogus-message-id@example.com>
1324 From: A U Thor <author@example.com>
1325 Date: Sat, 12 Jun 2010 15:53:58 +0200
1326 Content-Type: text/plain; charset=UTF-8
1327 Subject: Nothing to see here.
1329 Dieser Betreff enthält auch einen Umlaut!
1333 test_expect_success
$PREREQ 'sendemail.transferencoding=7bit fails on 8bit data' '
1334 clean_fake_sendmail &&
1335 git config sendemail.transferEncoding 7bit &&
1336 test_must_fail git send-email \
1337 --transfer-encoding=7bit \
1338 --smtp-server="$(pwd)/fake.sendmail" \
1341 grep "cannot send message as 7bit" errors &&
1342 test -z "$(ls msgtxt*)"
1345 test_expect_success
$PREREQ '--transfer-encoding overrides sendemail.transferEncoding' '
1346 clean_fake_sendmail &&
1347 git config sendemail.transferEncoding 8bit &&
1348 test_must_fail git send-email \
1349 --transfer-encoding=7bit \
1350 --smtp-server="$(pwd)/fake.sendmail" \
1353 grep "cannot send message as 7bit" errors &&
1354 test -z "$(ls msgtxt*)"
1357 test_expect_success
$PREREQ 'sendemail.transferencoding=8bit' '
1358 clean_fake_sendmail &&
1360 --transfer-encoding=8bit \
1361 --smtp-server="$(pwd)/fake.sendmail" \
1364 sed '1,/^$
/d
' msgtxt1 >actual &&
1365 sed '1,/^$
/d
' email-using-8bit >expected &&
1366 test_cmp expected actual
1369 test_expect_success
$PREREQ 'setup expect' '
1370 cat >expected <<-\EOF
1371 Dieser Betreff enth=C3=A4lt auch einen Umlaut!
1375 test_expect_success
$PREREQ '8-bit and sendemail.transferencoding=quoted-printable' '
1376 clean_fake_sendmail &&
1378 --transfer-encoding=quoted-printable \
1379 --smtp-server="$(pwd)/fake.sendmail" \
1382 sed '1,/^$
/d
' msgtxt1 >actual &&
1383 test_cmp expected actual
1386 test_expect_success
$PREREQ 'setup expect' '
1387 cat >expected <<-\EOF
1388 RGllc2VyIEJldHJlZmYgZW50aMOkbHQgYXVjaCBlaW5lbiBVbWxhdXQhCg==
1392 test_expect_success
$PREREQ '8-bit and sendemail.transferencoding=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 cat >email-using-qp <<-\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
1410 Content-Transfer-Encoding: quoted-printable
1411 Content-Type: text/plain; charset=UTF-8
1412 Subject: Nothing to see here.
1414 Dieser Betreff enth=C3=A4lt auch einen Umlaut!
1418 test_expect_success
$PREREQ 'convert from quoted-printable to base64' '
1419 clean_fake_sendmail &&
1421 --transfer-encoding=base64 \
1422 --smtp-server="$(pwd)/fake.sendmail" \
1425 sed '1,/^$
/d
' msgtxt1 >actual &&
1426 test_cmp expected actual
1429 test_expect_success
$PREREQ 'setup expect' "
1430 tr -d '\\015' | tr '%' '\\015' >email-using-crlf <<EOF
1431 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1432 Message-Id: <bogus-message-id@example.com>
1433 From: A U Thor <author@example.com>
1434 Date: Sat, 12 Jun 2010 15:53:58 +0200
1435 Content-Type: text/plain; charset=UTF-8
1436 Subject: Nothing to see here.
1438 Look, I have a CRLF and an = sign!%
1442 test_expect_success
$PREREQ 'setup expect' '
1443 cat >expected <<-\EOF
1444 Look, I have a CRLF and an =3D sign!=0D
1448 test_expect_success
$PREREQ 'CRLF and sendemail.transferencoding=quoted-printable' '
1449 clean_fake_sendmail &&
1451 --transfer-encoding=quoted-printable \
1452 --smtp-server="$(pwd)/fake.sendmail" \
1455 sed '1,/^$
/d
' msgtxt1 >actual &&
1456 test_cmp expected actual
1459 test_expect_success
$PREREQ 'setup expect' '
1460 cat >expected <<-\EOF
1461 TG9vaywgSSBoYXZlIGEgQ1JMRiBhbmQgYW4gPSBzaWduIQ0K
1465 test_expect_success
$PREREQ 'CRLF and sendemail.transferencoding=base64' '
1466 clean_fake_sendmail &&
1468 --transfer-encoding=base64 \
1469 --smtp-server="$(pwd)/fake.sendmail" \
1472 sed '1,/^$
/d
' msgtxt1 >actual &&
1473 test_cmp expected actual
1477 # Note that the patches in this test are deliberately out of order; we
1478 # want to make sure it works even if the cover-letter is not in the
1480 test_expect_success
$PREREQ 'refusing to send cover letter template' '
1481 clean_fake_sendmail &&
1483 git format-patch --cover-letter -2 -o outdir &&
1484 test_must_fail git send-email \
1485 --from="Example <nobody@example.com>" \
1486 --to=nobody@example.com \
1487 --smtp-server="$(pwd)/fake.sendmail" \
1488 outdir/0002-*.patch \
1489 outdir/0000-*.patch \
1490 outdir/0001-*.patch \
1492 grep "SUBJECT HERE" errors &&
1493 test -z "$(ls msgtxt*)"
1496 test_expect_success
$PREREQ '--force sends cover letter template anyway' '
1497 clean_fake_sendmail &&
1499 git format-patch --cover-letter -2 -o outdir &&
1502 --from="Example <nobody@example.com>" \
1503 --to=nobody@example.com \
1504 --smtp-server="$(pwd)/fake.sendmail" \
1505 outdir/0002-*.patch \
1506 outdir/0000-*.patch \
1507 outdir/0001-*.patch \
1509 ! grep "SUBJECT HERE" errors &&
1510 test -n "$(ls msgtxt*)"
1513 test_cover_addresses
() {
1516 clean_fake_sendmail
&&
1518 git format-patch
--cover-letter -2 -o outdir
&&
1519 cover
=$
(echo outdir
/0000-*.
patch) &&
1520 mv $cover cover-to-edit.
patch &&
1521 perl
-pe "s/^From:/$header: extra\@address.com\nFrom:/" cover-to-edit.
patch >"$cover" &&
1524 --from="Example <nobody@example.com>" \
1527 --smtp-server="$(pwd)/fake.sendmail" \
1528 outdir
/0000-*.
patch \
1529 outdir
/0001-*.
patch \
1530 outdir
/0002-*.
patch \
1532 grep "^$header: extra@address.com" msgtxt1
>to1
&&
1533 grep "^$header: extra@address.com" msgtxt2
>to2
&&
1534 grep "^$header: extra@address.com" msgtxt3
>to3
&&
1535 test_line_count
= 1 to1
&&
1536 test_line_count
= 1 to2
&&
1537 test_line_count
= 1 to3
1540 test_expect_success
$PREREQ 'to-cover adds To to all mail' '
1541 test_cover_addresses "To" --to-cover
1544 test_expect_success
$PREREQ 'cc-cover adds Cc to all mail' '
1545 test_cover_addresses "Cc" --cc-cover
1548 test_expect_success
$PREREQ 'tocover adds To to all mail' '
1549 test_config sendemail.tocover true &&
1550 test_cover_addresses "To"
1553 test_expect_success
$PREREQ 'cccover adds Cc to all mail' '
1554 test_config sendemail.cccover true &&
1555 test_cover_addresses "Cc"
1558 test_expect_success
$PREREQ 'escaped quotes in sendemail.aliasfiletype=mutt' '
1559 clean_fake_sendmail &&
1560 echo "alias sbd \\\"Dot U. Sir\\\" <somebody@example.org>" >.mutt &&
1561 git config --replace-all sendemail.aliasesfile "$(pwd)/.mutt" &&
1562 git config sendemail.aliasfiletype mutt &&
1564 --from="Example <nobody@example.com>" \
1566 --smtp-server="$(pwd)/fake.sendmail" \
1567 outdir/0001-*.patch \
1569 grep "^!somebody@example\.org!$" commandline1 &&
1570 grep -F "To: \"Dot U. Sir\" <somebody@example.org>" out
1573 test_expect_success
$PREREQ 'sendemail.aliasfiletype=mailrc' '
1574 clean_fake_sendmail &&
1575 echo "alias sbd somebody@example.org" >.mailrc &&
1576 git config --replace-all sendemail.aliasesfile "$(pwd)/.mailrc" &&
1577 git config sendemail.aliasfiletype mailrc &&
1579 --from="Example <nobody@example.com>" \
1581 --smtp-server="$(pwd)/fake.sendmail" \
1582 outdir/0001-*.patch \
1584 grep "^!somebody@example\.org!$" commandline1
1587 test_expect_success
$PREREQ 'sendemail.aliasfile=~/.mailrc' '
1588 clean_fake_sendmail &&
1589 echo "alias sbd someone@example.org" >"$HOME/.mailrc" &&
1590 git config --replace-all sendemail.aliasesfile "~/.mailrc" &&
1591 git config sendemail.aliasfiletype mailrc &&
1593 --from="Example <nobody@example.com>" \
1595 --smtp-server="$(pwd)/fake.sendmail" \
1596 outdir/0001-*.patch \
1598 grep "^!someone@example\.org!$" commandline1
1601 test_dump_aliases
() {
1602 msg
="$1" && shift &&
1603 filetype
="$1" && shift &&
1604 printf '%s\n' "$@" >expect
&&
1605 cat >.tmp-email-aliases
&&
1607 test_expect_success
$PREREQ "$msg" '
1608 clean_fake_sendmail && rm -fr outdir &&
1609 git config --replace-all sendemail.aliasesfile \
1610 "$(pwd)/.tmp-email-aliases" &&
1611 git config sendemail.aliasfiletype "$filetype" &&
1612 git send-email --dump-aliases 2>errors >actual &&
1613 test_cmp expect actual
1617 test_dump_aliases
'--dump-aliases sendmail format' \
1624 alice: Alice W Land <awol@example.com>
1625 bob: Robert Bobbyton <bob@example.com>
1626 chloe: chloe@example.com
1628 bcgrp: bob, chloe, Other <o@example.com>
1631 test_dump_aliases '--dump-aliases mutt format' \
1637 alias alice Alice W Land <awol@example.com>
1638 alias donald Donald C Carlton <donc@example.com>
1639 alias bob Robert Bobbyton <bob@example.com>
1640 alias chloe chloe@example.com
1643 test_dump_aliases '--dump-aliases mailrc format' \
1649 alias alice Alice W Land <awol@example.com>
1650 alias eve Eve <eve@example.com>
1651 alias bob Robert Bobbyton <bob@example.com>
1652 alias chloe chloe@example.com
1655 test_dump_aliases '--dump-aliases pine format' \
1661 alice Alice W Land <awol@example.com>
1662 eve Eve <eve@example.com>
1663 bob Robert Bobbyton <bob@example.com>
1664 chloe chloe@example.com
1667 test_dump_aliases '--dump-aliases gnus format' \
1673 (define-mail-alias "alice" "awol@example.com")
1674 (define-mail-alias "eve" "eve@example.com")
1675 (define-mail-alias "bob" "bob@example.com")
1676 (define-mail-alias "chloe" "chloe@example.com")
1679 test_expect_success '--dump-aliases must be used alone' '
1680 test_must_fail git send-email --dump-aliases --to=janice@example.com -1 refs/heads/accounting
1683 test_sendmail_aliases () {
1684 msg="$1" && shift &&
1686 cat >.tmp-email-aliases &&
1688 test_expect_success $PREREQ "$msg" '
1689 clean_fake_sendmail && rm -fr outdir &&
1690 git format-patch -1 -o outdir &&
1691 git config --replace-all sendemail.aliasesfile \
1692 "$(pwd)/.tmp-email-aliases" &&
1693 git config sendemail.aliasfiletype sendmail &&
1695 --from="Example <nobody@example.com>" \
1696 --to=alice --to=bcgrp \
1697 --smtp-server="$(pwd)/fake.sendmail" \
1698 outdir/0001-*.
patch \
1702 grep "^!$i!$" commandline1 ||
return 1
1707 test_sendmail_aliases 'sendemail.aliasfiletype
=sendmail
' \
1708 'awol@example\.com
' \
1709 'bob@example\.com
' \
1710 'chloe@example\.com
' \
1711 'o@example\.com
' <<-\EOF
1712 alice: Alice W Land <awol@example.com>
1713 bob: Robert Bobbyton <bob@example.com>
1715 # this is also a comment
1716 chloe: chloe@example.com
1718 bcgrp: bob, chloe, Other <o@example.com>
1721 test_sendmail_aliases 'sendmail aliases line folding
' \
1725 darla1 darla2 darla3 \
1726 elton1 elton2 elton3 \
1743 bcgrp: bob, chuck, darla, elton, fred, greg
1746 test_sendmail_aliases 'sendmail aliases tolerate bogus line folding
' \
1752 test_sendmail_aliases 'sendmail aliases empty
' alice bcgrp <<-\EOF
1755 test_expect_success $PREREQ 'alias support
in To header
' '
1756 clean_fake_sendmail
&&
1757 echo "alias sbd someone@example.org" >.mailrc
&&
1758 test_config sendemail.aliasesfile
".mailrc" &&
1759 test_config sendemail.aliasfiletype mailrc
&&
1760 git format-patch
--stdout -1 --to=sbd
>aliased.
patch &&
1762 --from="Example <nobody@example.com>" \
1763 --smtp-server="$(pwd)/fake.sendmail" \
1766 grep "^!someone@example\.org!$" commandline1
1769 test_expect_success $PREREQ 'alias support
in Cc header
' '
1770 clean_fake_sendmail
&&
1771 echo "alias sbd someone@example.org" >.mailrc
&&
1772 test_config sendemail.aliasesfile
".mailrc" &&
1773 test_config sendemail.aliasfiletype mailrc
&&
1774 git format-patch
--stdout -1 --cc=sbd
>aliased.
patch &&
1776 --from="Example <nobody@example.com>" \
1777 --smtp-server="$(pwd)/fake.sendmail" \
1780 grep "^!someone@example\.org!$" commandline1
1783 test_expect_success $PREREQ 'tocmd works with aliases
' '
1784 clean_fake_sendmail
&&
1785 echo "alias sbd someone@example.org" >.mailrc
&&
1786 test_config sendemail.aliasesfile
".mailrc" &&
1787 test_config sendemail.aliasfiletype mailrc
&&
1788 git format-patch
--stdout -1 >tocmd.
patch &&
1789 echo tocmd--sbd
>>tocmd.
patch &&
1791 --from="Example <nobody@example.com>" \
1792 --to-cmd=.
/tocmd-sed \
1793 --smtp-server="$(pwd)/fake.sendmail" \
1796 grep "^!someone@example\.org!$" commandline1
1799 test_expect_success $PREREQ 'cccmd works with aliases
' '
1800 clean_fake_sendmail
&&
1801 echo "alias sbd someone@example.org" >.mailrc
&&
1802 test_config sendemail.aliasesfile
".mailrc" &&
1803 test_config sendemail.aliasfiletype mailrc
&&
1804 git format-patch
--stdout -1 >cccmd.
patch &&
1805 echo cccmd--sbd
>>cccmd.
patch &&
1807 --from="Example <nobody@example.com>" \
1808 --cc-cmd=.
/cccmd-sed \
1809 --smtp-server="$(pwd)/fake.sendmail" \
1812 grep "^!someone@example\.org!$" commandline1
1815 do_xmailer_test () {
1816 expected=$1 params=$2 &&
1817 git format-patch -1 &&
1819 --from="Example <nobody@example.com>" \
1820 --to=someone@example.com \
1821 --smtp-server="$(pwd)/fake.sendmail" \
1825 { grep '^X-Mailer
:' out || :; } >mailer &&
1826 test_line_count = $expected mailer
1829 test_expect_success $PREREQ '--[no-
]xmailer without any configuration
' '
1830 do_xmailer_test
1 "--xmailer" &&
1831 do_xmailer_test
0 "--no-xmailer"
1834 test_expect_success $PREREQ '--[no-
]xmailer with sendemail.xmailer
=true
' '
1835 test_config sendemail.xmailer true
&&
1836 do_xmailer_test
1 "" &&
1837 do_xmailer_test
0 "--no-xmailer" &&
1838 do_xmailer_test
1 "--xmailer"
1841 test_expect_success $PREREQ '--[no-
]xmailer with sendemail.xmailer
=false
' '
1842 test_config sendemail.xmailer false
&&
1843 do_xmailer_test
0 "" &&
1844 do_xmailer_test
0 "--no-xmailer" &&
1845 do_xmailer_test
1 "--xmailer"
1848 test_expect_success $PREREQ 'setup expected-list
' '
1851 --from="Example <from@example.com>" \
1852 --to="To 1 <to1@example.com>" \
1853 --to="to2@example.com" \
1854 --to="to3@example.com" \
1855 --cc="Cc 1 <cc1@example.com>" \
1856 --cc="Cc2 <cc2@example.com>" \
1857 --bcc="bcc1@example.com" \
1858 --bcc="bcc2@example.com" \
1859 0001-add-master.
patch | replace_variable_fields \
1863 test_expect_success $PREREQ 'use email list
in --cc --to and
--bcc' '
1866 --from="Example <from@example.com>" \
1867 --to="To 1 <to1@example.com>, to2@example.com" \
1868 --to="to3@example.com" \
1869 --cc="Cc 1 <cc1@example.com>, Cc2 <cc2@example.com>" \
1870 --bcc="bcc1@example.com, bcc2@example.com" \
1871 0001-add-master.
patch | replace_variable_fields \
1873 test_cmp expected-list actual-list
1876 test_expect_success $PREREQ 'aliases work with email list
' '
1877 echo "alias to2 to2@example.com" >.mutt
&&
1878 echo "alias cc1 Cc 1 <cc1@example.com>" >>.mutt
&&
1879 test_config sendemail.aliasesfile
".mutt" &&
1880 test_config sendemail.aliasfiletype mutt
&&
1883 --from="Example <from@example.com>" \
1884 --to="To 1 <to1@example.com>, to2, to3@example.com" \
1885 --cc="cc1, Cc2 <cc2@example.com>" \
1886 --bcc="bcc1@example.com, bcc2@example.com" \
1887 0001-add-master.
patch | replace_variable_fields \
1889 test_cmp expected-list actual-list
1892 test_expect_success $PREREQ 'leading and trailing whitespaces are removed
' '
1893 echo "alias to2 to2@example.com" >.mutt
&&
1894 echo "alias cc1 Cc 1 <cc1@example.com>" >>.mutt
&&
1895 test_config sendemail.aliasesfile
".mutt" &&
1896 test_config sendemail.aliasfiletype mutt
&&
1897 TO1
=$
(echo "QTo 1 <to1@example.com>" | q_to_tab
) &&
1898 TO2
=$
(echo "QZto2" | qz_to_tab_space
) &&
1899 CC1
=$
(echo "cc1" | append_cr
) &&
1900 BCC1
=$
(echo "Q bcc1@example.com Q" | q_to_nul
) &&
1903 --from=" Example <from@example.com>" \
1906 --to=" to3@example.com " \
1908 --cc="Cc2 <cc2@example.com>" \
1910 --bcc="bcc2@example.com" \
1911 0001-add-master.
patch | replace_variable_fields \
1913 test_cmp expected-list actual-list