3 test_description
='git send-email'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7 TEST_PASSES_SANITIZE_LEAK
=true
10 # May be altered later in the test
13 replace_variable_fields
() {
14 sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
15 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
16 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/"
19 test_expect_success
$PREREQ 'prepare reference tree' '
20 echo "1A quick brown fox jumps over the" >file &&
21 echo "lazy dog" >>file &&
23 GIT_AUTHOR_NAME="A" git commit -a -m "Initial."
26 test_expect_success
$PREREQ 'Setup helper tool' '
27 write_script fake.sendmail <<-\EOF &&
30 while test -f commandline$output
37 done >commandline$output
40 git add fake.sendmail &&
41 GIT_AUTHOR_NAME="A" git commit -a -m "Second."
44 clean_fake_sendmail
() {
45 rm -f commandline
* msgtxt
*
48 test_expect_success
$PREREQ 'Extract patches' '
49 patches=$(git format-patch -s --cc="One <one@example.com>" --cc=two@example.com -n HEAD^1) &&
50 threaded_patches=$(git format-patch -o threaded -s --in-reply-to="format" HEAD^1)
53 # Test no confirm early to ensure remaining tests will not hang
57 GIT_SEND_EMAIL_NOTTY
=1 \
59 --from="Example <from@example.com>" \
60 --to=nobody@example.com \
61 --smtp-server="$(pwd)/fake.sendmail" \
64 ! grep "Send this email" stdout
&&
68 # Exit immediately to prevent hang if a no-confirm test fails
70 if ! test -f no_confirm_okay
72 say
'confirm test failed; skipping remaining tests to prevent hanging'
73 PREREQ
="$PREREQ,CHECK_NO_CONFIRM"
78 test_expect_success
$PREREQ 'No confirm with --suppress-cc' '
79 test_no_confirm --suppress-cc=sob &&
84 test_expect_success
$PREREQ 'No confirm with --confirm=never' '
85 test_no_confirm --confirm=never &&
89 # leave sendemail.confirm set to never after this so that none of the
90 # remaining tests prompt unintentionally.
91 test_expect_success
$PREREQ 'No confirm with sendemail.confirm=never' '
92 git config sendemail.confirm never &&
93 test_no_confirm --compose --subject=foo &&
97 test_expect_success
$PREREQ 'Send patches' '
98 git send-email --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors
101 test_expect_success
$PREREQ 'setup expect' '
102 cat >expected <<-\EOF
110 test_expect_success
$PREREQ 'Verify commandline' '
111 test_cmp expected commandline1
114 test_expect_success
$PREREQ 'Send patches with --envelope-sender' '
115 clean_fake_sendmail &&
116 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
119 test_expect_success
$PREREQ 'setup expect' '
120 cat >expected <<-\EOF
130 test_expect_success
$PREREQ 'Verify commandline' '
131 test_cmp expected commandline1
134 test_expect_success
$PREREQ 'Send patches with --envelope-sender=auto' '
135 clean_fake_sendmail &&
136 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
139 test_expect_success
$PREREQ 'setup expect' '
140 cat >expected <<-\EOF
150 test_expect_success
$PREREQ 'Verify commandline' '
151 test_cmp expected commandline1
154 test_expect_success
$PREREQ 'setup expect for cc trailer' "
155 cat >expected-cc <<\EOF
156 !recipient@example.com!
167 test_expect_success
$PREREQ 'cc trailer with various syntax' '
168 test_commit cc-trailer &&
169 test_when_finished "git reset --hard HEAD^" &&
170 git commit --amend -F - <<-EOF &&
174 Cc: <two@example.com> # trailing comments are ignored
175 Cc: <three@example.com>, <not.four@example.com> one address per line
176 Cc: "Some # Body" <four@example.com> [ <also.a.comment> ]
177 Cc: five@example.com # not.six@example.com
178 Cc: six@example.com, not.seven@example.com
180 clean_fake_sendmail &&
181 git send-email -1 --to=recipient@example.com \
182 --smtp-server="$(pwd)/fake.sendmail" &&
183 test_cmp expected-cc commandline1
186 test_expect_success
$PREREQ 'setup fake get_maintainer.pl script for cc trailer' "
187 write_script expected-cc-script.sh <<-EOF
188 echo 'One Person <one@example.com> (supporter:THIS (FOO/bar))'
189 echo 'Two Person <two@example.com> (maintainer:THIS THING)'
190 echo 'Third List <three@example.com> (moderated list:THIS THING (FOO/bar))'
191 echo '<four@example.com> (moderated list:FOR THING)'
192 echo 'five@example.com (open list:FOR THING (FOO/bar))'
193 echo 'six@example.com (open list)'
197 test_expect_success
$PREREQ 'cc trailer with get_maintainer.pl output' '
198 clean_fake_sendmail &&
199 git send-email -1 --to=recipient@example.com \
200 --cc-cmd=./expected-cc-script.sh \
201 --smtp-server="$(pwd)/fake.sendmail" &&
202 test_cmp expected-cc commandline1
205 test_expect_success
$PREREQ 'setup expect' "
206 cat >expected-show-all-headers <<\EOF
208 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
209 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
210 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
212 Server: relay.example.com
213 MAIL FROM:<from@example.com>
214 RCPT TO:<to@example.com>
215 RCPT TO:<cc@example.com>
216 RCPT TO:<author@example.com>
217 RCPT TO:<one@example.com>
218 RCPT TO:<two@example.com>
219 RCPT TO:<bcc@example.com>
220 From: Example <from@example.com>
223 A <author@example.com>,
224 One <one@example.com>,
226 Subject: [PATCH 1/1] Second.
228 Message-Id: MESSAGE-ID-STRING
229 X-Mailer: X-MAILER-STRING
230 In-Reply-To: <unique-message-id@example.com>
231 References: <unique-message-id@example.com>
232 Reply-To: Reply <reply@example.com>
234 Content-Transfer-Encoding: 8bit
240 test_suppress_self
() {
242 test_when_finished
"git reset --hard HEAD^" &&
244 write_script cccmd-sed
<<-EOF &&
245 sed -n -e s/^cccmd--//p "\$1"
248 git commit
--amend --author="$1 <$2>" -F - &&
249 clean_fake_sendmail
&&
250 git format-patch
--stdout -1 >"suppress-self-$3.patch" &&
252 git send-email
--from="$1 <$2>" \
253 --to=nobody@example.com \
254 --cc-cmd=.
/cccmd-sed \
256 --smtp-server="$(pwd)/fake.sendmail" \
257 suppress-self-
$3.
patch &&
259 mv msgtxt1 msgtxt1-
$3 &&
260 sed -e '/^$/q' msgtxt1-
$3 >"msghdr1-$3" &&
262 (grep '^Cc:' msghdr1-
$3 >"actual-no-cc-$3";
263 test_must_be_empty actual-no-cc-
$3)
266 test_suppress_self_unquoted
() {
267 test_suppress_self
"$1" "$2" "unquoted-$3" <<-EOF
268 test suppress-cc.self unquoted-$3 with name $1 email $2
275 Signed-off-by: $1 <$2>
279 test_suppress_self_quoted
() {
280 test_suppress_self
"$1" "$2" "quoted-$3" <<-EOF
281 test suppress-cc.self quoted-$3 with name $1 email $2
289 Signed-off-by: $1 <$2>
290 Signed-off-by: "$1" <$2>
294 test_expect_success
$PREREQ 'self name is suppressed' "
295 test_suppress_self_unquoted 'A U Thor' 'author@example.com' \
296 'self_name_suppressed'
299 test_expect_success
$PREREQ 'self name with dot is suppressed' "
300 test_suppress_self_quoted 'A U. Thor' 'author@example.com' \
301 'self_name_dot_suppressed'
304 test_expect_success
$PREREQ 'non-ascii self name is suppressed' "
305 test_suppress_self_quoted 'Füñný Nâmé' 'odd_?=mail@example.com' \
306 'non_ascii_self_suppressed'
309 # This name is long enough to force format-patch to split it into multiple
310 # encoded-words, assuming it uses UTF-8 with the "Q" encoding.
311 test_expect_success
$PREREQ 'long non-ascii self name is suppressed' "
312 test_suppress_self_quoted 'Ƒüñníęř €. Nâṁé' 'odd_?=mail@example.com' \
313 'long_non_ascii_self_suppressed'
316 test_expect_success
$PREREQ 'sanitized self name is suppressed' "
317 test_suppress_self_unquoted '\"A U. Thor\"' 'author@example.com' \
318 'self_name_sanitized_suppressed'
321 test_expect_success
$PREREQ 'Show all headers' '
325 --from="Example <from@example.com>" \
326 --reply-to="Reply <reply@example.com>" \
327 --to=to@example.com \
328 --cc=cc@example.com \
329 --bcc=bcc@example.com \
330 --in-reply-to="<unique-message-id@example.com>" \
331 --smtp-server relay.example.com \
332 $patches | replace_variable_fields \
333 >actual-show-all-headers &&
334 test_cmp expected-show-all-headers actual-show-all-headers
337 test_expect_success
$PREREQ 'Prompting works' '
338 clean_fake_sendmail &&
339 (echo "to@example.com" &&
340 echo "my-message-id@example.com"
341 ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
342 --smtp-server="$(pwd)/fake.sendmail" \
345 grep "^From: A U Thor <author@example.com>\$" msgtxt1 &&
346 grep "^To: to@example.com\$" msgtxt1 &&
347 grep "^In-Reply-To: <my-message-id@example.com>" msgtxt1
350 test_expect_success
$PREREQ,AUTOIDENT
'implicit ident is allowed' '
351 clean_fake_sendmail &&
352 (sane_unset GIT_AUTHOR_NAME &&
353 sane_unset GIT_AUTHOR_EMAIL &&
354 sane_unset GIT_COMMITTER_NAME &&
355 sane_unset GIT_COMMITTER_EMAIL &&
356 GIT_SEND_EMAIL_NOTTY=1 git send-email \
357 --smtp-server="$(pwd)/fake.sendmail" \
358 --to=to@example.com \
359 $patches </dev/null 2>errors
363 test_expect_success
$PREREQ,!AUTOIDENT
'broken implicit ident aborts send-email' '
364 clean_fake_sendmail &&
365 (sane_unset GIT_AUTHOR_NAME &&
366 sane_unset GIT_AUTHOR_EMAIL &&
367 sane_unset GIT_COMMITTER_NAME &&
368 sane_unset GIT_COMMITTER_EMAIL &&
369 GIT_SEND_EMAIL_NOTTY=1 && export GIT_SEND_EMAIL_NOTTY &&
370 test_must_fail git send-email \
371 --smtp-server="$(pwd)/fake.sendmail" \
372 --to=to@example.com \
373 $patches </dev/null 2>errors &&
374 test_i18ngrep "tell me who you are" errors
378 test_expect_success
$PREREQ 'setup tocmd and cccmd scripts' '
379 write_script tocmd-sed <<-\EOF &&
380 sed -n -e "s/^tocmd--//p" "$1"
382 write_script cccmd-sed <<-\EOF
383 sed -n -e "s/^cccmd--//p" "$1"
387 test_expect_success
$PREREQ 'tocmd works' '
388 clean_fake_sendmail &&
389 cp $patches tocmd.patch &&
390 echo tocmd--tocmd@example.com >>tocmd.patch &&
392 --from="Example <nobody@example.com>" \
393 --to-cmd=./tocmd-sed \
394 --smtp-server="$(pwd)/fake.sendmail" \
397 grep "^To: tocmd@example.com" msgtxt1
400 test_expect_success
$PREREQ 'cccmd works' '
401 clean_fake_sendmail &&
402 cp $patches cccmd.patch &&
403 echo "cccmd-- cccmd@example.com" >>cccmd.patch &&
405 --from="Example <nobody@example.com>" \
406 --to=nobody@example.com \
407 --cc-cmd=./cccmd-sed \
408 --smtp-server="$(pwd)/fake.sendmail" \
411 grep "^ cccmd@example.com" msgtxt1
414 test_expect_success
$PREREQ 'reject long lines' '
416 z64=$z8$z8$z8$z8$z8$z8$z8$z8 &&
417 z512=$z64$z64$z64$z64$z64$z64$z64$z64 &&
418 clean_fake_sendmail &&
419 cp $patches longline.patch &&
420 cat >>longline.patch <<-EOF &&
425 test_must_fail git send-email \
426 --from="Example <nobody@example.com>" \
427 --to=nobody@example.com \
428 --smtp-server="$(pwd)/fake.sendmail" \
429 --transfer-encoding=8bit \
430 $patches longline.patch \
432 cat >expect <<-\EOF &&
433 fatal: longline.patch:35 is longer than 998 characters
434 warning: no patches were sent
436 test_cmp expect actual
439 test_expect_success
$PREREQ 'no patch was sent' '
440 ! test -e commandline1
443 test_expect_success
$PREREQ 'Author From: in message body' '
444 clean_fake_sendmail &&
446 --from="Example <nobody@example.com>" \
447 --to=nobody@example.com \
448 --smtp-server="$(pwd)/fake.sendmail" \
450 sed "1,/^\$/d" <msgtxt1 >msgbody1 &&
451 grep "From: A <author@example.com>" msgbody1
454 test_expect_success
$PREREQ 'Author From: not in message body' '
455 clean_fake_sendmail &&
457 --from="A <author@example.com>" \
458 --to=nobody@example.com \
459 --smtp-server="$(pwd)/fake.sendmail" \
461 sed "1,/^\$/d" <msgtxt1 >msgbody1 &&
462 ! grep "From: A <author@example.com>" msgbody1
465 test_expect_success
$PREREQ 'allow long lines with --no-validate' '
467 --from="Example <nobody@example.com>" \
468 --to=nobody@example.com \
469 --smtp-server="$(pwd)/fake.sendmail" \
471 $patches longline.patch \
475 test_expect_success
$PREREQ 'short lines with auto encoding are 8bit' '
476 clean_fake_sendmail &&
478 --from="A <author@example.com>" \
479 --to=nobody@example.com \
480 --smtp-server="$(pwd)/fake.sendmail" \
481 --transfer-encoding=auto \
483 grep "Content-Transfer-Encoding: 8bit" msgtxt1
486 test_expect_success
$PREREQ 'long lines with auto encoding are quoted-printable' '
487 clean_fake_sendmail &&
489 --from="Example <nobody@example.com>" \
490 --to=nobody@example.com \
491 --smtp-server="$(pwd)/fake.sendmail" \
492 --transfer-encoding=auto \
495 grep "Content-Transfer-Encoding: quoted-printable" msgtxt1
498 test_expect_success
$PREREQ 'carriage returns with auto encoding are quoted-printable' '
499 clean_fake_sendmail &&
500 cp $patches cr.patch &&
501 printf "this is a line\r\n" >>cr.patch &&
503 --from="Example <nobody@example.com>" \
504 --to=nobody@example.com \
505 --smtp-server="$(pwd)/fake.sendmail" \
506 --transfer-encoding=auto \
509 grep "Content-Transfer-Encoding: quoted-printable" msgtxt1
512 for enc
in auto quoted-printable base64
514 test_expect_success
$PREREQ "--validate passes with encoding $enc" '
516 --from="Example <nobody@example.com>" \
517 --to=nobody@example.com \
518 --smtp-server="$(pwd)/fake.sendmail" \
519 --transfer-encoding=$enc \
521 $patches longline.patch
526 test_expect_success
$PREREQ "--validate respects relative core.hooksPath path" '
527 clean_fake_sendmail &&
529 test_when_finished "rm my-hooks.ran" &&
530 write_script my-hooks/sendemail-validate <<-\EOF &&
534 test_config core.hooksPath "my-hooks" &&
535 test_must_fail git send-email \
536 --from="Example <nobody@example.com>" \
537 --to=nobody@example.com \
538 --smtp-server="$(pwd)/fake.sendmail" \
540 longline.patch 2>actual &&
541 test_path_is_file my-hooks.ran &&
542 cat >expect <<-EOF &&
543 fatal: longline.patch: rejected by sendemail-validate hook
544 fatal: command '"'"'git hook run --ignore-missing sendemail-validate -- <patch>'"'"' died with exit code 1
545 warning: no patches were sent
547 test_cmp expect actual
550 test_expect_success
$PREREQ "--validate respects absolute core.hooksPath path" '
551 hooks_path="$(pwd)/my-hooks" &&
552 test_config core.hooksPath "$hooks_path" &&
553 test_when_finished "rm my-hooks.ran" &&
554 test_must_fail git send-email \
555 --from="Example <nobody@example.com>" \
556 --to=nobody@example.com \
557 --smtp-server="$(pwd)/fake.sendmail" \
559 longline.patch 2>actual &&
560 test_path_is_file my-hooks.ran &&
561 cat >expect <<-EOF &&
562 fatal: longline.patch: rejected by sendemail-validate hook
563 fatal: command '"'"'git hook run --ignore-missing sendemail-validate -- <patch>'"'"' died with exit code 1
564 warning: no patches were sent
566 test_cmp expect actual
569 for enc
in 7bit
8bit quoted-printable base64
571 test_expect_success
$PREREQ "--transfer-encoding=$enc produces correct header" '
572 clean_fake_sendmail &&
574 --from="Example <nobody@example.com>" \
575 --to=nobody@example.com \
576 --smtp-server="$(pwd)/fake.sendmail" \
577 --transfer-encoding=$enc \
579 grep "Content-Transfer-Encoding: $enc" msgtxt1
583 test_expect_success
$PREREQ 'Invalid In-Reply-To' '
584 clean_fake_sendmail &&
586 --from="Example <nobody@example.com>" \
587 --to=nobody@example.com \
589 --smtp-server="$(pwd)/fake.sendmail" \
592 ! grep "^In-Reply-To: < *>" msgtxt1
595 test_expect_success
$PREREQ 'Valid In-Reply-To when prompting' '
596 clean_fake_sendmail &&
597 (echo "From Example <from@example.com>" &&
598 echo "To Example <to@example.com>" &&
600 ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
601 --smtp-server="$(pwd)/fake.sendmail" \
603 ! grep "^In-Reply-To: < *>" msgtxt1
606 test_expect_success
$PREREQ 'In-Reply-To without --chain-reply-to' '
607 clean_fake_sendmail &&
608 echo "<unique-message-id@example.com>" >expect &&
610 --from="Example <nobody@example.com>" \
611 --to=nobody@example.com \
612 --no-chain-reply-to \
613 --in-reply-to="$(cat expect)" \
614 --smtp-server="$(pwd)/fake.sendmail" \
615 $patches $patches $patches \
617 # The first message is a reply to --in-reply-to
618 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual &&
619 test_cmp expect actual &&
620 # Second and subsequent messages are replies to the first one
621 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect &&
622 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual &&
623 test_cmp expect actual &&
624 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual &&
625 test_cmp expect actual
628 test_expect_success
$PREREQ 'In-Reply-To with --chain-reply-to' '
629 clean_fake_sendmail &&
630 echo "<unique-message-id@example.com>" >expect &&
632 --from="Example <nobody@example.com>" \
633 --to=nobody@example.com \
635 --in-reply-to="$(cat expect)" \
636 --smtp-server="$(pwd)/fake.sendmail" \
637 $patches $patches $patches \
639 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual &&
640 test_cmp expect actual &&
641 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect &&
642 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual &&
643 test_cmp expect actual &&
644 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt2 >expect &&
645 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual &&
646 test_cmp expect actual
649 test_set_editor
"$(pwd)/fake-editor"
651 test_expect_success
$PREREQ 'setup erroring fake editor' '
652 write_script fake-editor <<-\EOF
653 echo >&2 "I am about to error"
658 test_expect_success
$PREREQ 'fake editor dies with error' '
659 clean_fake_sendmail &&
660 test_must_fail git send-email \
661 --compose --subject foo \
662 --from="Example <nobody@example.com>" \
663 --to=nobody@example.com \
664 --smtp-server="$(pwd)/fake.sendmail" \
666 grep "I am about to error" err &&
667 grep "the editor exited uncleanly, aborting everything" err
670 test_expect_success
$PREREQ 'setup fake editor' '
671 write_script fake-editor <<-\EOF
672 echo fake edit >>"$1"
676 test_expect_success
$PREREQ '--compose works' '
677 clean_fake_sendmail &&
679 --compose --subject foo \
680 --from="Example <nobody@example.com>" \
681 --to=nobody@example.com \
682 --smtp-server="$(pwd)/fake.sendmail" \
687 test_expect_success
$PREREQ 'first message is compose text' '
688 grep "^fake edit" msgtxt1
691 test_expect_success
$PREREQ 'second message is patch' '
692 grep "Subject:.*Second" msgtxt2
695 test_expect_success
$PREREQ 'setup expect' "
696 cat >expected-suppress-sob <<\EOF
698 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
699 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
700 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
702 Server: relay.example.com
703 MAIL FROM:<from@example.com>
704 RCPT TO:<to@example.com>
705 RCPT TO:<cc@example.com>
706 RCPT TO:<author@example.com>
707 RCPT TO:<one@example.com>
708 RCPT TO:<two@example.com>
709 From: Example <from@example.com>
712 A <author@example.com>,
713 One <one@example.com>,
715 Subject: [PATCH 1/1] Second.
717 Message-Id: MESSAGE-ID-STRING
718 X-Mailer: X-MAILER-STRING
720 Content-Transfer-Encoding: 8bit
726 test_suppression
() {
729 --suppress-cc=$1 ${2+"--suppress-cc=$2"} \
730 --from="Example <from@example.com>" \
731 --to=to@example.com \
732 --smtp-server relay.example.com \
733 $patches | replace_variable_fields \
734 >actual-suppress-
$1${2+"-$2"} &&
735 test_cmp expected-suppress-
$1${2+"-$2"} actual-suppress-
$1${2+"-$2"}
738 test_expect_success
$PREREQ 'sendemail.cc set' '
739 git config sendemail.cc cc@example.com &&
743 test_expect_success
$PREREQ 'setup expect' "
744 cat >expected-suppress-sob <<\EOF
746 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
747 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
748 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
750 Server: relay.example.com
751 MAIL FROM:<from@example.com>
752 RCPT TO:<to@example.com>
753 RCPT TO:<author@example.com>
754 RCPT TO:<one@example.com>
755 RCPT TO:<two@example.com>
756 From: Example <from@example.com>
758 Cc: A <author@example.com>,
759 One <one@example.com>,
761 Subject: [PATCH 1/1] Second.
763 Message-Id: MESSAGE-ID-STRING
764 X-Mailer: X-MAILER-STRING
766 Content-Transfer-Encoding: 8bit
772 test_expect_success
$PREREQ 'sendemail.cc unset' '
773 git config --unset sendemail.cc &&
777 test_expect_success
$PREREQ 'setup expect' "
778 cat >expected-suppress-cccmd <<\EOF
780 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
781 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
782 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
783 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
785 Server: relay.example.com
786 MAIL FROM:<from@example.com>
787 RCPT TO:<to@example.com>
788 RCPT TO:<author@example.com>
789 RCPT TO:<one@example.com>
790 RCPT TO:<two@example.com>
791 RCPT TO:<committer@example.com>
792 From: Example <from@example.com>
794 Cc: A <author@example.com>,
795 One <one@example.com>,
797 C O Mitter <committer@example.com>
798 Subject: [PATCH 1/1] Second.
800 Message-Id: MESSAGE-ID-STRING
801 X-Mailer: X-MAILER-STRING
803 Content-Transfer-Encoding: 8bit
809 test_expect_success
$PREREQ 'sendemail.cccmd' '
810 write_script cccmd <<-\EOF &&
811 echo cc-cmd@example.com
813 git config sendemail.cccmd ./cccmd &&
814 test_suppression cccmd
817 test_expect_success
$PREREQ 'setup expect' '
818 cat >expected-suppress-all <<\EOF
821 Server: relay.example.com
822 MAIL FROM:<from@example.com>
823 RCPT TO:<to@example.com>
824 From: Example <from@example.com>
826 Subject: [PATCH 1/1] Second.
828 Message-Id: MESSAGE-ID-STRING
829 X-Mailer: X-MAILER-STRING
831 Content-Transfer-Encoding: 8bit
837 test_expect_success
$PREREQ '--suppress-cc=all' '
841 test_expect_success
$PREREQ 'setup expect' "
842 cat >expected-suppress-body <<\EOF
844 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
845 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
846 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
847 (cc-cmd) Adding cc: cc-cmd@example.com from: './cccmd'
849 Server: relay.example.com
850 MAIL FROM:<from@example.com>
851 RCPT TO:<to@example.com>
852 RCPT TO:<author@example.com>
853 RCPT TO:<one@example.com>
854 RCPT TO:<two@example.com>
855 RCPT TO:<cc-cmd@example.com>
856 From: Example <from@example.com>
858 Cc: A <author@example.com>,
859 One <one@example.com>,
862 Subject: [PATCH 1/1] Second.
864 Message-Id: MESSAGE-ID-STRING
865 X-Mailer: X-MAILER-STRING
867 Content-Transfer-Encoding: 8bit
873 test_expect_success
$PREREQ '--suppress-cc=body' '
874 test_suppression body
877 test_expect_success
$PREREQ 'setup expect' "
878 cat >expected-suppress-body-cccmd <<\EOF
880 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
881 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
882 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
884 Server: relay.example.com
885 MAIL FROM:<from@example.com>
886 RCPT TO:<to@example.com>
887 RCPT TO:<author@example.com>
888 RCPT TO:<one@example.com>
889 RCPT TO:<two@example.com>
890 From: Example <from@example.com>
892 Cc: A <author@example.com>,
893 One <one@example.com>,
895 Subject: [PATCH 1/1] Second.
897 Message-Id: MESSAGE-ID-STRING
898 X-Mailer: X-MAILER-STRING
900 Content-Transfer-Encoding: 8bit
906 test_expect_success
$PREREQ '--suppress-cc=body --suppress-cc=cccmd' '
907 test_suppression body cccmd
910 test_expect_success
$PREREQ 'setup expect' "
911 cat >expected-suppress-sob <<\EOF
913 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
914 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
915 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
917 Server: relay.example.com
918 MAIL FROM:<from@example.com>
919 RCPT TO:<to@example.com>
920 RCPT TO:<author@example.com>
921 RCPT TO:<one@example.com>
922 RCPT TO:<two@example.com>
923 From: Example <from@example.com>
925 Cc: A <author@example.com>,
926 One <one@example.com>,
928 Subject: [PATCH 1/1] Second.
930 Message-Id: MESSAGE-ID-STRING
931 X-Mailer: X-MAILER-STRING
933 Content-Transfer-Encoding: 8bit
939 test_expect_success
$PREREQ '--suppress-cc=sob' '
940 test_might_fail git config --unset sendemail.cccmd &&
944 test_expect_success
$PREREQ 'setup expect' "
945 cat >expected-suppress-bodycc <<\EOF
947 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
948 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
949 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
950 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
952 Server: relay.example.com
953 MAIL FROM:<from@example.com>
954 RCPT TO:<to@example.com>
955 RCPT TO:<author@example.com>
956 RCPT TO:<one@example.com>
957 RCPT TO:<two@example.com>
958 RCPT TO:<committer@example.com>
959 From: Example <from@example.com>
961 Cc: A <author@example.com>,
962 One <one@example.com>,
964 C O Mitter <committer@example.com>
965 Subject: [PATCH 1/1] Second.
967 Message-Id: MESSAGE-ID-STRING
968 X-Mailer: X-MAILER-STRING
970 Content-Transfer-Encoding: 8bit
976 test_expect_success
$PREREQ '--suppress-cc=bodycc' '
977 test_suppression bodycc
980 test_expect_success
$PREREQ 'setup expect' "
981 cat >expected-suppress-cc <<\EOF
983 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
984 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
986 Server: relay.example.com
987 MAIL FROM:<from@example.com>
988 RCPT TO:<to@example.com>
989 RCPT TO:<author@example.com>
990 RCPT TO:<committer@example.com>
991 From: Example <from@example.com>
993 Cc: A <author@example.com>,
994 C O Mitter <committer@example.com>
995 Subject: [PATCH 1/1] Second.
997 Message-Id: MESSAGE-ID-STRING
998 X-Mailer: X-MAILER-STRING
1000 Content-Transfer-Encoding: 8bit
1006 test_expect_success
$PREREQ '--suppress-cc=cc' '
1012 GIT_SEND_EMAIL_NOTTY
=1 \
1014 --from="Example <nobody@example.com>" \
1015 --to=nobody@example.com \
1016 --smtp-server="$(pwd)/fake.sendmail" \
1017 $@
$patches >stdout
&&
1018 grep "Send this email" stdout
1021 test_expect_success
$PREREQ '--confirm=always' '
1022 test_confirm --confirm=always --suppress-cc=all
1025 test_expect_success
$PREREQ '--confirm=auto' '
1026 test_confirm --confirm=auto
1029 test_expect_success
$PREREQ '--confirm=cc' '
1030 test_confirm --confirm=cc
1033 test_expect_success
$PREREQ '--confirm=compose' '
1034 test_confirm --confirm=compose --compose
1037 test_expect_success
$PREREQ 'confirm by default (due to cc)' '
1038 test_when_finished git config sendemail.confirm never &&
1039 git config --unset sendemail.confirm &&
1043 test_expect_success
$PREREQ 'confirm by default (due to --compose)' '
1044 test_when_finished git config sendemail.confirm never &&
1045 git config --unset sendemail.confirm &&
1046 test_confirm --suppress-cc=all --compose
1049 test_expect_success
$PREREQ 'confirm detects EOF (inform assumes y)' '
1050 test_when_finished git config sendemail.confirm never &&
1051 git config --unset sendemail.confirm &&
1053 git format-patch -2 -o outdir &&
1054 GIT_SEND_EMAIL_NOTTY=1 \
1056 --from="Example <nobody@example.com>" \
1057 --to=nobody@example.com \
1058 --smtp-server="$(pwd)/fake.sendmail" \
1059 outdir/*.patch </dev/null
1062 test_expect_success
$PREREQ 'confirm detects EOF (auto causes failure)' '
1063 test_when_finished git config sendemail.confirm never &&
1064 git config sendemail.confirm auto &&
1065 GIT_SEND_EMAIL_NOTTY=1 &&
1066 export GIT_SEND_EMAIL_NOTTY &&
1067 test_must_fail git send-email \
1068 --from="Example <nobody@example.com>" \
1069 --to=nobody@example.com \
1070 --smtp-server="$(pwd)/fake.sendmail" \
1074 test_expect_success
$PREREQ 'confirm does not loop forever' '
1075 test_when_finished git config sendemail.confirm never &&
1076 git config sendemail.confirm auto &&
1077 GIT_SEND_EMAIL_NOTTY=1 &&
1078 export GIT_SEND_EMAIL_NOTTY &&
1079 yes "bogus" | test_must_fail git send-email \
1080 --from="Example <nobody@example.com>" \
1081 --to=nobody@example.com \
1082 --smtp-server="$(pwd)/fake.sendmail" \
1086 test_expect_success
$PREREQ 'utf8 Cc is rfc2047 encoded' '
1087 clean_fake_sendmail &&
1089 git format-patch -1 -o outdir --cc="àéìöú <utf8@example.com>" &&
1091 --from="Example <nobody@example.com>" \
1092 --to=nobody@example.com \
1093 --smtp-server="$(pwd)/fake.sendmail" \
1096 grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>"
1099 test_expect_success
$PREREQ '--compose adds MIME for utf8 body' '
1100 clean_fake_sendmail &&
1101 write_script fake-editor-utf8 <<-\EOF &&
1102 echo "utf8 body: àéìöú" >>"$1"
1104 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
1106 --compose --subject foo \
1107 --from="Example <nobody@example.com>" \
1108 --to=nobody@example.com \
1109 --smtp-server="$(pwd)/fake.sendmail" \
1111 grep "^utf8 body" msgtxt1 &&
1112 grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
1115 test_expect_success
$PREREQ '--compose respects user mime type' '
1116 clean_fake_sendmail &&
1117 write_script fake-editor-utf8-mime <<-\EOF &&
1120 Content-Type: text/plain; charset=iso-8859-1
1121 Content-Transfer-Encoding: 8bit
1127 GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \
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 &&
1136 ! grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
1139 test_expect_success
$PREREQ '--compose adds MIME for utf8 subject' '
1140 clean_fake_sendmail &&
1141 GIT_EDITOR="\"$(pwd)/fake-editor\"" \
1143 --compose --subject utf8-sübjëct \
1144 --from="Example <nobody@example.com>" \
1145 --to=nobody@example.com \
1146 --smtp-server="$(pwd)/fake.sendmail" \
1148 grep "^fake edit" msgtxt1 &&
1149 grep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
1152 test_expect_success
$PREREQ 'utf8 author is correctly passed on' '
1153 clean_fake_sendmail &&
1154 test_commit weird_author &&
1155 test_when_finished "git reset --hard HEAD^" &&
1156 git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" &&
1157 git format-patch --stdout -1 >funny_name.patch &&
1158 git send-email --from="Example <nobody@example.com>" \
1159 --to=nobody@example.com \
1160 --smtp-server="$(pwd)/fake.sendmail" \
1162 grep "^From: Füñný Nâmé <odd_?=mail@example.com>" msgtxt1
1165 test_expect_success
$PREREQ 'utf8 sender is not duplicated' '
1166 clean_fake_sendmail &&
1167 test_commit weird_sender &&
1168 test_when_finished "git reset --hard HEAD^" &&
1169 git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" &&
1170 git format-patch --stdout -1 >funny_name.patch &&
1171 git send-email --from="Füñný Nâmé <odd_?=mail@example.com>" \
1172 --to=nobody@example.com \
1173 --smtp-server="$(pwd)/fake.sendmail" \
1175 grep "^From: " msgtxt1 >msgfrom &&
1176 test_line_count = 1 msgfrom
1179 test_expect_success
$PREREQ 'sendemail.composeencoding works' '
1180 clean_fake_sendmail &&
1181 git config sendemail.composeencoding iso-8859-1 &&
1182 write_script fake-editor-utf8 <<-\EOF &&
1183 echo "utf8 body: àéìöú" >>"$1"
1185 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
1187 --compose --subject foo \
1188 --from="Example <nobody@example.com>" \
1189 --to=nobody@example.com \
1190 --smtp-server="$(pwd)/fake.sendmail" \
1192 grep "^utf8 body" msgtxt1 &&
1193 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1
1196 test_expect_success
$PREREQ '--compose-encoding works' '
1197 clean_fake_sendmail &&
1198 write_script fake-editor-utf8 <<-\EOF &&
1199 echo "utf8 body: àéìöú" >>"$1"
1201 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
1203 --compose-encoding iso-8859-1 \
1204 --compose --subject foo \
1205 --from="Example <nobody@example.com>" \
1206 --to=nobody@example.com \
1207 --smtp-server="$(pwd)/fake.sendmail" \
1209 grep "^utf8 body" msgtxt1 &&
1210 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1
1213 test_expect_success
$PREREQ '--compose-encoding overrides sendemail.composeencoding' '
1214 clean_fake_sendmail &&
1215 git config sendemail.composeencoding iso-8859-1 &&
1216 write_script fake-editor-utf8 <<-\EOF &&
1217 echo "utf8 body: àéìöú" >>"$1"
1219 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
1221 --compose-encoding iso-8859-2 \
1222 --compose --subject foo \
1223 --from="Example <nobody@example.com>" \
1224 --to=nobody@example.com \
1225 --smtp-server="$(pwd)/fake.sendmail" \
1227 grep "^utf8 body" msgtxt1 &&
1228 grep "^Content-Type: text/plain; charset=iso-8859-2" msgtxt1
1231 test_expect_success
$PREREQ '--compose-encoding adds correct MIME for subject' '
1232 clean_fake_sendmail &&
1233 GIT_EDITOR="\"$(pwd)/fake-editor\"" \
1235 --compose-encoding iso-8859-2 \
1236 --compose --subject utf8-sübjëct \
1237 --from="Example <nobody@example.com>" \
1238 --to=nobody@example.com \
1239 --smtp-server="$(pwd)/fake.sendmail" \
1241 grep "^fake edit" msgtxt1 &&
1242 grep "^Subject: =?iso-8859-2?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
1245 test_expect_success
$PREREQ 'detects ambiguous reference/file conflict' '
1248 git commit -m"add main" &&
1249 test_must_fail git send-email --dry-run main 2>errors &&
1250 grep disambiguate errors
1253 test_expect_success
$PREREQ 'feed two files' '
1255 git format-patch -2 -o outdir &&
1258 --from="Example <nobody@example.com>" \
1259 --to=nobody@example.com \
1260 outdir/000?-*.patch 2>errors >out &&
1261 grep "^Subject: " out >subjects &&
1262 test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." &&
1263 test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add main"
1266 test_expect_success
$PREREQ 'in-reply-to but no threading' '
1269 --from="Example <nobody@example.com>" \
1270 --to=nobody@example.com \
1271 --in-reply-to="<in-reply-id@example.com>" \
1274 grep "In-Reply-To: <in-reply-id@example.com>" out
1277 test_expect_success
$PREREQ 'no in-reply-to and no threading' '
1280 --from="Example <nobody@example.com>" \
1281 --to=nobody@example.com \
1284 ! grep "In-Reply-To: " stdout
1287 test_expect_success
$PREREQ 'threading but no chain-reply-to' '
1290 --from="Example <nobody@example.com>" \
1291 --to=nobody@example.com \
1293 --no-chain-reply-to \
1294 $patches $patches >stdout &&
1295 grep "In-Reply-To: " stdout
1298 test_expect_success
$PREREQ 'override in-reply-to if no threading' '
1301 --from="Example <nobody@example.com>" \
1302 --to=nobody@example.com \
1304 --in-reply-to="override" \
1305 $threaded_patches >stdout &&
1306 grep "In-Reply-To: <override>" stdout
1309 test_expect_success
$PREREQ 'sendemail.to works' '
1310 git config --replace-all sendemail.to "Somebody <somebody@ex.com>" &&
1313 --from="Example <nobody@example.com>" \
1315 grep "To: Somebody <somebody@ex.com>" stdout
1318 test_expect_success
$PREREQ 'setup sendemail.identity' '
1319 git config --replace-all sendemail.to "default@example.com" &&
1320 git config --replace-all sendemail.isp.to "isp@example.com" &&
1321 git config --replace-all sendemail.cloud.to "cloud@example.com"
1324 test_expect_success
$PREREQ 'sendemail.identity: reads the correct identity config' '
1325 git -c sendemail.identity=cloud send-email \
1327 --from="nobody@example.com" \
1329 grep "To: cloud@example.com" stdout
1332 test_expect_success
$PREREQ 'sendemail.identity: identity overrides sendemail.identity' '
1333 git -c sendemail.identity=cloud send-email \
1336 --from="nobody@example.com" \
1338 grep "To: isp@example.com" stdout
1341 test_expect_success
$PREREQ 'sendemail.identity: --no-identity clears previous identity' '
1342 git -c sendemail.identity=cloud send-email \
1345 --from="nobody@example.com" \
1347 grep "To: default@example.com" stdout
1350 test_expect_success
$PREREQ 'sendemail.identity: bool identity variable existence overrides' '
1351 git -c sendemail.identity=cloud \
1352 -c sendemail.xmailer=true \
1353 -c sendemail.cloud.xmailer=false \
1356 --from="nobody@example.com" \
1358 grep "To: cloud@example.com" stdout &&
1359 ! grep "X-Mailer" stdout
1362 test_expect_success
$PREREQ 'sendemail.identity: bool variable fallback' '
1363 git -c sendemail.identity=cloud \
1364 -c sendemail.xmailer=false \
1367 --from="nobody@example.com" \
1369 grep "To: cloud@example.com" stdout &&
1370 ! grep "X-Mailer" stdout
1373 test_expect_success
$PREREQ 'sendemail.identity: bool variable without a value' '
1374 git -c sendemail.xmailer \
1377 --from="nobody@example.com" \
1379 grep "To: default@example.com" stdout &&
1380 grep "X-Mailer" stdout
1383 test_expect_success
$PREREQ '--no-to overrides sendemail.to' '
1386 --from="Example <nobody@example.com>" \
1388 --to=nobody@example.com \
1390 grep "To: nobody@example.com" stdout &&
1391 ! grep "To: Somebody <somebody@ex.com>" stdout
1394 test_expect_success
$PREREQ 'sendemail.cc works' '
1395 git config --replace-all sendemail.cc "Somebody <somebody@ex.com>" &&
1398 --from="Example <nobody@example.com>" \
1399 --to=nobody@example.com \
1401 grep "Cc: Somebody <somebody@ex.com>" stdout
1404 test_expect_success
$PREREQ '--no-cc overrides sendemail.cc' '
1407 --from="Example <nobody@example.com>" \
1409 --cc=bodies@example.com \
1410 --to=nobody@example.com \
1412 grep "Cc: bodies@example.com" stdout &&
1413 ! grep "Cc: Somebody <somebody@ex.com>" stdout
1416 test_expect_success
$PREREQ 'sendemail.bcc works' '
1417 git config --replace-all sendemail.bcc "Other <other@ex.com>" &&
1420 --from="Example <nobody@example.com>" \
1421 --to=nobody@example.com \
1422 --smtp-server relay.example.com \
1424 grep "RCPT TO:<other@ex.com>" stdout
1427 test_expect_success
$PREREQ '--no-bcc overrides sendemail.bcc' '
1430 --from="Example <nobody@example.com>" \
1432 --bcc=bodies@example.com \
1433 --to=nobody@example.com \
1434 --smtp-server relay.example.com \
1436 grep "RCPT TO:<bodies@example.com>" stdout &&
1437 ! grep "RCPT TO:<other@ex.com>" stdout
1440 test_expect_success
$PREREQ 'patches To headers are used by default' '
1441 patch=$(git format-patch -1 --to="bodies@example.com") &&
1442 test_when_finished "rm $patch" &&
1445 --from="Example <nobody@example.com>" \
1446 --smtp-server relay.example.com \
1448 grep "RCPT TO:<bodies@example.com>" stdout
1451 test_expect_success
$PREREQ 'patches To headers are appended to' '
1452 patch=$(git format-patch -1 --to="bodies@example.com") &&
1453 test_when_finished "rm $patch" &&
1456 --from="Example <nobody@example.com>" \
1457 --to=nobody@example.com \
1458 --smtp-server relay.example.com \
1460 grep "RCPT TO:<bodies@example.com>" stdout &&
1461 grep "RCPT TO:<nobody@example.com>" stdout
1464 test_expect_success
$PREREQ 'To headers from files reset each patch' '
1465 patch1=$(git format-patch -1 --to="bodies@example.com") &&
1466 patch2=$(git format-patch -1 --to="other@example.com" HEAD~) &&
1467 test_when_finished "rm $patch1 && rm $patch2" &&
1470 --from="Example <nobody@example.com>" \
1471 --to="nobody@example.com" \
1472 --smtp-server relay.example.com \
1473 $patch1 $patch2 >stdout &&
1474 test $(grep -c "RCPT TO:<bodies@example.com>" stdout) = 1 &&
1475 test $(grep -c "RCPT TO:<nobody@example.com>" stdout) = 2 &&
1476 test $(grep -c "RCPT TO:<other@example.com>" stdout) = 1
1479 test_expect_success
$PREREQ 'setup expect' '
1480 cat >email-using-8bit <<\EOF
1481 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1482 Message-Id: <bogus-message-id@example.com>
1483 From: author@example.com
1484 Date: Sat, 12 Jun 2010 15:53:58 +0200
1485 Subject: subject goes here
1487 Dieser deutsche Text enthält einen Umlaut!
1491 test_expect_success
$PREREQ 'setup expect' '
1492 echo "Subject: subject goes here" >expected
1495 test_expect_success
$PREREQ 'ASCII subject is not RFC2047 quoted' '
1496 clean_fake_sendmail &&
1498 git send-email --from=author@example.com --to=nobody@example.com \
1499 --smtp-server="$(pwd)/fake.sendmail" \
1500 --8bit-encoding=UTF-8 \
1501 email-using-8bit >stdout &&
1502 grep "Subject" msgtxt1 >actual &&
1503 test_cmp expected actual
1506 test_expect_success
$PREREQ 'setup expect' '
1507 cat >content-type-decl <<-\EOF
1509 Content-Type: text/plain; charset=UTF-8
1510 Content-Transfer-Encoding: 8bit
1514 test_expect_success
$PREREQ 'asks about and fixes 8bit encodings' '
1515 clean_fake_sendmail &&
1517 git send-email --from=author@example.com --to=nobody@example.com \
1518 --smtp-server="$(pwd)/fake.sendmail" \
1519 email-using-8bit >stdout &&
1520 grep "do not declare a Content-Transfer-Encoding" stdout &&
1521 grep email-using-8bit stdout &&
1522 grep "Which 8bit encoding" stdout &&
1523 grep -E "Content|MIME" msgtxt1 >actual &&
1524 test_cmp content-type-decl actual
1527 test_expect_success
$PREREQ 'sendemail.8bitEncoding works' '
1528 clean_fake_sendmail &&
1529 git config sendemail.assume8bitEncoding UTF-8 &&
1531 git send-email --from=author@example.com --to=nobody@example.com \
1532 --smtp-server="$(pwd)/fake.sendmail" \
1533 email-using-8bit >stdout &&
1534 grep -E "Content|MIME" msgtxt1 >actual &&
1535 test_cmp content-type-decl actual
1538 test_expect_success
$PREREQ 'sendemail.8bitEncoding in .git/config overrides --global .gitconfig' '
1539 clean_fake_sendmail &&
1540 git config sendemail.assume8bitEncoding UTF-8 &&
1541 test_when_finished "rm -rf home" &&
1543 git config -f home/.gitconfig sendemail.assume8bitEncoding "bogus too" &&
1545 env HOME="$(pwd)/home" DEBUG=1 \
1546 git send-email --from=author@example.com --to=nobody@example.com \
1547 --smtp-server="$(pwd)/fake.sendmail" \
1548 email-using-8bit >stdout &&
1549 grep -E "Content|MIME" msgtxt1 >actual &&
1550 test_cmp content-type-decl actual
1553 test_expect_success
$PREREQ '--8bit-encoding overrides sendemail.8bitEncoding' '
1554 clean_fake_sendmail &&
1555 git config sendemail.assume8bitEncoding "bogus too" &&
1557 git send-email --from=author@example.com --to=nobody@example.com \
1558 --smtp-server="$(pwd)/fake.sendmail" \
1559 --8bit-encoding=UTF-8 \
1560 email-using-8bit >stdout &&
1561 grep -E "Content|MIME" msgtxt1 >actual &&
1562 test_cmp content-type-decl actual
1565 test_expect_success
$PREREQ 'setup expect' '
1566 cat >email-using-8bit <<-\EOF
1567 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1568 Message-Id: <bogus-message-id@example.com>
1569 From: author@example.com
1570 Date: Sat, 12 Jun 2010 15:53:58 +0200
1571 Subject: Dieser Betreff enthält auch einen Umlaut!
1573 Nothing to see here.
1577 test_expect_success
$PREREQ 'setup expect' '
1578 cat >expected <<-\EOF
1579 Subject: =?UTF-8?q?Dieser=20Betreff=20enth=C3=A4lt=20auch=20einen=20Umlaut!?=
1583 test_expect_success
$PREREQ '--8bit-encoding also treats subject' '
1584 clean_fake_sendmail &&
1586 git send-email --from=author@example.com --to=nobody@example.com \
1587 --smtp-server="$(pwd)/fake.sendmail" \
1588 --8bit-encoding=UTF-8 \
1589 email-using-8bit >stdout &&
1590 grep "Subject" msgtxt1 >actual &&
1591 test_cmp expected actual
1594 test_expect_success
$PREREQ 'setup expect' '
1595 cat >email-using-8bit <<-\EOF
1596 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1597 Message-Id: <bogus-message-id@example.com>
1598 From: A U Thor <author@example.com>
1599 Date: Sat, 12 Jun 2010 15:53:58 +0200
1600 Content-Type: text/plain; charset=UTF-8
1601 Subject: Nothing to see here.
1603 Dieser Betreff enthält auch einen Umlaut!
1607 test_expect_success
$PREREQ '--transfer-encoding overrides sendemail.transferEncoding' '
1608 clean_fake_sendmail &&
1609 test_must_fail git -c sendemail.transferEncoding=8bit \
1611 --transfer-encoding=7bit \
1612 --smtp-server="$(pwd)/fake.sendmail" \
1615 grep "cannot send message as 7bit" errors &&
1616 test -z "$(ls msgtxt*)"
1619 test_expect_success
$PREREQ 'sendemail.transferEncoding via config' '
1620 clean_fake_sendmail &&
1621 test_must_fail git -c sendemail.transferEncoding=7bit \
1623 --smtp-server="$(pwd)/fake.sendmail" \
1626 grep "cannot send message as 7bit" errors &&
1627 test -z "$(ls msgtxt*)"
1630 test_expect_success
$PREREQ 'sendemail.transferEncoding via cli' '
1631 clean_fake_sendmail &&
1632 test_must_fail git send-email \
1633 --transfer-encoding=7bit \
1634 --smtp-server="$(pwd)/fake.sendmail" \
1637 grep "cannot send message as 7bit" errors &&
1638 test -z "$(ls msgtxt*)"
1641 test_expect_success
$PREREQ 'setup expect' '
1642 cat >expected <<-\EOF
1643 Dieser Betreff enth=C3=A4lt auch einen Umlaut!
1647 test_expect_success
$PREREQ '8-bit and sendemail.transferencoding=quoted-printable' '
1648 clean_fake_sendmail &&
1650 --transfer-encoding=quoted-printable \
1651 --smtp-server="$(pwd)/fake.sendmail" \
1654 sed "1,/^$/d" msgtxt1 >actual &&
1655 test_cmp expected actual
1658 test_expect_success
$PREREQ 'setup expect' '
1659 cat >expected <<-\EOF
1660 RGllc2VyIEJldHJlZmYgZW50aMOkbHQgYXVjaCBlaW5lbiBVbWxhdXQhCg==
1664 test_expect_success
$PREREQ '8-bit and sendemail.transferencoding=base64' '
1665 clean_fake_sendmail &&
1667 --transfer-encoding=base64 \
1668 --smtp-server="$(pwd)/fake.sendmail" \
1671 sed "1,/^$/d" msgtxt1 >actual &&
1672 test_cmp expected actual
1675 test_expect_success
$PREREQ 'setup expect' '
1676 cat >email-using-qp <<-\EOF
1677 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1678 Message-Id: <bogus-message-id@example.com>
1679 From: A U Thor <author@example.com>
1680 Date: Sat, 12 Jun 2010 15:53:58 +0200
1682 Content-Transfer-Encoding: quoted-printable
1683 Content-Type: text/plain; charset=UTF-8
1684 Subject: Nothing to see here.
1686 Dieser Betreff enth=C3=A4lt auch einen Umlaut!
1690 test_expect_success
$PREREQ 'convert from quoted-printable to base64' '
1691 clean_fake_sendmail &&
1693 --transfer-encoding=base64 \
1694 --smtp-server="$(pwd)/fake.sendmail" \
1697 sed "1,/^$/d" msgtxt1 >actual &&
1698 test_cmp expected actual
1701 test_expect_success
$PREREQ 'setup expect' "
1702 tr -d '\\015' | tr '%' '\\015' >email-using-crlf <<EOF
1703 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1704 Message-Id: <bogus-message-id@example.com>
1705 From: A U Thor <author@example.com>
1706 Date: Sat, 12 Jun 2010 15:53:58 +0200
1707 Content-Type: text/plain; charset=UTF-8
1708 Subject: Nothing to see here.
1710 Look, I have a CRLF and an = sign!%
1714 test_expect_success
$PREREQ 'setup expect' '
1715 cat >expected <<-\EOF
1716 Look, I have a CRLF and an =3D sign!=0D
1720 test_expect_success
$PREREQ 'CRLF and sendemail.transferencoding=quoted-printable' '
1721 clean_fake_sendmail &&
1723 --transfer-encoding=quoted-printable \
1724 --smtp-server="$(pwd)/fake.sendmail" \
1727 sed "1,/^$/d" msgtxt1 >actual &&
1728 test_cmp expected actual
1731 test_expect_success
$PREREQ 'setup expect' '
1732 cat >expected <<-\EOF
1733 TG9vaywgSSBoYXZlIGEgQ1JMRiBhbmQgYW4gPSBzaWduIQ0K
1737 test_expect_success
$PREREQ 'CRLF and sendemail.transferencoding=base64' '
1738 clean_fake_sendmail &&
1740 --transfer-encoding=base64 \
1741 --smtp-server="$(pwd)/fake.sendmail" \
1744 sed "1,/^$/d" msgtxt1 >actual &&
1745 test_cmp expected actual
1749 # Note that the patches in this test are deliberately out of order; we
1750 # want to make sure it works even if the cover-letter is not in the
1752 test_expect_success
$PREREQ 'refusing to send cover letter template' '
1753 clean_fake_sendmail &&
1755 git format-patch --cover-letter -2 -o outdir &&
1756 test_must_fail git send-email \
1757 --from="Example <nobody@example.com>" \
1758 --to=nobody@example.com \
1759 --smtp-server="$(pwd)/fake.sendmail" \
1760 outdir/0002-*.patch \
1761 outdir/0000-*.patch \
1762 outdir/0001-*.patch \
1764 grep "SUBJECT HERE" errors &&
1765 test -z "$(ls msgtxt*)"
1768 test_expect_success
$PREREQ '--force sends cover letter template anyway' '
1769 clean_fake_sendmail &&
1771 git format-patch --cover-letter -2 -o outdir &&
1774 --from="Example <nobody@example.com>" \
1775 --to=nobody@example.com \
1776 --smtp-server="$(pwd)/fake.sendmail" \
1777 outdir/0002-*.patch \
1778 outdir/0000-*.patch \
1779 outdir/0001-*.patch \
1781 ! grep "SUBJECT HERE" errors &&
1782 test -n "$(ls msgtxt*)"
1785 test_cover_addresses
() {
1788 clean_fake_sendmail
&&
1790 git format-patch
--cover-letter -2 -o outdir
&&
1791 cover
=$
(echo outdir
/0000-*.
patch) &&
1792 mv $cover cover-to-edit.
patch &&
1793 perl
-pe "s/^From:/$header: extra\@address.com\nFrom:/" cover-to-edit.
patch >"$cover" &&
1796 --from="Example <nobody@example.com>" \
1799 --smtp-server="$(pwd)/fake.sendmail" \
1800 outdir
/0000-*.
patch \
1801 outdir
/0001-*.
patch \
1802 outdir
/0002-*.
patch \
1804 grep "^$header: extra@address.com" msgtxt1
>to1
&&
1805 grep "^$header: extra@address.com" msgtxt2
>to2
&&
1806 grep "^$header: extra@address.com" msgtxt3
>to3
&&
1807 test_line_count
= 1 to1
&&
1808 test_line_count
= 1 to2
&&
1809 test_line_count
= 1 to3
1812 test_expect_success
$PREREQ 'to-cover adds To to all mail' '
1813 test_cover_addresses "To" --to-cover
1816 test_expect_success
$PREREQ 'cc-cover adds Cc to all mail' '
1817 test_cover_addresses "Cc" --cc-cover
1820 test_expect_success
$PREREQ 'tocover adds To to all mail' '
1821 test_config sendemail.tocover true &&
1822 test_cover_addresses "To"
1825 test_expect_success
$PREREQ 'cccover adds Cc to all mail' '
1826 test_config sendemail.cccover true &&
1827 test_cover_addresses "Cc"
1830 test_expect_success
$PREREQ 'escaped quotes in sendemail.aliasfiletype=mutt' '
1831 clean_fake_sendmail &&
1832 echo "alias sbd \\\"Dot U. Sir\\\" <somebody@example.org>" >.mutt &&
1833 git config --replace-all sendemail.aliasesfile "$(pwd)/.mutt" &&
1834 git config sendemail.aliasfiletype mutt &&
1836 --from="Example <nobody@example.com>" \
1838 --smtp-server="$(pwd)/fake.sendmail" \
1839 outdir/0001-*.patch \
1841 grep "^!somebody@example\.org!$" commandline1 &&
1842 grep -F "To: \"Dot U. Sir\" <somebody@example.org>" out
1845 test_expect_success
$PREREQ 'sendemail.aliasfiletype=mailrc' '
1846 clean_fake_sendmail &&
1847 echo "alias sbd somebody@example.org" >.mailrc &&
1848 git config --replace-all sendemail.aliasesfile "$(pwd)/.mailrc" &&
1849 git config sendemail.aliasfiletype mailrc &&
1851 --from="Example <nobody@example.com>" \
1853 --smtp-server="$(pwd)/fake.sendmail" \
1854 outdir/0001-*.patch \
1856 grep "^!somebody@example\.org!$" commandline1
1859 test_expect_success
$PREREQ 'sendemail.aliasesfile=~/.mailrc' '
1860 clean_fake_sendmail &&
1861 echo "alias sbd someone@example.org" >"$HOME/.mailrc" &&
1862 git config --replace-all sendemail.aliasesfile "~/.mailrc" &&
1863 git config sendemail.aliasfiletype mailrc &&
1865 --from="Example <nobody@example.com>" \
1867 --smtp-server="$(pwd)/fake.sendmail" \
1868 outdir/0001-*.patch \
1870 grep "^!someone@example\.org!$" commandline1
1873 test_dump_aliases
() {
1874 msg
="$1" && shift &&
1875 filetype
="$1" && shift &&
1876 printf '%s\n' "$@" >expect
&&
1877 cat >.tmp-email-aliases
&&
1879 test_expect_success
$PREREQ "$msg" '
1880 clean_fake_sendmail && rm -fr outdir &&
1881 git config --replace-all sendemail.aliasesfile \
1882 "$(pwd)/.tmp-email-aliases" &&
1883 git config sendemail.aliasfiletype "$filetype" &&
1884 git send-email --dump-aliases 2>errors >actual &&
1885 test_cmp expect actual
1889 test_dump_aliases
'--dump-aliases sendmail format' \
1896 alice: Alice W Land <awol@example.com>
1897 bob: Robert Bobbyton <bob@example.com>
1898 chloe: chloe@example.com
1900 bcgrp: bob, chloe, Other <o@example.com>
1903 test_dump_aliases '--dump-aliases mutt format' \
1909 alias alice Alice W Land <awol@example.com>
1910 alias donald Donald C Carlton <donc@example.com>
1911 alias bob Robert Bobbyton <bob@example.com>
1912 alias chloe chloe@example.com
1915 test_dump_aliases '--dump-aliases mailrc format' \
1921 alias alice Alice W Land <awol@example.com>
1922 alias eve Eve <eve@example.com>
1923 alias bob Robert Bobbyton <bob@example.com>
1924 alias chloe chloe@example.com
1927 test_dump_aliases '--dump-aliases pine format' \
1933 alice Alice W Land <awol@example.com>
1934 eve Eve <eve@example.com>
1935 bob Robert Bobbyton <bob@example.com>
1936 chloe chloe@example.com
1939 test_dump_aliases '--dump-aliases gnus format' \
1945 (define-mail-alias "alice" "awol@example.com")
1946 (define-mail-alias "eve" "eve@example.com")
1947 (define-mail-alias "bob" "bob@example.com")
1948 (define-mail-alias "chloe" "chloe@example.com")
1951 test_expect_success '--dump-aliases must be used alone' '
1952 test_must_fail git send-email --dump-aliases --to=janice@example.com -1 refs/heads/accounting
1955 test_expect_success $PREREQ 'aliases and sendemail.identity' '
1956 test_must_fail git \
1957 -c sendemail.identity=cloud \
1958 -c sendemail.aliasesfile=default-aliases \
1959 -c sendemail.cloud.aliasesfile=cloud-aliases \
1960 send-email -1 2>stderr &&
1961 test_i18ngrep "cloud-aliases" stderr
1964 test_sendmail_aliases () {
1965 msg="$1" && shift &&
1967 cat >.tmp-email-aliases &&
1969 test_expect_success $PREREQ "$msg" '
1970 clean_fake_sendmail && rm -fr outdir &&
1971 git format-patch -1 -o outdir &&
1972 git config --replace-all sendemail.aliasesfile \
1973 "$(pwd)/.tmp-email-aliases" &&
1974 git config sendemail.aliasfiletype sendmail &&
1976 --from="Example <nobody@example.com>" \
1977 --to=alice --to=bcgrp \
1978 --smtp-server="$(pwd)/fake.sendmail" \
1979 outdir/0001-*.
patch \
1983 grep "^!$i!$" commandline1 ||
return 1
1988 test_sendmail_aliases 'sendemail.aliasfiletype
=sendmail
' \
1989 'awol@example\.com
' \
1990 'bob@example\.com
' \
1991 'chloe@example\.com
' \
1992 'o@example\.com
' <<-\EOF
1993 alice: Alice W Land <awol@example.com>
1994 bob: Robert Bobbyton <bob@example.com>
1996 # this is also a comment
1997 chloe: chloe@example.com
1999 bcgrp: bob, chloe, Other <o@example.com>
2002 test_sendmail_aliases 'sendmail aliases line folding
' \
2006 darla1 darla2 darla3 \
2007 elton1 elton2 elton3 \
2024 bcgrp: bob, chuck, darla, elton, fred, greg
2027 test_sendmail_aliases 'sendmail aliases tolerate bogus line folding
' \
2033 test_sendmail_aliases 'sendmail aliases empty
' alice bcgrp <<-\EOF
2036 test_expect_success $PREREQ 'alias support
in To header
' '
2037 clean_fake_sendmail
&&
2038 echo "alias sbd someone@example.org" >.mailrc
&&
2039 test_config sendemail.aliasesfile
".mailrc" &&
2040 test_config sendemail.aliasfiletype mailrc
&&
2041 git format-patch
--stdout -1 --to=sbd
>aliased.
patch &&
2043 --from="Example <nobody@example.com>" \
2044 --smtp-server="$(pwd)/fake.sendmail" \
2047 grep "^!someone@example\.org!$" commandline1
2050 test_expect_success $PREREQ 'alias support
in Cc header
' '
2051 clean_fake_sendmail
&&
2052 echo "alias sbd someone@example.org" >.mailrc
&&
2053 test_config sendemail.aliasesfile
".mailrc" &&
2054 test_config sendemail.aliasfiletype mailrc
&&
2055 git format-patch
--stdout -1 --cc=sbd
>aliased.
patch &&
2057 --from="Example <nobody@example.com>" \
2058 --smtp-server="$(pwd)/fake.sendmail" \
2061 grep "^!someone@example\.org!$" commandline1
2064 test_expect_success $PREREQ 'tocmd works with aliases
' '
2065 clean_fake_sendmail
&&
2066 echo "alias sbd someone@example.org" >.mailrc
&&
2067 test_config sendemail.aliasesfile
".mailrc" &&
2068 test_config sendemail.aliasfiletype mailrc
&&
2069 git format-patch
--stdout -1 >tocmd.
patch &&
2070 echo tocmd--sbd
>>tocmd.
patch &&
2072 --from="Example <nobody@example.com>" \
2073 --to-cmd=.
/tocmd-sed \
2074 --smtp-server="$(pwd)/fake.sendmail" \
2077 grep "^!someone@example\.org!$" commandline1
2080 test_expect_success $PREREQ 'cccmd works with aliases
' '
2081 clean_fake_sendmail
&&
2082 echo "alias sbd someone@example.org" >.mailrc
&&
2083 test_config sendemail.aliasesfile
".mailrc" &&
2084 test_config sendemail.aliasfiletype mailrc
&&
2085 git format-patch
--stdout -1 >cccmd.
patch &&
2086 echo cccmd--sbd
>>cccmd.
patch &&
2088 --from="Example <nobody@example.com>" \
2089 --cc-cmd=.
/cccmd-sed \
2090 --smtp-server="$(pwd)/fake.sendmail" \
2093 grep "^!someone@example\.org!$" commandline1
2096 do_xmailer_test () {
2097 expected=$1 params=$2 &&
2098 git format-patch -1 &&
2100 --from="Example <nobody@example.com>" \
2101 --to=someone@example.com \
2102 --smtp-server="$(pwd)/fake.sendmail" \
2106 { grep '^X-Mailer
:' out || :; } >mailer &&
2107 test_line_count = $expected mailer
2110 test_expect_success $PREREQ '--[no-
]xmailer without any configuration
' '
2111 do_xmailer_test
1 "--xmailer" &&
2112 do_xmailer_test
0 "--no-xmailer"
2115 test_expect_success $PREREQ '--[no-
]xmailer with sendemail.xmailer
=true
' '
2116 test_config sendemail.xmailer true
&&
2117 do_xmailer_test
1 "" &&
2118 do_xmailer_test
0 "--no-xmailer" &&
2119 do_xmailer_test
1 "--xmailer"
2122 test_expect_success $PREREQ '--[no-
]xmailer with sendemail.xmailer
' '
2123 test_when_finished
"test_unconfig sendemail.xmailer" &&
2124 cat >>.git
/config
<<-\EOF &&
2128 test_config sendemail.xmailer true &&
2129 do_xmailer_test 1 "" &&
2130 do_xmailer_test 0 "--no-xmailer" &&
2131 do_xmailer_test 1 "--xmailer"
2134 test_expect_success $PREREQ '--[no-]xmailer with sendemail.xmailer=false' '
2135 test_config sendemail.xmailer false &&
2136 do_xmailer_test 0 "" &&
2137 do_xmailer_test 0 "--no-xmailer" &&
2138 do_xmailer_test 1 "--xmailer"
2141 test_expect_success $PREREQ '--[no-]xmailer with sendemail.xmailer=' '
2142 test_config sendemail.xmailer "" &&
2143 do_xmailer_test 0 "" &&
2144 do_xmailer_test 0 "--no-xmailer" &&
2145 do_xmailer_test 1 "--xmailer"
2148 test_expect_success $PREREQ 'setup expected-list' '
2151 --from="Example <from@example.com>" \
2152 --to="To 1 <to1@example.com>" \
2153 --to="to2@example.com" \
2154 --to="to3@example.com" \
2155 --cc="Cc 1 <cc1@example.com>" \
2156 --cc="Cc2 <cc2@example.com>" \
2157 --bcc="bcc1@example.com" \
2158 --bcc="bcc2@example.com" \
2159 0001-add-main.patch | replace_variable_fields \
2163 test_expect_success $PREREQ 'use email list in --cc --to and --bcc' '
2166 --from="Example <from@example.com>" \
2167 --to="To 1 <to1@example.com>, to2@example.com" \
2168 --to="to3@example.com" \
2169 --cc="Cc 1 <cc1@example.com>, Cc2 <cc2@example.com>" \
2170 --bcc="bcc1@example.com, bcc2@example.com" \
2171 0001-add-main.patch | replace_variable_fields \
2173 test_cmp expected-list actual-list
2176 test_expect_success $PREREQ 'aliases work with email list' '
2177 echo "alias to2 to2@example.com" >.mutt &&
2178 echo "alias cc1 Cc 1 <cc1@example.com>" >>.mutt &&
2179 test_config sendemail.aliasesfile ".mutt" &&
2180 test_config sendemail.aliasfiletype mutt &&
2183 --from="Example <from@example.com>" \
2184 --to="To 1 <to1@example.com>, to2, to3@example.com" \
2185 --cc="cc1, Cc2 <cc2@example.com>" \
2186 --bcc="bcc1@example.com, bcc2@example.com" \
2187 0001-add-main.patch | replace_variable_fields \
2189 test_cmp expected-list actual-list
2192 test_expect_success $PREREQ 'leading and trailing whitespaces are removed' '
2193 echo "alias to2 to2@example.com" >.mutt &&
2194 echo "alias cc1 Cc 1 <cc1@example.com>" >>.mutt &&
2195 test_config sendemail.aliasesfile ".mutt" &&
2196 test_config sendemail.aliasfiletype mutt &&
2197 TO1=$(echo "QTo 1 <to1@example.com>" | q_to_tab) &&
2198 TO2=$(echo "QZto2" | qz_to_tab_space) &&
2199 CC1=$(echo "cc1" | append_cr) &&
2200 BCC1=$(echo " bcc1@example.com Q" | q_to_nul) &&
2203 --from=" Example <from@example.com>" \
2206 --to=" to3@example.com " \
2208 --cc="Cc2 <cc2@example.com>" \
2210 --bcc="bcc2@example.com" \
2211 0001-add-main.patch | replace_variable_fields \
2213 test_cmp expected-list actual-list
2216 test_expect_success $PREREQ 'test using command name with --sendmail-cmd' '
2217 clean_fake_sendmail &&
2220 --from="Example <nobody@example.com>" \
2221 --to=nobody@example.com \
2222 --sendmail-cmd="fake.sendmail" \
2224 test_path_is_file commandline1
2227 test_expect_success $PREREQ 'test using arguments with --sendmail-cmd' '
2228 clean_fake_sendmail &&
2230 --from="Example <nobody@example.com>" \
2231 --to=nobody@example.com \
2232 --sendmail-cmd='\''"$(pwd)/fake.sendmail" -f nobody@example.com'\'' \
2234 test_path_is_file commandline1
2237 test_expect_success $PREREQ 'test shell expression with --sendmail-cmd' '
2238 clean_fake_sendmail &&
2240 --from="Example <nobody@example.com>" \
2241 --to=nobody@example.com \
2242 --sendmail-cmd='\''f() { "$(pwd)/fake.sendmail" "$@"; };f'\'' \
2244 test_path_is_file commandline1
2247 test_expect_success $PREREQ 'set up in-reply-to/references patches' '
2248 cat >has-reply.patch <<-\
EOF &&
2249 From: A U Thor <author@example.com>
2250 Subject: patch with in-reply-to
2251 Message-ID: <patch.with.in.reply.to@example.com>
2252 In-Reply-To: <replied.to@example.com>
2253 References: <replied.to@example.com>
2257 cat >no-reply.patch <<-\EOF
2258 From: A U Thor <author@example.com>
2259 Subject: patch without in-reply-to
2260 Message-ID: <patch.without.in.reply.to@example.com>
2266 test_expect_success $PREREQ 'patch reply headers correct with --no-thread' '
2267 clean_fake_sendmail &&
2270 --to=nobody@example.com \
2271 --smtp-server="$(pwd)/fake.sendmail" \
2272 has-reply.patch no-reply.patch &&
2273 grep "In-Reply-To: <replied.to@example.com>" msgtxt1 &&
2274 grep "References: <replied.to@example.com>" msgtxt1 &&
2275 ! grep replied.to@example.com msgtxt2
2278 test_expect_success $PREREQ 'cmdline in-reply-to used with --no-thread' '
2279 clean_fake_sendmail &&
2282 --in-reply-to="<cmdline.reply@example.com>" \
2283 --to=nobody@example.com \
2284 --smtp-server="$(pwd)/fake.sendmail" \
2285 has-reply.patch no-reply.patch &&
2286 grep "In-Reply-To: <cmdline.reply@example.com>" msgtxt1 &&
2287 grep "References: <cmdline.reply@example.com>" msgtxt1 &&
2288 grep "In-Reply-To: <cmdline.reply@example.com>" msgtxt2 &&
2289 grep "References: <cmdline.reply@example.com>" msgtxt2
2292 test_expect_success $PREREQ 'invoke hook' '
2293 test_hook sendemail-validate <<-\EOF &&
2294 # test that we have the correct environment variable, pwd, and
2304 test -f 0001-add-main.patch &&
2305 grep "add main" "$1"
2310 # Test that it works even if we are not at the root of the
2314 --from="Example <nobody@example.com>" \
2315 --to=nobody@example.com \
2316 --smtp-server="$(pwd)/../fake.sendmail" \
2317 ../0001-add-main.patch &&
2319 # Verify error message when a patch is rejected by the hook
2320 sed -e "s/add main/x/" ../0001-add-main.patch >../another.patch &&
2321 test_must_fail git send-email \
2322 --from="Example <nobody@example.com>" \
2323 --to=nobody@example.com \
2324 --smtp-server="$(pwd)/../fake.sendmail" \
2325 ../another.patch 2>err &&
2326 test_i18ngrep "rejected by sendemail-validate hook" err
2330 test_expect_success $PREREQ 'test that send-email works outside a repo' '
2331 nongit git send-email \
2332 --from="Example <nobody@example.com>" \
2333 --to=nobody@example.com \
2334 --smtp-server="$(pwd)/fake.sendmail" \
2335 "$(pwd)/0001-add-main.patch"
2338 test_expect_success $PREREQ 'test that sendmail config is rejected' '
2339 test_config sendmail.program sendmail &&
2340 test_must_fail git send-email \
2341 --from="Example <nobody@example.com>" \
2342 --to=nobody@example.com \
2343 --smtp-server="$(pwd)/fake.sendmail" \
2345 test_i18ngrep "found configuration options for '"'"sendmail"'"'" err
2348 test_expect_success $PREREQ 'test that sendmail config rejection is specific' '
2349 test_config resendmail.program sendmail &&
2351 --from="Example <nobody@example.com>" \
2352 --to=nobody@example.com \
2353 --smtp-server="$(pwd)/fake.sendmail" \
2357 test_expect_success $PREREQ 'test forbidSendmailVariables behavior override' '
2358 test_config sendmail.program sendmail &&
2359 test_config sendemail.forbidSendmailVariables false &&
2361 --from="Example <nobody@example.com>" \
2362 --to=nobody@example.com \
2363 --smtp-server="$(pwd)/fake.sendmail" \