3 test_description
='git send-email'
6 # May be altered later in the test
9 replace_variable_fields
() {
10 sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
11 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
12 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/"
15 test_expect_success
$PREREQ 'prepare reference tree' '
16 echo "1A quick brown fox jumps over the" >file &&
17 echo "lazy dog" >>file &&
19 GIT_AUTHOR_NAME="A" git commit -a -m "Initial."
22 test_expect_success
$PREREQ 'Setup helper tool' '
23 write_script fake.sendmail <<-\EOF &&
26 while test -f commandline$output
33 done >commandline$output
36 git add fake.sendmail &&
37 GIT_AUTHOR_NAME="A" git commit -a -m "Second."
40 clean_fake_sendmail
() {
41 rm -f commandline
* msgtxt
*
44 test_expect_success
$PREREQ 'Extract patches' '
45 patches=$(git format-patch -s --cc="One <one@example.com>" --cc=two@example.com -n HEAD^1) &&
46 threaded_patches=$(git format-patch -o threaded -s --in-reply-to="format" HEAD^1)
49 # Test no confirm early to ensure remaining tests will not hang
53 GIT_SEND_EMAIL_NOTTY
=1 \
55 --from="Example <from@example.com>" \
56 --to=nobody@example.com \
57 --smtp-server="$(pwd)/fake.sendmail" \
60 ! grep "Send this email" stdout
&&
64 # Exit immediately to prevent hang if a no-confirm test fails
66 if ! test -f no_confirm_okay
68 say
'confirm test failed; skipping remaining tests to prevent hanging'
69 PREREQ
="$PREREQ,CHECK_NO_CONFIRM"
74 test_expect_success
$PREREQ 'No confirm with --suppress-cc' '
75 test_no_confirm --suppress-cc=sob &&
80 test_expect_success
$PREREQ 'No confirm with --confirm=never' '
81 test_no_confirm --confirm=never &&
85 # leave sendemail.confirm set to never after this so that none of the
86 # remaining tests prompt unintentionally.
87 test_expect_success
$PREREQ 'No confirm with sendemail.confirm=never' '
88 git config sendemail.confirm never &&
89 test_no_confirm --compose --subject=foo &&
93 test_expect_success
$PREREQ 'Send patches' '
94 git send-email --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors
97 test_expect_success
$PREREQ 'setup expect' '
106 test_expect_success
$PREREQ 'Verify commandline' '
107 test_cmp expected commandline1
110 test_expect_success
$PREREQ 'Send patches with --envelope-sender' '
111 clean_fake_sendmail &&
112 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
115 test_expect_success
$PREREQ 'setup expect' '
116 cat >expected <<-\EOF
126 test_expect_success
$PREREQ 'Verify commandline' '
127 test_cmp expected commandline1
130 test_expect_success
$PREREQ 'Send patches with --envelope-sender=auto' '
131 clean_fake_sendmail &&
132 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
135 test_expect_success
$PREREQ 'setup expect' '
136 cat >expected <<-\EOF
146 test_expect_success
$PREREQ 'Verify commandline' '
147 test_cmp expected commandline1
150 test_expect_success
$PREREQ 'setup expect for cc trailer' "
151 cat >expected-cc <<\EOF
152 !recipient@example.com!
163 test_expect_success
$PREREQ 'cc trailer with various syntax' '
164 test_commit cc-trailer &&
165 test_when_finished "git reset --hard HEAD^" &&
166 git commit --amend -F - <<-EOF &&
170 Cc: <two@example.com> # trailing comments are ignored
171 Cc: <three@example.com>, <not.four@example.com> one address per line
172 Cc: "Some # Body" <four@example.com> [ <also.a.comment> ]
173 Cc: five@example.com # not.six@example.com
174 Cc: six@example.com, not.seven@example.com
176 clean_fake_sendmail &&
177 git send-email -1 --to=recipient@example.com \
178 --smtp-server="$(pwd)/fake.sendmail" &&
179 test_cmp expected-cc commandline1
182 test_expect_success
$PREREQ 'setup fake get_maintainer.pl script for cc trailer' "
183 write_script expected-cc-script.sh <<-EOF
184 echo 'One Person <one@example.com> (supporter:THIS (FOO/bar))'
185 echo 'Two Person <two@example.com> (maintainer:THIS THING)'
186 echo 'Third List <three@example.com> (moderated list:THIS THING (FOO/bar))'
187 echo '<four@example.com> (moderated list:FOR THING)'
188 echo 'five@example.com (open list:FOR THING (FOO/bar))'
189 echo 'six@example.com (open list)'
193 test_expect_success
$PREREQ 'cc trailer with get_maintainer.pl output' '
194 clean_fake_sendmail &&
195 git send-email -1 --to=recipient@example.com \
196 --cc-cmd=./expected-cc-script.sh \
197 --smtp-server="$(pwd)/fake.sendmail" &&
198 test_cmp expected-cc commandline1
201 test_expect_success
$PREREQ 'setup expect' "
202 cat >expected-show-all-headers <<\EOF
204 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
205 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
206 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
208 Server: relay.example.com
209 MAIL FROM:<from@example.com>
210 RCPT TO:<to@example.com>
211 RCPT TO:<cc@example.com>
212 RCPT TO:<author@example.com>
213 RCPT TO:<one@example.com>
214 RCPT TO:<two@example.com>
215 RCPT TO:<bcc@example.com>
216 From: Example <from@example.com>
219 A <author@example.com>,
220 One <one@example.com>,
222 Subject: [PATCH 1/1] Second.
224 Message-Id: MESSAGE-ID-STRING
225 X-Mailer: X-MAILER-STRING
226 In-Reply-To: <unique-message-id@example.com>
227 References: <unique-message-id@example.com>
228 Reply-To: Reply <reply@example.com>
230 Content-Transfer-Encoding: 8bit
236 test_suppress_self
() {
238 test_when_finished
"git reset --hard HEAD^" &&
240 write_script cccmd-sed
<<-EOF &&
241 sed -n -e s/^cccmd--//p "\$1"
244 git commit
--amend --author="$1 <$2>" -F - &&
245 clean_fake_sendmail
&&
246 git format-patch
--stdout -1 >"suppress-self-$3.patch" &&
248 git send-email
--from="$1 <$2>" \
249 --to=nobody@example.com \
250 --cc-cmd=.
/cccmd-sed \
252 --smtp-server="$(pwd)/fake.sendmail" \
253 suppress-self-
$3.
patch &&
255 mv msgtxt1 msgtxt1-
$3 &&
256 sed -e '/^$/q' msgtxt1-
$3 >"msghdr1-$3" &&
258 (grep '^Cc:' msghdr1-
$3 >"actual-no-cc-$3";
259 test_must_be_empty actual-no-cc-
$3)
262 test_suppress_self_unquoted
() {
263 test_suppress_self
"$1" "$2" "unquoted-$3" <<-EOF
264 test suppress-cc.self unquoted-$3 with name $1 email $2
271 Signed-off-by: $1 <$2>
275 test_suppress_self_quoted
() {
276 test_suppress_self
"$1" "$2" "quoted-$3" <<-EOF
277 test suppress-cc.self quoted-$3 with name $1 email $2
285 Signed-off-by: $1 <$2>
286 Signed-off-by: "$1" <$2>
290 test_expect_success
$PREREQ 'self name is suppressed' "
291 test_suppress_self_unquoted 'A U Thor' 'author@example.com' \
292 'self_name_suppressed'
295 test_expect_success
$PREREQ 'self name with dot is suppressed' "
296 test_suppress_self_quoted 'A U. Thor' 'author@example.com' \
297 'self_name_dot_suppressed'
300 test_expect_success
$PREREQ 'non-ascii self name is suppressed' "
301 test_suppress_self_quoted 'Füñný Nâmé' 'odd_?=mail@example.com' \
302 'non_ascii_self_suppressed'
305 # This name is long enough to force format-patch to split it into multiple
306 # encoded-words, assuming it uses UTF-8 with the "Q" encoding.
307 test_expect_success
$PREREQ 'long non-ascii self name is suppressed' "
308 test_suppress_self_quoted 'Ƒüñníęř €. Nâṁé' 'odd_?=mail@example.com' \
309 'long_non_ascii_self_suppressed'
312 test_expect_success
$PREREQ 'sanitized self name is suppressed' "
313 test_suppress_self_unquoted '\"A U. Thor\"' 'author@example.com' \
314 'self_name_sanitized_suppressed'
317 test_expect_success
$PREREQ 'Show all headers' '
321 --from="Example <from@example.com>" \
322 --reply-to="Reply <reply@example.com>" \
323 --to=to@example.com \
324 --cc=cc@example.com \
325 --bcc=bcc@example.com \
326 --in-reply-to="<unique-message-id@example.com>" \
327 --smtp-server relay.example.com \
328 $patches | replace_variable_fields \
329 >actual-show-all-headers &&
330 test_cmp expected-show-all-headers actual-show-all-headers
333 test_expect_success
$PREREQ 'Prompting works' '
334 clean_fake_sendmail &&
335 (echo "to@example.com" &&
337 ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
338 --smtp-server="$(pwd)/fake.sendmail" \
341 grep "^From: A U Thor <author@example.com>\$" msgtxt1 &&
342 grep "^To: to@example.com\$" msgtxt1
345 test_expect_success
$PREREQ,AUTOIDENT
'implicit ident is allowed' '
346 clean_fake_sendmail &&
347 (sane_unset GIT_AUTHOR_NAME &&
348 sane_unset GIT_AUTHOR_EMAIL &&
349 sane_unset GIT_COMMITTER_NAME &&
350 sane_unset GIT_COMMITTER_EMAIL &&
351 GIT_SEND_EMAIL_NOTTY=1 git send-email \
352 --smtp-server="$(pwd)/fake.sendmail" \
353 --to=to@example.com \
354 $patches </dev/null 2>errors
358 test_expect_success
$PREREQ,!AUTOIDENT
'broken implicit ident aborts send-email' '
359 clean_fake_sendmail &&
360 (sane_unset GIT_AUTHOR_NAME &&
361 sane_unset GIT_AUTHOR_EMAIL &&
362 sane_unset GIT_COMMITTER_NAME &&
363 sane_unset GIT_COMMITTER_EMAIL &&
364 GIT_SEND_EMAIL_NOTTY=1 && export GIT_SEND_EMAIL_NOTTY &&
365 test_must_fail git send-email \
366 --smtp-server="$(pwd)/fake.sendmail" \
367 --to=to@example.com \
368 $patches </dev/null 2>errors &&
369 test_i18ngrep "tell me who you are" errors
373 test_expect_success
$PREREQ 'setup tocmd and cccmd scripts' '
374 write_script tocmd-sed <<-\EOF &&
375 sed -n -e "s/^tocmd--//p" "$1"
377 write_script cccmd-sed <<-\EOF
378 sed -n -e "s/^cccmd--//p" "$1"
382 test_expect_success
$PREREQ 'tocmd works' '
383 clean_fake_sendmail &&
384 cp $patches tocmd.patch &&
385 echo tocmd--tocmd@example.com >>tocmd.patch &&
387 --from="Example <nobody@example.com>" \
388 --to-cmd=./tocmd-sed \
389 --smtp-server="$(pwd)/fake.sendmail" \
392 grep "^To: tocmd@example.com" msgtxt1
395 test_expect_success
$PREREQ 'cccmd works' '
396 clean_fake_sendmail &&
397 cp $patches cccmd.patch &&
398 echo "cccmd-- cccmd@example.com" >>cccmd.patch &&
400 --from="Example <nobody@example.com>" \
401 --to=nobody@example.com \
402 --cc-cmd=./cccmd-sed \
403 --smtp-server="$(pwd)/fake.sendmail" \
406 grep "^ cccmd@example.com" msgtxt1
409 test_expect_success
$PREREQ 'reject long lines' '
411 z64=$z8$z8$z8$z8$z8$z8$z8$z8 &&
412 z512=$z64$z64$z64$z64$z64$z64$z64$z64 &&
413 clean_fake_sendmail &&
414 cp $patches longline.patch &&
415 echo $z512$z512 >>longline.patch &&
416 test_must_fail git send-email \
417 --from="Example <nobody@example.com>" \
418 --to=nobody@example.com \
419 --smtp-server="$(pwd)/fake.sendmail" \
420 --transfer-encoding=8bit \
421 $patches longline.patch \
423 grep longline.patch errors
426 test_expect_success
$PREREQ 'no patch was sent' '
427 ! test -e commandline1
430 test_expect_success
$PREREQ 'Author From: in message body' '
431 clean_fake_sendmail &&
433 --from="Example <nobody@example.com>" \
434 --to=nobody@example.com \
435 --smtp-server="$(pwd)/fake.sendmail" \
437 sed "1,/^\$/d" <msgtxt1 >msgbody1 &&
438 grep "From: A <author@example.com>" msgbody1
441 test_expect_success
$PREREQ 'Author From: not in message body' '
442 clean_fake_sendmail &&
444 --from="A <author@example.com>" \
445 --to=nobody@example.com \
446 --smtp-server="$(pwd)/fake.sendmail" \
448 sed "1,/^\$/d" <msgtxt1 >msgbody1 &&
449 ! grep "From: A <author@example.com>" msgbody1
452 test_expect_success
$PREREQ 'allow long lines with --no-validate' '
454 --from="Example <nobody@example.com>" \
455 --to=nobody@example.com \
456 --smtp-server="$(pwd)/fake.sendmail" \
458 $patches longline.patch \
462 test_expect_success
$PREREQ 'short lines with auto encoding are 8bit' '
463 clean_fake_sendmail &&
465 --from="A <author@example.com>" \
466 --to=nobody@example.com \
467 --smtp-server="$(pwd)/fake.sendmail" \
468 --transfer-encoding=auto \
470 grep "Content-Transfer-Encoding: 8bit" msgtxt1
473 test_expect_success
$PREREQ 'long lines with auto encoding are quoted-printable' '
474 clean_fake_sendmail &&
476 --from="Example <nobody@example.com>" \
477 --to=nobody@example.com \
478 --smtp-server="$(pwd)/fake.sendmail" \
479 --transfer-encoding=auto \
482 grep "Content-Transfer-Encoding: quoted-printable" msgtxt1
485 test_expect_success
$PREREQ 'carriage returns with auto encoding are quoted-printable' '
486 clean_fake_sendmail &&
487 cp $patches cr.patch &&
488 printf "this is a line\r\n" >>cr.patch &&
490 --from="Example <nobody@example.com>" \
491 --to=nobody@example.com \
492 --smtp-server="$(pwd)/fake.sendmail" \
493 --transfer-encoding=auto \
496 grep "Content-Transfer-Encoding: quoted-printable" msgtxt1
499 for enc
in auto quoted-printable base64
501 test_expect_success
$PREREQ "--validate passes with encoding $enc" '
503 --from="Example <nobody@example.com>" \
504 --to=nobody@example.com \
505 --smtp-server="$(pwd)/fake.sendmail" \
506 --transfer-encoding=$enc \
508 $patches longline.patch
513 for enc
in 7bit
8bit quoted-printable base64
515 test_expect_success
$PREREQ "--transfer-encoding=$enc produces correct header" '
516 clean_fake_sendmail &&
518 --from="Example <nobody@example.com>" \
519 --to=nobody@example.com \
520 --smtp-server="$(pwd)/fake.sendmail" \
521 --transfer-encoding=$enc \
523 grep "Content-Transfer-Encoding: $enc" msgtxt1
527 test_expect_success
$PREREQ 'Invalid In-Reply-To' '
528 clean_fake_sendmail &&
530 --from="Example <nobody@example.com>" \
531 --to=nobody@example.com \
533 --smtp-server="$(pwd)/fake.sendmail" \
536 ! grep "^In-Reply-To: < *>" msgtxt1
539 test_expect_success
$PREREQ 'Valid In-Reply-To when prompting' '
540 clean_fake_sendmail &&
541 (echo "From Example <from@example.com>" &&
542 echo "To Example <to@example.com>" &&
544 ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
545 --smtp-server="$(pwd)/fake.sendmail" \
547 ! grep "^In-Reply-To: < *>" msgtxt1
550 test_expect_success
$PREREQ 'In-Reply-To without --chain-reply-to' '
551 clean_fake_sendmail &&
552 echo "<unique-message-id@example.com>" >expect &&
554 --from="Example <nobody@example.com>" \
555 --to=nobody@example.com \
556 --no-chain-reply-to \
557 --in-reply-to="$(cat expect)" \
558 --smtp-server="$(pwd)/fake.sendmail" \
559 $patches $patches $patches \
561 # The first message is a reply to --in-reply-to
562 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual &&
563 test_cmp expect actual &&
564 # Second and subsequent messages are replies to the first one
565 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect &&
566 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual &&
567 test_cmp expect actual &&
568 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual &&
569 test_cmp expect actual
572 test_expect_success
$PREREQ 'In-Reply-To with --chain-reply-to' '
573 clean_fake_sendmail &&
574 echo "<unique-message-id@example.com>" >expect &&
576 --from="Example <nobody@example.com>" \
577 --to=nobody@example.com \
579 --in-reply-to="$(cat expect)" \
580 --smtp-server="$(pwd)/fake.sendmail" \
581 $patches $patches $patches \
583 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual &&
584 test_cmp expect actual &&
585 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect &&
586 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual &&
587 test_cmp expect actual &&
588 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt2 >expect &&
589 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual &&
590 test_cmp expect actual
593 test_expect_success
$PREREQ 'setup fake editor' '
594 write_script fake-editor <<-\EOF
595 echo fake edit >>"$1"
599 test_set_editor
"$(pwd)/fake-editor"
601 test_expect_success
$PREREQ '--compose works' '
602 clean_fake_sendmail &&
604 --compose --subject foo \
605 --from="Example <nobody@example.com>" \
606 --to=nobody@example.com \
607 --smtp-server="$(pwd)/fake.sendmail" \
612 test_expect_success
$PREREQ 'first message is compose text' '
613 grep "^fake edit" msgtxt1
616 test_expect_success
$PREREQ 'second message is patch' '
617 grep "Subject:.*Second" msgtxt2
620 test_expect_success
$PREREQ 'setup expect' "
621 cat >expected-suppress-sob <<\EOF
623 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
624 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
625 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
627 Server: relay.example.com
628 MAIL FROM:<from@example.com>
629 RCPT TO:<to@example.com>
630 RCPT TO:<cc@example.com>
631 RCPT TO:<author@example.com>
632 RCPT TO:<one@example.com>
633 RCPT TO:<two@example.com>
634 From: Example <from@example.com>
637 A <author@example.com>,
638 One <one@example.com>,
640 Subject: [PATCH 1/1] Second.
642 Message-Id: MESSAGE-ID-STRING
643 X-Mailer: X-MAILER-STRING
645 Content-Transfer-Encoding: 8bit
651 test_suppression
() {
654 --suppress-cc=$1 ${2+"--suppress-cc=$2"} \
655 --from="Example <from@example.com>" \
656 --to=to@example.com \
657 --smtp-server relay.example.com \
658 $patches | replace_variable_fields \
659 >actual-suppress-
$1${2+"-$2"} &&
660 test_cmp expected-suppress-
$1${2+"-$2"} actual-suppress-
$1${2+"-$2"}
663 test_expect_success
$PREREQ 'sendemail.cc set' '
664 git config sendemail.cc cc@example.com &&
668 test_expect_success
$PREREQ 'setup expect' "
669 cat >expected-suppress-sob <<\EOF
671 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
672 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
673 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
675 Server: relay.example.com
676 MAIL FROM:<from@example.com>
677 RCPT TO:<to@example.com>
678 RCPT TO:<author@example.com>
679 RCPT TO:<one@example.com>
680 RCPT TO:<two@example.com>
681 From: Example <from@example.com>
683 Cc: A <author@example.com>,
684 One <one@example.com>,
686 Subject: [PATCH 1/1] Second.
688 Message-Id: MESSAGE-ID-STRING
689 X-Mailer: X-MAILER-STRING
691 Content-Transfer-Encoding: 8bit
697 test_expect_success
$PREREQ 'sendemail.cc unset' '
698 git config --unset sendemail.cc &&
702 test_expect_success
$PREREQ 'setup expect' "
703 cat >expected-suppress-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'
708 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
710 Server: relay.example.com
711 MAIL FROM:<from@example.com>
712 RCPT TO:<to@example.com>
713 RCPT TO:<author@example.com>
714 RCPT TO:<one@example.com>
715 RCPT TO:<two@example.com>
716 RCPT TO:<committer@example.com>
717 From: Example <from@example.com>
719 Cc: A <author@example.com>,
720 One <one@example.com>,
722 C O Mitter <committer@example.com>
723 Subject: [PATCH 1/1] Second.
725 Message-Id: MESSAGE-ID-STRING
726 X-Mailer: X-MAILER-STRING
728 Content-Transfer-Encoding: 8bit
734 test_expect_success
$PREREQ 'sendemail.cccmd' '
735 write_script cccmd <<-\EOF &&
736 echo cc-cmd@example.com
738 git config sendemail.cccmd ./cccmd &&
739 test_suppression cccmd
742 test_expect_success
$PREREQ 'setup expect' '
743 cat >expected-suppress-all <<\EOF
746 Server: relay.example.com
747 MAIL FROM:<from@example.com>
748 RCPT TO:<to@example.com>
749 From: Example <from@example.com>
751 Subject: [PATCH 1/1] Second.
753 Message-Id: MESSAGE-ID-STRING
754 X-Mailer: X-MAILER-STRING
756 Content-Transfer-Encoding: 8bit
762 test_expect_success
$PREREQ '--suppress-cc=all' '
766 test_expect_success
$PREREQ 'setup expect' "
767 cat >expected-suppress-body <<\EOF
769 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
770 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
771 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
772 (cc-cmd) Adding cc: cc-cmd@example.com from: './cccmd'
774 Server: relay.example.com
775 MAIL FROM:<from@example.com>
776 RCPT TO:<to@example.com>
777 RCPT TO:<author@example.com>
778 RCPT TO:<one@example.com>
779 RCPT TO:<two@example.com>
780 RCPT TO:<cc-cmd@example.com>
781 From: Example <from@example.com>
783 Cc: A <author@example.com>,
784 One <one@example.com>,
787 Subject: [PATCH 1/1] Second.
789 Message-Id: MESSAGE-ID-STRING
790 X-Mailer: X-MAILER-STRING
792 Content-Transfer-Encoding: 8bit
798 test_expect_success
$PREREQ '--suppress-cc=body' '
799 test_suppression body
802 test_expect_success
$PREREQ 'setup expect' "
803 cat >expected-suppress-body-cccmd <<\EOF
805 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
806 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
807 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
809 Server: relay.example.com
810 MAIL FROM:<from@example.com>
811 RCPT TO:<to@example.com>
812 RCPT TO:<author@example.com>
813 RCPT TO:<one@example.com>
814 RCPT TO:<two@example.com>
815 From: Example <from@example.com>
817 Cc: A <author@example.com>,
818 One <one@example.com>,
820 Subject: [PATCH 1/1] Second.
822 Message-Id: MESSAGE-ID-STRING
823 X-Mailer: X-MAILER-STRING
825 Content-Transfer-Encoding: 8bit
831 test_expect_success
$PREREQ '--suppress-cc=body --suppress-cc=cccmd' '
832 test_suppression body cccmd
835 test_expect_success
$PREREQ 'setup expect' "
836 cat >expected-suppress-sob <<\EOF
838 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
839 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
840 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
842 Server: relay.example.com
843 MAIL FROM:<from@example.com>
844 RCPT TO:<to@example.com>
845 RCPT TO:<author@example.com>
846 RCPT TO:<one@example.com>
847 RCPT TO:<two@example.com>
848 From: Example <from@example.com>
850 Cc: A <author@example.com>,
851 One <one@example.com>,
853 Subject: [PATCH 1/1] Second.
855 Message-Id: MESSAGE-ID-STRING
856 X-Mailer: X-MAILER-STRING
858 Content-Transfer-Encoding: 8bit
864 test_expect_success
$PREREQ '--suppress-cc=sob' '
865 test_might_fail git config --unset sendemail.cccmd &&
869 test_expect_success
$PREREQ 'setup expect' "
870 cat >expected-suppress-bodycc <<\EOF
872 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
873 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
874 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
875 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
877 Server: relay.example.com
878 MAIL FROM:<from@example.com>
879 RCPT TO:<to@example.com>
880 RCPT TO:<author@example.com>
881 RCPT TO:<one@example.com>
882 RCPT TO:<two@example.com>
883 RCPT TO:<committer@example.com>
884 From: Example <from@example.com>
886 Cc: A <author@example.com>,
887 One <one@example.com>,
889 C O Mitter <committer@example.com>
890 Subject: [PATCH 1/1] Second.
892 Message-Id: MESSAGE-ID-STRING
893 X-Mailer: X-MAILER-STRING
895 Content-Transfer-Encoding: 8bit
901 test_expect_success
$PREREQ '--suppress-cc=bodycc' '
902 test_suppression bodycc
905 test_expect_success
$PREREQ 'setup expect' "
906 cat >expected-suppress-cc <<\EOF
908 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
909 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
911 Server: relay.example.com
912 MAIL FROM:<from@example.com>
913 RCPT TO:<to@example.com>
914 RCPT TO:<author@example.com>
915 RCPT TO:<committer@example.com>
916 From: Example <from@example.com>
918 Cc: A <author@example.com>,
919 C O Mitter <committer@example.com>
920 Subject: [PATCH 1/1] Second.
922 Message-Id: MESSAGE-ID-STRING
923 X-Mailer: X-MAILER-STRING
925 Content-Transfer-Encoding: 8bit
931 test_expect_success
$PREREQ '--suppress-cc=cc' '
937 GIT_SEND_EMAIL_NOTTY
=1 \
939 --from="Example <nobody@example.com>" \
940 --to=nobody@example.com \
941 --smtp-server="$(pwd)/fake.sendmail" \
942 $@
$patches >stdout
&&
943 grep "Send this email" stdout
946 test_expect_success
$PREREQ '--confirm=always' '
947 test_confirm --confirm=always --suppress-cc=all
950 test_expect_success
$PREREQ '--confirm=auto' '
951 test_confirm --confirm=auto
954 test_expect_success
$PREREQ '--confirm=cc' '
955 test_confirm --confirm=cc
958 test_expect_success
$PREREQ '--confirm=compose' '
959 test_confirm --confirm=compose --compose
962 test_expect_success
$PREREQ 'confirm by default (due to cc)' '
963 test_when_finished git config sendemail.confirm never &&
964 git config --unset sendemail.confirm &&
968 test_expect_success
$PREREQ 'confirm by default (due to --compose)' '
969 test_when_finished git config sendemail.confirm never &&
970 git config --unset sendemail.confirm &&
971 test_confirm --suppress-cc=all --compose
974 test_expect_success
$PREREQ 'confirm detects EOF (inform assumes y)' '
975 test_when_finished git config sendemail.confirm never &&
976 git config --unset sendemail.confirm &&
978 git format-patch -2 -o outdir &&
979 GIT_SEND_EMAIL_NOTTY=1 \
981 --from="Example <nobody@example.com>" \
982 --to=nobody@example.com \
983 --smtp-server="$(pwd)/fake.sendmail" \
984 outdir/*.patch </dev/null
987 test_expect_success
$PREREQ 'confirm detects EOF (auto causes failure)' '
988 test_when_finished git config sendemail.confirm never &&
989 git config sendemail.confirm auto &&
990 GIT_SEND_EMAIL_NOTTY=1 &&
991 export GIT_SEND_EMAIL_NOTTY &&
992 test_must_fail git send-email \
993 --from="Example <nobody@example.com>" \
994 --to=nobody@example.com \
995 --smtp-server="$(pwd)/fake.sendmail" \
999 test_expect_success
$PREREQ 'confirm does not loop forever' '
1000 test_when_finished git config sendemail.confirm never &&
1001 git config sendemail.confirm auto &&
1002 GIT_SEND_EMAIL_NOTTY=1 &&
1003 export GIT_SEND_EMAIL_NOTTY &&
1004 yes "bogus" | test_must_fail git send-email \
1005 --from="Example <nobody@example.com>" \
1006 --to=nobody@example.com \
1007 --smtp-server="$(pwd)/fake.sendmail" \
1011 test_expect_success
$PREREQ 'utf8 Cc is rfc2047 encoded' '
1012 clean_fake_sendmail &&
1014 git format-patch -1 -o outdir --cc="àéìöú <utf8@example.com>" &&
1016 --from="Example <nobody@example.com>" \
1017 --to=nobody@example.com \
1018 --smtp-server="$(pwd)/fake.sendmail" \
1021 grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>"
1024 test_expect_success
$PREREQ '--compose adds MIME for utf8 body' '
1025 clean_fake_sendmail &&
1026 write_script fake-editor-utf8 <<-\EOF &&
1027 echo "utf8 body: àéìöú" >>"$1"
1029 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
1031 --compose --subject foo \
1032 --from="Example <nobody@example.com>" \
1033 --to=nobody@example.com \
1034 --smtp-server="$(pwd)/fake.sendmail" \
1036 grep "^utf8 body" msgtxt1 &&
1037 grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
1040 test_expect_success
$PREREQ '--compose respects user mime type' '
1041 clean_fake_sendmail &&
1042 write_script fake-editor-utf8-mime <<-\EOF &&
1045 Content-Type: text/plain; charset=iso-8859-1
1046 Content-Transfer-Encoding: 8bit
1052 GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \
1054 --compose --subject foo \
1055 --from="Example <nobody@example.com>" \
1056 --to=nobody@example.com \
1057 --smtp-server="$(pwd)/fake.sendmail" \
1059 grep "^utf8 body" msgtxt1 &&
1060 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 &&
1061 ! grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
1064 test_expect_success
$PREREQ '--compose adds MIME for utf8 subject' '
1065 clean_fake_sendmail &&
1066 GIT_EDITOR="\"$(pwd)/fake-editor\"" \
1068 --compose --subject utf8-sübjëct \
1069 --from="Example <nobody@example.com>" \
1070 --to=nobody@example.com \
1071 --smtp-server="$(pwd)/fake.sendmail" \
1073 grep "^fake edit" msgtxt1 &&
1074 grep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
1077 test_expect_success
$PREREQ 'utf8 author is correctly passed on' '
1078 clean_fake_sendmail &&
1079 test_commit weird_author &&
1080 test_when_finished "git reset --hard HEAD^" &&
1081 git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" &&
1082 git format-patch --stdout -1 >funny_name.patch &&
1083 git send-email --from="Example <nobody@example.com>" \
1084 --to=nobody@example.com \
1085 --smtp-server="$(pwd)/fake.sendmail" \
1087 grep "^From: Füñný Nâmé <odd_?=mail@example.com>" msgtxt1
1090 test_expect_success
$PREREQ 'utf8 sender is not duplicated' '
1091 clean_fake_sendmail &&
1092 test_commit weird_sender &&
1093 test_when_finished "git reset --hard HEAD^" &&
1094 git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" &&
1095 git format-patch --stdout -1 >funny_name.patch &&
1096 git send-email --from="Füñný Nâmé <odd_?=mail@example.com>" \
1097 --to=nobody@example.com \
1098 --smtp-server="$(pwd)/fake.sendmail" \
1100 grep "^From: " msgtxt1 >msgfrom &&
1101 test_line_count = 1 msgfrom
1104 test_expect_success
$PREREQ 'sendemail.composeencoding works' '
1105 clean_fake_sendmail &&
1106 git config sendemail.composeencoding iso-8859-1 &&
1107 write_script fake-editor-utf8 <<-\EOF &&
1108 echo "utf8 body: àéìöú" >>"$1"
1110 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
1112 --compose --subject foo \
1113 --from="Example <nobody@example.com>" \
1114 --to=nobody@example.com \
1115 --smtp-server="$(pwd)/fake.sendmail" \
1117 grep "^utf8 body" msgtxt1 &&
1118 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1
1121 test_expect_success
$PREREQ '--compose-encoding works' '
1122 clean_fake_sendmail &&
1123 write_script fake-editor-utf8 <<-\EOF &&
1124 echo "utf8 body: àéìöú" >>"$1"
1126 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
1128 --compose-encoding iso-8859-1 \
1129 --compose --subject foo \
1130 --from="Example <nobody@example.com>" \
1131 --to=nobody@example.com \
1132 --smtp-server="$(pwd)/fake.sendmail" \
1134 grep "^utf8 body" msgtxt1 &&
1135 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1
1138 test_expect_success
$PREREQ '--compose-encoding overrides sendemail.composeencoding' '
1139 clean_fake_sendmail &&
1140 git config sendemail.composeencoding iso-8859-1 &&
1141 write_script fake-editor-utf8 <<-\EOF &&
1142 echo "utf8 body: àéìöú" >>"$1"
1144 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
1146 --compose-encoding iso-8859-2 \
1147 --compose --subject foo \
1148 --from="Example <nobody@example.com>" \
1149 --to=nobody@example.com \
1150 --smtp-server="$(pwd)/fake.sendmail" \
1152 grep "^utf8 body" msgtxt1 &&
1153 grep "^Content-Type: text/plain; charset=iso-8859-2" msgtxt1
1156 test_expect_success
$PREREQ '--compose-encoding adds correct MIME for subject' '
1157 clean_fake_sendmail &&
1158 GIT_EDITOR="\"$(pwd)/fake-editor\"" \
1160 --compose-encoding iso-8859-2 \
1161 --compose --subject utf8-sübjëct \
1162 --from="Example <nobody@example.com>" \
1163 --to=nobody@example.com \
1164 --smtp-server="$(pwd)/fake.sendmail" \
1166 grep "^fake edit" msgtxt1 &&
1167 grep "^Subject: =?iso-8859-2?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
1170 test_expect_success
$PREREQ 'detects ambiguous reference/file conflict' '
1171 echo master >master &&
1173 git commit -m"add master" &&
1174 test_must_fail git send-email --dry-run master 2>errors &&
1175 grep disambiguate errors
1178 test_expect_success
$PREREQ 'feed two files' '
1180 git format-patch -2 -o outdir &&
1183 --from="Example <nobody@example.com>" \
1184 --to=nobody@example.com \
1185 outdir/000?-*.patch 2>errors >out &&
1186 grep "^Subject: " out >subjects &&
1187 test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." &&
1188 test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add master"
1191 test_expect_success
$PREREQ 'in-reply-to but no threading' '
1194 --from="Example <nobody@example.com>" \
1195 --to=nobody@example.com \
1196 --in-reply-to="<in-reply-id@example.com>" \
1199 grep "In-Reply-To: <in-reply-id@example.com>" out
1202 test_expect_success
$PREREQ 'no in-reply-to and no threading' '
1205 --from="Example <nobody@example.com>" \
1206 --to=nobody@example.com \
1209 ! grep "In-Reply-To: " stdout
1212 test_expect_success
$PREREQ 'threading but no chain-reply-to' '
1215 --from="Example <nobody@example.com>" \
1216 --to=nobody@example.com \
1218 --no-chain-reply-to \
1219 $patches $patches >stdout &&
1220 grep "In-Reply-To: " stdout
1223 test_expect_success
$PREREQ 'override in-reply-to if no threading' '
1226 --from="Example <nobody@example.com>" \
1227 --to=nobody@example.com \
1229 --in-reply-to="override" \
1230 $threaded_patches >stdout &&
1231 grep "In-Reply-To: <override>" stdout
1234 test_expect_success
$PREREQ 'sendemail.to works' '
1235 git config --replace-all sendemail.to "Somebody <somebody@ex.com>" &&
1238 --from="Example <nobody@example.com>" \
1240 grep "To: Somebody <somebody@ex.com>" stdout
1243 test_expect_success
$PREREQ 'setup sendemail.identity' '
1244 git config --replace-all sendemail.to "default@example.com" &&
1245 git config --replace-all sendemail.isp.to "isp@example.com" &&
1246 git config --replace-all sendemail.cloud.to "cloud@example.com"
1249 test_expect_success
$PREREQ 'sendemail.identity: reads the correct identity config' '
1250 git -c sendemail.identity=cloud send-email \
1252 --from="nobody@example.com" \
1254 grep "To: cloud@example.com" stdout
1257 test_expect_success
$PREREQ 'sendemail.identity: identity overrides sendemail.identity' '
1258 git -c sendemail.identity=cloud send-email \
1261 --from="nobody@example.com" \
1263 grep "To: isp@example.com" stdout
1266 test_expect_success
$PREREQ 'sendemail.identity: --no-identity clears previous identity' '
1267 git -c sendemail.identity=cloud send-email \
1270 --from="nobody@example.com" \
1272 grep "To: default@example.com" stdout
1275 test_expect_success
$PREREQ 'sendemail.identity: bool identity variable existence overrides' '
1276 git -c sendemail.identity=cloud \
1277 -c sendemail.xmailer=true \
1278 -c sendemail.cloud.xmailer=false \
1281 --from="nobody@example.com" \
1283 grep "To: cloud@example.com" stdout &&
1284 ! grep "X-Mailer" stdout
1287 test_expect_success
$PREREQ 'sendemail.identity: bool variable fallback' '
1288 git -c sendemail.identity=cloud \
1289 -c sendemail.xmailer=false \
1292 --from="nobody@example.com" \
1294 grep "To: cloud@example.com" stdout &&
1295 ! grep "X-Mailer" stdout
1298 test_expect_success
$PREREQ '--no-to overrides sendemail.to' '
1301 --from="Example <nobody@example.com>" \
1303 --to=nobody@example.com \
1305 grep "To: nobody@example.com" stdout &&
1306 ! grep "To: Somebody <somebody@ex.com>" stdout
1309 test_expect_success
$PREREQ 'sendemail.cc works' '
1310 git config --replace-all sendemail.cc "Somebody <somebody@ex.com>" &&
1313 --from="Example <nobody@example.com>" \
1314 --to=nobody@example.com \
1316 grep "Cc: Somebody <somebody@ex.com>" stdout
1319 test_expect_success
$PREREQ '--no-cc overrides sendemail.cc' '
1322 --from="Example <nobody@example.com>" \
1324 --cc=bodies@example.com \
1325 --to=nobody@example.com \
1327 grep "Cc: bodies@example.com" stdout &&
1328 ! grep "Cc: Somebody <somebody@ex.com>" stdout
1331 test_expect_success
$PREREQ 'sendemail.bcc works' '
1332 git config --replace-all sendemail.bcc "Other <other@ex.com>" &&
1335 --from="Example <nobody@example.com>" \
1336 --to=nobody@example.com \
1337 --smtp-server relay.example.com \
1339 grep "RCPT TO:<other@ex.com>" stdout
1342 test_expect_success
$PREREQ '--no-bcc overrides sendemail.bcc' '
1345 --from="Example <nobody@example.com>" \
1347 --bcc=bodies@example.com \
1348 --to=nobody@example.com \
1349 --smtp-server relay.example.com \
1351 grep "RCPT TO:<bodies@example.com>" stdout &&
1352 ! grep "RCPT TO:<other@ex.com>" stdout
1355 test_expect_success
$PREREQ 'patches To headers are used by default' '
1356 patch=$(git format-patch -1 --to="bodies@example.com") &&
1357 test_when_finished "rm $patch" &&
1360 --from="Example <nobody@example.com>" \
1361 --smtp-server relay.example.com \
1363 grep "RCPT TO:<bodies@example.com>" stdout
1366 test_expect_success
$PREREQ 'patches To headers are appended to' '
1367 patch=$(git format-patch -1 --to="bodies@example.com") &&
1368 test_when_finished "rm $patch" &&
1371 --from="Example <nobody@example.com>" \
1372 --to=nobody@example.com \
1373 --smtp-server relay.example.com \
1375 grep "RCPT TO:<bodies@example.com>" stdout &&
1376 grep "RCPT TO:<nobody@example.com>" stdout
1379 test_expect_success
$PREREQ 'To headers from files reset each patch' '
1380 patch1=$(git format-patch -1 --to="bodies@example.com") &&
1381 patch2=$(git format-patch -1 --to="other@example.com" HEAD~) &&
1382 test_when_finished "rm $patch1 && rm $patch2" &&
1385 --from="Example <nobody@example.com>" \
1386 --to="nobody@example.com" \
1387 --smtp-server relay.example.com \
1388 $patch1 $patch2 >stdout &&
1389 test $(grep -c "RCPT TO:<bodies@example.com>" stdout) = 1 &&
1390 test $(grep -c "RCPT TO:<nobody@example.com>" stdout) = 2 &&
1391 test $(grep -c "RCPT TO:<other@example.com>" stdout) = 1
1394 test_expect_success
$PREREQ 'setup expect' '
1395 cat >email-using-8bit <<\EOF
1396 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1397 Message-Id: <bogus-message-id@example.com>
1398 From: author@example.com
1399 Date: Sat, 12 Jun 2010 15:53:58 +0200
1400 Subject: subject goes here
1402 Dieser deutsche Text enthält einen Umlaut!
1406 test_expect_success
$PREREQ 'setup expect' '
1407 echo "Subject: subject goes here" >expected
1410 test_expect_success
$PREREQ 'ASCII subject is not RFC2047 quoted' '
1411 clean_fake_sendmail &&
1413 git send-email --from=author@example.com --to=nobody@example.com \
1414 --smtp-server="$(pwd)/fake.sendmail" \
1415 --8bit-encoding=UTF-8 \
1416 email-using-8bit >stdout &&
1417 grep "Subject" msgtxt1 >actual &&
1418 test_cmp expected actual
1421 test_expect_success
$PREREQ 'setup expect' '
1422 cat >content-type-decl <<-\EOF
1424 Content-Type: text/plain; charset=UTF-8
1425 Content-Transfer-Encoding: 8bit
1429 test_expect_success
$PREREQ 'asks about and fixes 8bit encodings' '
1430 clean_fake_sendmail &&
1432 git send-email --from=author@example.com --to=nobody@example.com \
1433 --smtp-server="$(pwd)/fake.sendmail" \
1434 email-using-8bit >stdout &&
1435 grep "do not declare a Content-Transfer-Encoding" stdout &&
1436 grep email-using-8bit stdout &&
1437 grep "Which 8bit encoding" stdout &&
1438 egrep "Content|MIME" msgtxt1 >actual &&
1439 test_cmp content-type-decl actual
1442 test_expect_success
$PREREQ 'sendemail.8bitEncoding works' '
1443 clean_fake_sendmail &&
1444 git config sendemail.assume8bitEncoding UTF-8 &&
1446 git send-email --from=author@example.com --to=nobody@example.com \
1447 --smtp-server="$(pwd)/fake.sendmail" \
1448 email-using-8bit >stdout &&
1449 egrep "Content|MIME" msgtxt1 >actual &&
1450 test_cmp content-type-decl actual
1453 test_expect_success
$PREREQ '--8bit-encoding overrides sendemail.8bitEncoding' '
1454 clean_fake_sendmail &&
1455 git config sendemail.assume8bitEncoding "bogus too" &&
1457 git send-email --from=author@example.com --to=nobody@example.com \
1458 --smtp-server="$(pwd)/fake.sendmail" \
1459 --8bit-encoding=UTF-8 \
1460 email-using-8bit >stdout &&
1461 egrep "Content|MIME" msgtxt1 >actual &&
1462 test_cmp content-type-decl actual
1465 test_expect_success
$PREREQ 'setup expect' '
1466 cat >email-using-8bit <<-\EOF
1467 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1468 Message-Id: <bogus-message-id@example.com>
1469 From: author@example.com
1470 Date: Sat, 12 Jun 2010 15:53:58 +0200
1471 Subject: Dieser Betreff enthält auch einen Umlaut!
1473 Nothing to see here.
1477 test_expect_success
$PREREQ 'setup expect' '
1478 cat >expected <<-\EOF
1479 Subject: =?UTF-8?q?Dieser=20Betreff=20enth=C3=A4lt=20auch=20einen=20Umlaut!?=
1483 test_expect_success
$PREREQ '--8bit-encoding also treats subject' '
1484 clean_fake_sendmail &&
1486 git send-email --from=author@example.com --to=nobody@example.com \
1487 --smtp-server="$(pwd)/fake.sendmail" \
1488 --8bit-encoding=UTF-8 \
1489 email-using-8bit >stdout &&
1490 grep "Subject" msgtxt1 >actual &&
1491 test_cmp expected actual
1494 test_expect_success
$PREREQ 'setup expect' '
1495 cat >email-using-8bit <<-\EOF
1496 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1497 Message-Id: <bogus-message-id@example.com>
1498 From: A U Thor <author@example.com>
1499 Date: Sat, 12 Jun 2010 15:53:58 +0200
1500 Content-Type: text/plain; charset=UTF-8
1501 Subject: Nothing to see here.
1503 Dieser Betreff enthält auch einen Umlaut!
1507 test_expect_success
$PREREQ '--transfer-encoding overrides sendemail.transferEncoding' '
1508 clean_fake_sendmail &&
1509 test_must_fail git -c sendemail.transferEncoding=8bit \
1511 --transfer-encoding=7bit \
1512 --smtp-server="$(pwd)/fake.sendmail" \
1515 grep "cannot send message as 7bit" errors &&
1516 test -z "$(ls msgtxt*)"
1519 test_expect_success
$PREREQ 'sendemail.transferEncoding via config' '
1520 clean_fake_sendmail &&
1521 test_must_fail git -c sendemail.transferEncoding=7bit \
1523 --smtp-server="$(pwd)/fake.sendmail" \
1526 grep "cannot send message as 7bit" errors &&
1527 test -z "$(ls msgtxt*)"
1530 test_expect_success
$PREREQ 'sendemail.transferEncoding via cli' '
1531 clean_fake_sendmail &&
1532 test_must_fail git send-email \
1533 --transfer-encoding=7bit \
1534 --smtp-server="$(pwd)/fake.sendmail" \
1537 grep "cannot send message as 7bit" errors &&
1538 test -z "$(ls msgtxt*)"
1541 test_expect_success
$PREREQ 'setup expect' '
1542 cat >expected <<-\EOF
1543 Dieser Betreff enth=C3=A4lt auch einen Umlaut!
1547 test_expect_success
$PREREQ '8-bit and sendemail.transferencoding=quoted-printable' '
1548 clean_fake_sendmail &&
1550 --transfer-encoding=quoted-printable \
1551 --smtp-server="$(pwd)/fake.sendmail" \
1554 sed "1,/^$/d" msgtxt1 >actual &&
1555 test_cmp expected actual
1558 test_expect_success
$PREREQ 'setup expect' '
1559 cat >expected <<-\EOF
1560 RGllc2VyIEJldHJlZmYgZW50aMOkbHQgYXVjaCBlaW5lbiBVbWxhdXQhCg==
1564 test_expect_success
$PREREQ '8-bit and sendemail.transferencoding=base64' '
1565 clean_fake_sendmail &&
1567 --transfer-encoding=base64 \
1568 --smtp-server="$(pwd)/fake.sendmail" \
1571 sed "1,/^$/d" msgtxt1 >actual &&
1572 test_cmp expected actual
1575 test_expect_success
$PREREQ 'setup expect' '
1576 cat >email-using-qp <<-\EOF
1577 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1578 Message-Id: <bogus-message-id@example.com>
1579 From: A U Thor <author@example.com>
1580 Date: Sat, 12 Jun 2010 15:53:58 +0200
1582 Content-Transfer-Encoding: quoted-printable
1583 Content-Type: text/plain; charset=UTF-8
1584 Subject: Nothing to see here.
1586 Dieser Betreff enth=C3=A4lt auch einen Umlaut!
1590 test_expect_success
$PREREQ 'convert from quoted-printable to base64' '
1591 clean_fake_sendmail &&
1593 --transfer-encoding=base64 \
1594 --smtp-server="$(pwd)/fake.sendmail" \
1597 sed "1,/^$/d" msgtxt1 >actual &&
1598 test_cmp expected actual
1601 test_expect_success
$PREREQ 'setup expect' "
1602 tr -d '\\015' | tr '%' '\\015' >email-using-crlf <<EOF
1603 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1604 Message-Id: <bogus-message-id@example.com>
1605 From: A U Thor <author@example.com>
1606 Date: Sat, 12 Jun 2010 15:53:58 +0200
1607 Content-Type: text/plain; charset=UTF-8
1608 Subject: Nothing to see here.
1610 Look, I have a CRLF and an = sign!%
1614 test_expect_success
$PREREQ 'setup expect' '
1615 cat >expected <<-\EOF
1616 Look, I have a CRLF and an =3D sign!=0D
1620 test_expect_success
$PREREQ 'CRLF and sendemail.transferencoding=quoted-printable' '
1621 clean_fake_sendmail &&
1623 --transfer-encoding=quoted-printable \
1624 --smtp-server="$(pwd)/fake.sendmail" \
1627 sed "1,/^$/d" msgtxt1 >actual &&
1628 test_cmp expected actual
1631 test_expect_success
$PREREQ 'setup expect' '
1632 cat >expected <<-\EOF
1633 TG9vaywgSSBoYXZlIGEgQ1JMRiBhbmQgYW4gPSBzaWduIQ0K
1637 test_expect_success
$PREREQ 'CRLF and sendemail.transferencoding=base64' '
1638 clean_fake_sendmail &&
1640 --transfer-encoding=base64 \
1641 --smtp-server="$(pwd)/fake.sendmail" \
1644 sed "1,/^$/d" msgtxt1 >actual &&
1645 test_cmp expected actual
1649 # Note that the patches in this test are deliberately out of order; we
1650 # want to make sure it works even if the cover-letter is not in the
1652 test_expect_success
$PREREQ 'refusing to send cover letter template' '
1653 clean_fake_sendmail &&
1655 git format-patch --cover-letter -2 -o outdir &&
1656 test_must_fail git send-email \
1657 --from="Example <nobody@example.com>" \
1658 --to=nobody@example.com \
1659 --smtp-server="$(pwd)/fake.sendmail" \
1660 outdir/0002-*.patch \
1661 outdir/0000-*.patch \
1662 outdir/0001-*.patch \
1664 grep "SUBJECT HERE" errors &&
1665 test -z "$(ls msgtxt*)"
1668 test_expect_success
$PREREQ '--force sends cover letter template anyway' '
1669 clean_fake_sendmail &&
1671 git format-patch --cover-letter -2 -o outdir &&
1674 --from="Example <nobody@example.com>" \
1675 --to=nobody@example.com \
1676 --smtp-server="$(pwd)/fake.sendmail" \
1677 outdir/0002-*.patch \
1678 outdir/0000-*.patch \
1679 outdir/0001-*.patch \
1681 ! grep "SUBJECT HERE" errors &&
1682 test -n "$(ls msgtxt*)"
1685 test_cover_addresses
() {
1688 clean_fake_sendmail
&&
1690 git format-patch
--cover-letter -2 -o outdir
&&
1691 cover
=$
(echo outdir
/0000-*.
patch) &&
1692 mv $cover cover-to-edit.
patch &&
1693 perl
-pe "s/^From:/$header: extra\@address.com\nFrom:/" cover-to-edit.
patch >"$cover" &&
1696 --from="Example <nobody@example.com>" \
1699 --smtp-server="$(pwd)/fake.sendmail" \
1700 outdir
/0000-*.
patch \
1701 outdir
/0001-*.
patch \
1702 outdir
/0002-*.
patch \
1704 grep "^$header: extra@address.com" msgtxt1
>to1
&&
1705 grep "^$header: extra@address.com" msgtxt2
>to2
&&
1706 grep "^$header: extra@address.com" msgtxt3
>to3
&&
1707 test_line_count
= 1 to1
&&
1708 test_line_count
= 1 to2
&&
1709 test_line_count
= 1 to3
1712 test_expect_success
$PREREQ 'to-cover adds To to all mail' '
1713 test_cover_addresses "To" --to-cover
1716 test_expect_success
$PREREQ 'cc-cover adds Cc to all mail' '
1717 test_cover_addresses "Cc" --cc-cover
1720 test_expect_success
$PREREQ 'tocover adds To to all mail' '
1721 test_config sendemail.tocover true &&
1722 test_cover_addresses "To"
1725 test_expect_success
$PREREQ 'cccover adds Cc to all mail' '
1726 test_config sendemail.cccover true &&
1727 test_cover_addresses "Cc"
1730 test_expect_success
$PREREQ 'escaped quotes in sendemail.aliasfiletype=mutt' '
1731 clean_fake_sendmail &&
1732 echo "alias sbd \\\"Dot U. Sir\\\" <somebody@example.org>" >.mutt &&
1733 git config --replace-all sendemail.aliasesfile "$(pwd)/.mutt" &&
1734 git config sendemail.aliasfiletype mutt &&
1736 --from="Example <nobody@example.com>" \
1738 --smtp-server="$(pwd)/fake.sendmail" \
1739 outdir/0001-*.patch \
1741 grep "^!somebody@example\.org!$" commandline1 &&
1742 grep -F "To: \"Dot U. Sir\" <somebody@example.org>" out
1745 test_expect_success
$PREREQ 'sendemail.aliasfiletype=mailrc' '
1746 clean_fake_sendmail &&
1747 echo "alias sbd somebody@example.org" >.mailrc &&
1748 git config --replace-all sendemail.aliasesfile "$(pwd)/.mailrc" &&
1749 git config sendemail.aliasfiletype mailrc &&
1751 --from="Example <nobody@example.com>" \
1753 --smtp-server="$(pwd)/fake.sendmail" \
1754 outdir/0001-*.patch \
1756 grep "^!somebody@example\.org!$" commandline1
1759 test_expect_success
$PREREQ 'sendemail.aliasfile=~/.mailrc' '
1760 clean_fake_sendmail &&
1761 echo "alias sbd someone@example.org" >"$HOME/.mailrc" &&
1762 git config --replace-all sendemail.aliasesfile "~/.mailrc" &&
1763 git config sendemail.aliasfiletype mailrc &&
1765 --from="Example <nobody@example.com>" \
1767 --smtp-server="$(pwd)/fake.sendmail" \
1768 outdir/0001-*.patch \
1770 grep "^!someone@example\.org!$" commandline1
1773 test_dump_aliases
() {
1774 msg
="$1" && shift &&
1775 filetype
="$1" && shift &&
1776 printf '%s\n' "$@" >expect
&&
1777 cat >.tmp-email-aliases
&&
1779 test_expect_success
$PREREQ "$msg" '
1780 clean_fake_sendmail && rm -fr outdir &&
1781 git config --replace-all sendemail.aliasesfile \
1782 "$(pwd)/.tmp-email-aliases" &&
1783 git config sendemail.aliasfiletype "$filetype" &&
1784 git send-email --dump-aliases 2>errors >actual &&
1785 test_cmp expect actual
1789 test_dump_aliases
'--dump-aliases sendmail format' \
1796 alice: Alice W Land <awol@example.com>
1797 bob: Robert Bobbyton <bob@example.com>
1798 chloe: chloe@example.com
1800 bcgrp: bob, chloe, Other <o@example.com>
1803 test_dump_aliases '--dump-aliases mutt format' \
1809 alias alice Alice W Land <awol@example.com>
1810 alias donald Donald C Carlton <donc@example.com>
1811 alias bob Robert Bobbyton <bob@example.com>
1812 alias chloe chloe@example.com
1815 test_dump_aliases '--dump-aliases mailrc format' \
1821 alias alice Alice W Land <awol@example.com>
1822 alias eve Eve <eve@example.com>
1823 alias bob Robert Bobbyton <bob@example.com>
1824 alias chloe chloe@example.com
1827 test_dump_aliases '--dump-aliases pine format' \
1833 alice Alice W Land <awol@example.com>
1834 eve Eve <eve@example.com>
1835 bob Robert Bobbyton <bob@example.com>
1836 chloe chloe@example.com
1839 test_dump_aliases '--dump-aliases gnus format' \
1845 (define-mail-alias "alice" "awol@example.com")
1846 (define-mail-alias "eve" "eve@example.com")
1847 (define-mail-alias "bob" "bob@example.com")
1848 (define-mail-alias "chloe" "chloe@example.com")
1851 test_expect_success '--dump-aliases must be used alone' '
1852 test_must_fail git send-email --dump-aliases --to=janice@example.com -1 refs/heads/accounting
1855 test_expect_success $PREREQ 'aliases and sendemail.identity' '
1856 test_must_fail git \
1857 -c sendemail.identity=cloud \
1858 -c sendemail.aliasesfile=default-aliases \
1859 -c sendemail.cloud.aliasesfile=cloud-aliases \
1860 send-email -1 2>stderr &&
1861 test_i18ngrep "cloud-aliases" stderr
1864 test_sendmail_aliases () {
1865 msg="$1" && shift &&
1867 cat >.tmp-email-aliases &&
1869 test_expect_success $PREREQ "$msg" '
1870 clean_fake_sendmail && rm -fr outdir &&
1871 git format-patch -1 -o outdir &&
1872 git config --replace-all sendemail.aliasesfile \
1873 "$(pwd)/.tmp-email-aliases" &&
1874 git config sendemail.aliasfiletype sendmail &&
1876 --from="Example <nobody@example.com>" \
1877 --to=alice --to=bcgrp \
1878 --smtp-server="$(pwd)/fake.sendmail" \
1879 outdir/0001-*.
patch \
1883 grep "^!$i!$" commandline1 ||
return 1
1888 test_sendmail_aliases 'sendemail.aliasfiletype
=sendmail
' \
1889 'awol@example\.com
' \
1890 'bob@example\.com
' \
1891 'chloe@example\.com
' \
1892 'o@example\.com
' <<-\EOF
1893 alice: Alice W Land <awol@example.com>
1894 bob: Robert Bobbyton <bob@example.com>
1896 # this is also a comment
1897 chloe: chloe@example.com
1899 bcgrp: bob, chloe, Other <o@example.com>
1902 test_sendmail_aliases 'sendmail aliases line folding
' \
1906 darla1 darla2 darla3 \
1907 elton1 elton2 elton3 \
1924 bcgrp: bob, chuck, darla, elton, fred, greg
1927 test_sendmail_aliases 'sendmail aliases tolerate bogus line folding
' \
1933 test_sendmail_aliases 'sendmail aliases empty
' alice bcgrp <<-\EOF
1936 test_expect_success $PREREQ 'alias support
in To header
' '
1937 clean_fake_sendmail
&&
1938 echo "alias sbd someone@example.org" >.mailrc
&&
1939 test_config sendemail.aliasesfile
".mailrc" &&
1940 test_config sendemail.aliasfiletype mailrc
&&
1941 git format-patch
--stdout -1 --to=sbd
>aliased.
patch &&
1943 --from="Example <nobody@example.com>" \
1944 --smtp-server="$(pwd)/fake.sendmail" \
1947 grep "^!someone@example\.org!$" commandline1
1950 test_expect_success $PREREQ 'alias support
in Cc header
' '
1951 clean_fake_sendmail
&&
1952 echo "alias sbd someone@example.org" >.mailrc
&&
1953 test_config sendemail.aliasesfile
".mailrc" &&
1954 test_config sendemail.aliasfiletype mailrc
&&
1955 git format-patch
--stdout -1 --cc=sbd
>aliased.
patch &&
1957 --from="Example <nobody@example.com>" \
1958 --smtp-server="$(pwd)/fake.sendmail" \
1961 grep "^!someone@example\.org!$" commandline1
1964 test_expect_success $PREREQ 'tocmd works with aliases
' '
1965 clean_fake_sendmail
&&
1966 echo "alias sbd someone@example.org" >.mailrc
&&
1967 test_config sendemail.aliasesfile
".mailrc" &&
1968 test_config sendemail.aliasfiletype mailrc
&&
1969 git format-patch
--stdout -1 >tocmd.
patch &&
1970 echo tocmd--sbd
>>tocmd.
patch &&
1972 --from="Example <nobody@example.com>" \
1973 --to-cmd=.
/tocmd-sed \
1974 --smtp-server="$(pwd)/fake.sendmail" \
1977 grep "^!someone@example\.org!$" commandline1
1980 test_expect_success $PREREQ 'cccmd works with aliases
' '
1981 clean_fake_sendmail
&&
1982 echo "alias sbd someone@example.org" >.mailrc
&&
1983 test_config sendemail.aliasesfile
".mailrc" &&
1984 test_config sendemail.aliasfiletype mailrc
&&
1985 git format-patch
--stdout -1 >cccmd.
patch &&
1986 echo cccmd--sbd
>>cccmd.
patch &&
1988 --from="Example <nobody@example.com>" \
1989 --cc-cmd=.
/cccmd-sed \
1990 --smtp-server="$(pwd)/fake.sendmail" \
1993 grep "^!someone@example\.org!$" commandline1
1996 do_xmailer_test () {
1997 expected=$1 params=$2 &&
1998 git format-patch -1 &&
2000 --from="Example <nobody@example.com>" \
2001 --to=someone@example.com \
2002 --smtp-server="$(pwd)/fake.sendmail" \
2006 { grep '^X-Mailer
:' out || :; } >mailer &&
2007 test_line_count = $expected mailer
2010 test_expect_success $PREREQ '--[no-
]xmailer without any configuration
' '
2011 do_xmailer_test
1 "--xmailer" &&
2012 do_xmailer_test
0 "--no-xmailer"
2015 test_expect_success $PREREQ '--[no-
]xmailer with sendemail.xmailer
=true
' '
2016 test_config sendemail.xmailer true
&&
2017 do_xmailer_test
1 "" &&
2018 do_xmailer_test
0 "--no-xmailer" &&
2019 do_xmailer_test
1 "--xmailer"
2022 test_expect_success $PREREQ '--[no-
]xmailer with sendemail.xmailer
=false
' '
2023 test_config sendemail.xmailer false
&&
2024 do_xmailer_test
0 "" &&
2025 do_xmailer_test
0 "--no-xmailer" &&
2026 do_xmailer_test
1 "--xmailer"
2029 test_expect_success $PREREQ 'setup expected-list
' '
2032 --from="Example <from@example.com>" \
2033 --to="To 1 <to1@example.com>" \
2034 --to="to2@example.com" \
2035 --to="to3@example.com" \
2036 --cc="Cc 1 <cc1@example.com>" \
2037 --cc="Cc2 <cc2@example.com>" \
2038 --bcc="bcc1@example.com" \
2039 --bcc="bcc2@example.com" \
2040 0001-add-master.
patch | replace_variable_fields \
2044 test_expect_success $PREREQ 'use email list
in --cc --to and
--bcc' '
2047 --from="Example <from@example.com>" \
2048 --to="To 1 <to1@example.com>, to2@example.com" \
2049 --to="to3@example.com" \
2050 --cc="Cc 1 <cc1@example.com>, Cc2 <cc2@example.com>" \
2051 --bcc="bcc1@example.com, bcc2@example.com" \
2052 0001-add-master.
patch | replace_variable_fields \
2054 test_cmp expected-list actual-list
2057 test_expect_success $PREREQ 'aliases work with email list
' '
2058 echo "alias to2 to2@example.com" >.mutt
&&
2059 echo "alias cc1 Cc 1 <cc1@example.com>" >>.mutt
&&
2060 test_config sendemail.aliasesfile
".mutt" &&
2061 test_config sendemail.aliasfiletype mutt
&&
2064 --from="Example <from@example.com>" \
2065 --to="To 1 <to1@example.com>, to2, to3@example.com" \
2066 --cc="cc1, Cc2 <cc2@example.com>" \
2067 --bcc="bcc1@example.com, bcc2@example.com" \
2068 0001-add-master.
patch | replace_variable_fields \
2070 test_cmp expected-list actual-list
2073 test_expect_success $PREREQ 'leading and trailing whitespaces are removed
' '
2074 echo "alias to2 to2@example.com" >.mutt
&&
2075 echo "alias cc1 Cc 1 <cc1@example.com>" >>.mutt
&&
2076 test_config sendemail.aliasesfile
".mutt" &&
2077 test_config sendemail.aliasfiletype mutt
&&
2078 TO1
=$
(echo "QTo 1 <to1@example.com>" | q_to_tab
) &&
2079 TO2
=$
(echo "QZto2" | qz_to_tab_space
) &&
2080 CC1
=$
(echo "cc1" | append_cr
) &&
2081 BCC1
=$
(echo " bcc1@example.com Q" | q_to_nul
) &&
2084 --from=" Example <from@example.com>" \
2087 --to=" to3@example.com " \
2089 --cc="Cc2 <cc2@example.com>" \
2091 --bcc="bcc2@example.com" \
2092 0001-add-master.
patch | replace_variable_fields \
2094 test_cmp expected-list actual-list
2097 test_expect_success $PREREQ 'invoke hook
' '
2098 mkdir
-p .git
/hooks
&&
2100 write_script .git
/hooks
/sendemail-validate
<<-\EOF &&
2101 # test that we have the correct environment variable, pwd, and
2111 test -f 0001-add-master.patch &&
2112 grep "add master" "$1"
2117 # Test that it works even if we are not at the root of the
2121 --from="Example <nobody@example.com>" \
2122 --to=nobody@example.com \
2123 --smtp-server="$(pwd)/../fake.sendmail" \
2124 ../0001-add-master.patch &&
2126 # Verify error message when a patch is rejected by the hook
2127 sed -e "s/add master/x/" ../0001-add-master.patch >../another.patch &&
2128 test_must_fail git send-email \
2129 --from="Example <nobody@example.com>" \
2130 --to=nobody@example.com \
2131 --smtp-server="$(pwd)/../fake.sendmail" \
2132 ../another.patch 2>err &&
2133 test_i18ngrep "rejected by sendemail-validate hook" err
2137 test_expect_success $PREREQ 'test that send-email works outside a repo' '
2138 nongit git send-email \
2139 --from="Example <nobody@example.com>" \
2140 --to=nobody@example.com \
2141 --smtp-server="$(pwd)/fake.sendmail" \
2142 "$(pwd)/0001-add-master.patch"
2145 test_expect_success $PREREQ 'test that sendmail config is rejected' '
2146 test_config sendmail.program sendmail &&
2147 test_must_fail git send-email \
2148 --from="Example <nobody@example.com>" \
2149 --to=nobody@example.com \
2150 --smtp-server="$(pwd)/fake.sendmail" \
2152 test_i18ngrep "found configuration options for '"'"sendmail"'"'" err
2155 test_expect_success $PREREQ 'test that sendmail config rejection is specific' '
2156 test_config resendmail.program sendmail &&
2158 --from="Example <nobody@example.com>" \
2159 --to=nobody@example.com \
2160 --smtp-server="$(pwd)/fake.sendmail" \
2164 test_expect_success $PREREQ 'test forbidSendmailVariables behavior override' '
2165 test_config sendmail.program sendmail &&
2166 test_config sendemail.forbidSendmailVariables false &&
2168 --from="Example <nobody@example.com>" \
2169 --to=nobody@example.com \
2170 --smtp-server="$(pwd)/fake.sendmail" \