3 test_description
='git send-email'
6 # May be altered later in the test
9 test_expect_success
$PREREQ \
10 'prepare reference tree' \
11 'echo "1A quick brown fox jumps over the" >file &&
12 echo "lazy dog" >>file &&
14 GIT_AUTHOR_NAME="A" git commit -a -m "Initial."'
16 test_expect_success
$PREREQ \
18 '(echo "#!$SHELL_PATH"
21 echo "while test -f commandline\$output; do output=\$((\$output+1)); done"
24 echo " echo \"!\$a!\""
25 echo "done >commandline\$output"
26 echo "cat > msgtxt\$output"
28 chmod +x ./fake.sendmail &&
29 git add fake.sendmail &&
30 GIT_AUTHOR_NAME="A" git commit -a -m "Second."'
32 clean_fake_sendmail
() {
33 rm -f commandline
* msgtxt
*
36 test_expect_success
$PREREQ 'Extract patches' '
37 patches=`git format-patch -s --cc="One <one@example.com>" --cc=two@example.com -n HEAD^1`
40 # Test no confirm early to ensure remaining tests will not hang
44 GIT_SEND_EMAIL_NOTTY
=1 \
46 --from="Example <from@example.com>" \
47 --to=nobody@example.com \
48 --smtp-server="$(pwd)/fake.sendmail" \
51 test_must_fail
grep "Send this email" stdout
&&
55 # Exit immediately to prevent hang if a no-confirm test fails
57 if ! test -f no_confirm_okay
59 say
'confirm test failed; skipping remaining tests to prevent hanging'
60 PREREQ
="$PREREQ,CHECK_NO_CONFIRM"
65 test_expect_success
$PREREQ 'No confirm with --suppress-cc' '
66 test_no_confirm --suppress-cc=sob &&
71 test_expect_success
$PREREQ 'No confirm with --confirm=never' '
72 test_no_confirm --confirm=never &&
76 # leave sendemail.confirm set to never after this so that none of the
77 # remaining tests prompt unintentionally.
78 test_expect_success
$PREREQ 'No confirm with sendemail.confirm=never' '
79 git config sendemail.confirm never &&
80 test_no_confirm --compose --subject=foo &&
84 test_expect_success
$PREREQ 'Send patches' '
85 git send-email --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors
88 test_expect_success
$PREREQ 'setup expect' '
97 test_expect_success
$PREREQ \
98 'Verify commandline' \
99 'test_cmp expected commandline1'
101 test_expect_success
$PREREQ 'Send patches with --envelope-sender' '
102 clean_fake_sendmail &&
103 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
106 test_expect_success
$PREREQ 'setup expect' '
117 test_expect_success
$PREREQ \
118 'Verify commandline' \
119 'test_cmp expected commandline1'
121 test_expect_success
$PREREQ 'Send patches with --envelope-sender=auto' '
122 clean_fake_sendmail &&
123 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
126 test_expect_success
$PREREQ 'setup expect' '
137 test_expect_success
$PREREQ \
138 'Verify commandline' \
139 'test_cmp expected commandline1'
141 test_expect_success
$PREREQ 'setup expect' "
142 cat >expected-show-all-headers <<\EOF
144 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
145 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
146 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
148 Server: relay.example.com
149 MAIL FROM:<from@example.com>
150 RCPT TO:<to@example.com>
151 RCPT TO:<cc@example.com>
152 RCPT TO:<author@example.com>
153 RCPT TO:<one@example.com>
154 RCPT TO:<two@example.com>
155 RCPT TO:<bcc@example.com>
156 From: Example <from@example.com>
159 A <author@example.com>,
160 One <one@example.com>,
162 Subject: [PATCH 1/1] Second.
164 Message-Id: MESSAGE-ID-STRING
165 X-Mailer: X-MAILER-STRING
166 In-Reply-To: <unique-message-id@example.com>
167 References: <unique-message-id@example.com>
173 test_suppress_self
() {
175 test_when_finished
"git reset --hard HEAD^" &&
177 write_script cccmd-sed
<<-EOF &&
178 sed -n -e s/^cccmd--//p "\$1"
181 git commit
--amend --author="$1 <$2>" -F - &&
182 clean_fake_sendmail
&&
183 git format-patch
--stdout -1 >"suppress-self-$3.patch" &&
185 git send-email
--from="$1 <$2>" \
186 --to=nobody@example.com \
187 --cc-cmd=.
/cccmd-sed \
189 --smtp-server="$(pwd)/fake.sendmail" \
190 suppress-self-
$3.
patch &&
192 mv msgtxt1 msgtxt1-
$3 &&
193 sed -e '/^$/q' msgtxt1-
$3 >"msghdr1-$3" &&
194 >"expected-no-cc-$3" &&
196 (grep '^Cc:' msghdr1-
$3 >"actual-no-cc-$3";
197 test_cmp expected-no-cc-
$3 actual-no-cc-
$3)
200 test_suppress_self_unquoted
() {
201 test_suppress_self
"$1" "$2" "unquoted-$3" <<-EOF
202 test suppress-cc.self unquoted-$3 with name $1 email $2
209 Signed-off-by: $1 <$2>
213 test_suppress_self_quoted
() {
214 test_suppress_self
"$1" "$2" "quoted-$3" <<-EOF
215 test suppress-cc.self quoted-$3 with name $1 email $2
223 Signed-off-by: $1 <$2>
224 Signed-off-by: "$1" <$2>
228 test_expect_success
$PREREQ 'self name is suppressed' "
229 test_suppress_self_unquoted 'A U Thor' 'author@example.com' \
230 'self_name_suppressed'
233 test_expect_success
$PREREQ 'self name with dot is suppressed' "
234 test_suppress_self_quoted 'A U. Thor' 'author@example.com' \
235 'self_name_dot_suppressed'
238 test_expect_success
$PREREQ 'non-ascii self name is suppressed' "
239 test_suppress_self_quoted 'Füñný Nâmé' 'odd_?=mail@example.com' \
240 'non_ascii_self_suppressed'
243 # This name is long enough to force format-patch to split it into multiple
244 # encoded-words, assuming it uses UTF-8 with the "Q" encoding.
245 test_expect_success
$PREREQ 'long non-ascii self name is suppressed' "
246 test_suppress_self_quoted 'Ƒüñníęř €. Nâṁé' 'odd_?=mail@example.com' \
247 'long_non_ascii_self_suppressed'
250 test_expect_success
$PREREQ 'sanitized self name is suppressed' "
251 test_suppress_self_unquoted '\"A U. Thor\"' 'author@example.com' \
252 'self_name_sanitized_suppressed'
255 test_expect_success
$PREREQ 'Show all headers' '
259 --from="Example <from@example.com>" \
260 --to=to@example.com \
261 --cc=cc@example.com \
262 --bcc=bcc@example.com \
263 --in-reply-to="<unique-message-id@example.com>" \
264 --smtp-server relay.example.com \
266 sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
267 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
268 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
269 >actual-show-all-headers &&
270 test_cmp expected-show-all-headers actual-show-all-headers
273 test_expect_success
$PREREQ 'Prompting works' '
274 clean_fake_sendmail &&
275 (echo "to@example.com"
277 ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
278 --smtp-server="$(pwd)/fake.sendmail" \
281 grep "^From: A U Thor <author@example.com>\$" msgtxt1 &&
282 grep "^To: to@example.com\$" msgtxt1
285 test_expect_success
$PREREQ,AUTOIDENT
'implicit ident is allowed' '
286 clean_fake_sendmail &&
287 (sane_unset GIT_AUTHOR_NAME &&
288 sane_unset GIT_AUTHOR_EMAIL &&
289 sane_unset GIT_COMMITTER_NAME &&
290 sane_unset GIT_COMMITTER_EMAIL &&
291 GIT_SEND_EMAIL_NOTTY=1 git send-email \
292 --smtp-server="$(pwd)/fake.sendmail" \
293 --to=to@example.com \
294 $patches </dev/null 2>errors
298 test_expect_success
$PREREQ,!AUTOIDENT
'broken implicit ident aborts send-email' '
299 clean_fake_sendmail &&
300 (sane_unset GIT_AUTHOR_NAME &&
301 sane_unset GIT_AUTHOR_EMAIL &&
302 sane_unset GIT_COMMITTER_NAME &&
303 sane_unset GIT_COMMITTER_EMAIL &&
304 GIT_SEND_EMAIL_NOTTY=1 && export GIT_SEND_EMAIL_NOTTY &&
305 test_must_fail git send-email \
306 --smtp-server="$(pwd)/fake.sendmail" \
307 --to=to@example.com \
308 $patches </dev/null 2>errors &&
309 test_i18ngrep "tell me who you are" errors
313 test_expect_success
$PREREQ 'tocmd works' '
314 clean_fake_sendmail &&
315 cp $patches tocmd.patch &&
316 echo tocmd--tocmd@example.com >>tocmd.patch &&
319 echo sed -n -e s/^tocmd--//p \"\$1\"
321 chmod +x tocmd-sed &&
323 --from="Example <nobody@example.com>" \
324 --to-cmd=./tocmd-sed \
325 --smtp-server="$(pwd)/fake.sendmail" \
328 grep "^To: tocmd@example.com" msgtxt1
331 test_expect_success
$PREREQ 'cccmd works' '
332 clean_fake_sendmail &&
333 cp $patches cccmd.patch &&
334 echo "cccmd-- cccmd@example.com" >>cccmd.patch &&
337 echo sed -n -e s/^cccmd--//p \"\$1\"
339 chmod +x cccmd-sed &&
341 --from="Example <nobody@example.com>" \
342 --to=nobody@example.com \
343 --cc-cmd=./cccmd-sed \
344 --smtp-server="$(pwd)/fake.sendmail" \
347 grep "^ cccmd@example.com" msgtxt1
350 test_expect_success
$PREREQ 'reject long lines' '
352 z64=$z8$z8$z8$z8$z8$z8$z8$z8 &&
353 z512=$z64$z64$z64$z64$z64$z64$z64$z64 &&
354 clean_fake_sendmail &&
355 cp $patches longline.patch &&
356 echo $z512$z512 >>longline.patch &&
357 test_must_fail git send-email \
358 --from="Example <nobody@example.com>" \
359 --to=nobody@example.com \
360 --smtp-server="$(pwd)/fake.sendmail" \
361 $patches longline.patch \
363 grep longline.patch errors
366 test_expect_success
$PREREQ 'no patch was sent' '
367 ! test -e commandline1
370 test_expect_success
$PREREQ 'Author From: in message body' '
371 clean_fake_sendmail &&
373 --from="Example <nobody@example.com>" \
374 --to=nobody@example.com \
375 --smtp-server="$(pwd)/fake.sendmail" \
377 sed "1,/^\$/d" < msgtxt1 > msgbody1 &&
378 grep "From: A <author@example.com>" msgbody1
381 test_expect_success
$PREREQ 'Author From: not in message body' '
382 clean_fake_sendmail &&
384 --from="A <author@example.com>" \
385 --to=nobody@example.com \
386 --smtp-server="$(pwd)/fake.sendmail" \
388 sed "1,/^\$/d" < msgtxt1 > msgbody1 &&
389 ! grep "From: A <author@example.com>" msgbody1
392 test_expect_success
$PREREQ 'allow long lines with --no-validate' '
394 --from="Example <nobody@example.com>" \
395 --to=nobody@example.com \
396 --smtp-server="$(pwd)/fake.sendmail" \
398 $patches longline.patch \
402 test_expect_success
$PREREQ 'Invalid In-Reply-To' '
403 clean_fake_sendmail &&
405 --from="Example <nobody@example.com>" \
406 --to=nobody@example.com \
408 --smtp-server="$(pwd)/fake.sendmail" \
411 ! grep "^In-Reply-To: < *>" msgtxt1
414 test_expect_success
$PREREQ 'Valid In-Reply-To when prompting' '
415 clean_fake_sendmail &&
416 (echo "From Example <from@example.com>"
417 echo "To Example <to@example.com>"
419 ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
420 --smtp-server="$(pwd)/fake.sendmail" \
422 ! grep "^In-Reply-To: < *>" msgtxt1
425 test_expect_success
$PREREQ 'In-Reply-To without --chain-reply-to' '
426 clean_fake_sendmail &&
427 echo "<unique-message-id@example.com>" >expect &&
429 --from="Example <nobody@example.com>" \
430 --to=nobody@example.com \
432 --in-reply-to="$(cat expect)" \
433 --smtp-server="$(pwd)/fake.sendmail" \
434 $patches $patches $patches \
436 # The first message is a reply to --in-reply-to
437 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual &&
438 test_cmp expect actual &&
439 # Second and subsequent messages are replies to the first one
440 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect &&
441 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual &&
442 test_cmp expect actual &&
443 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual &&
444 test_cmp expect actual
447 test_expect_success
$PREREQ 'In-Reply-To with --chain-reply-to' '
448 clean_fake_sendmail &&
449 echo "<unique-message-id@example.com>" >expect &&
451 --from="Example <nobody@example.com>" \
452 --to=nobody@example.com \
454 --in-reply-to="$(cat expect)" \
455 --smtp-server="$(pwd)/fake.sendmail" \
456 $patches $patches $patches \
458 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual &&
459 test_cmp expect actual &&
460 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect &&
461 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual &&
462 test_cmp expect actual &&
463 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt2 >expect &&
464 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual &&
465 test_cmp expect actual
468 test_expect_success
$PREREQ 'setup fake editor' '
469 (echo "#!$SHELL_PATH" &&
470 echo "echo fake edit >>\"\$1\""
475 test_set_editor
"$(pwd)/fake-editor"
477 test_expect_success
$PREREQ '--compose works' '
478 clean_fake_sendmail &&
480 --compose --subject foo \
481 --from="Example <nobody@example.com>" \
482 --to=nobody@example.com \
483 --smtp-server="$(pwd)/fake.sendmail" \
488 test_expect_success
$PREREQ 'first message is compose text' '
489 grep "^fake edit" msgtxt1
492 test_expect_success
$PREREQ 'second message is patch' '
493 grep "Subject:.*Second" msgtxt2
496 test_expect_success
$PREREQ 'setup expect' "
497 cat >expected-suppress-sob <<\EOF
499 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
500 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
501 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
503 Server: relay.example.com
504 MAIL FROM:<from@example.com>
505 RCPT TO:<to@example.com>
506 RCPT TO:<cc@example.com>
507 RCPT TO:<author@example.com>
508 RCPT TO:<one@example.com>
509 RCPT TO:<two@example.com>
510 From: Example <from@example.com>
513 A <author@example.com>,
514 One <one@example.com>,
516 Subject: [PATCH 1/1] Second.
518 Message-Id: MESSAGE-ID-STRING
519 X-Mailer: X-MAILER-STRING
525 test_suppression
() {
528 --suppress-cc=$1 ${2+"--suppress-cc=$2"} \
529 --from="Example <from@example.com>" \
530 --to=to@example.com \
531 --smtp-server relay.example.com \
533 sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
534 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
535 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
536 >actual-suppress-
$1${2+"-$2"} &&
537 test_cmp expected-suppress-
$1${2+"-$2"} actual-suppress-
$1${2+"-$2"}
540 test_expect_success
$PREREQ 'sendemail.cc set' '
541 git config sendemail.cc cc@example.com &&
545 test_expect_success
$PREREQ 'setup expect' "
546 cat >expected-suppress-sob <<\EOF
548 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
549 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
550 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
552 Server: relay.example.com
553 MAIL FROM:<from@example.com>
554 RCPT TO:<to@example.com>
555 RCPT TO:<author@example.com>
556 RCPT TO:<one@example.com>
557 RCPT TO:<two@example.com>
558 From: Example <from@example.com>
560 Cc: A <author@example.com>,
561 One <one@example.com>,
563 Subject: [PATCH 1/1] Second.
565 Message-Id: MESSAGE-ID-STRING
566 X-Mailer: X-MAILER-STRING
572 test_expect_success
$PREREQ 'sendemail.cc unset' '
573 git config --unset sendemail.cc &&
577 test_expect_success
$PREREQ 'setup expect' "
578 cat >expected-suppress-cccmd <<\EOF
580 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
581 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
582 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
583 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
585 Server: relay.example.com
586 MAIL FROM:<from@example.com>
587 RCPT TO:<to@example.com>
588 RCPT TO:<author@example.com>
589 RCPT TO:<one@example.com>
590 RCPT TO:<two@example.com>
591 RCPT TO:<committer@example.com>
592 From: Example <from@example.com>
594 Cc: A <author@example.com>,
595 One <one@example.com>,
597 C O Mitter <committer@example.com>
598 Subject: [PATCH 1/1] Second.
600 Message-Id: MESSAGE-ID-STRING
601 X-Mailer: X-MAILER-STRING
607 test_expect_success
$PREREQ 'sendemail.cccmd' '
608 echo echo cc-cmd@example.com > cccmd &&
610 git config sendemail.cccmd ./cccmd &&
611 test_suppression cccmd
614 test_expect_success
$PREREQ 'setup expect' '
615 cat >expected-suppress-all <<\EOF
618 Server: relay.example.com
619 MAIL FROM:<from@example.com>
620 RCPT TO:<to@example.com>
621 From: Example <from@example.com>
623 Subject: [PATCH 1/1] Second.
625 Message-Id: MESSAGE-ID-STRING
626 X-Mailer: X-MAILER-STRING
632 test_expect_success
$PREREQ '--suppress-cc=all' '
636 test_expect_success
$PREREQ 'setup expect' "
637 cat >expected-suppress-body <<\EOF
639 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
640 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
641 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
642 (cc-cmd) Adding cc: cc-cmd@example.com from: './cccmd'
644 Server: relay.example.com
645 MAIL FROM:<from@example.com>
646 RCPT TO:<to@example.com>
647 RCPT TO:<author@example.com>
648 RCPT TO:<one@example.com>
649 RCPT TO:<two@example.com>
650 RCPT TO:<cc-cmd@example.com>
651 From: Example <from@example.com>
653 Cc: A <author@example.com>,
654 One <one@example.com>,
657 Subject: [PATCH 1/1] Second.
659 Message-Id: MESSAGE-ID-STRING
660 X-Mailer: X-MAILER-STRING
666 test_expect_success
$PREREQ '--suppress-cc=body' '
667 test_suppression body
670 test_expect_success
$PREREQ 'setup expect' "
671 cat >expected-suppress-body-cccmd <<\EOF
673 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
674 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
675 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
677 Server: relay.example.com
678 MAIL FROM:<from@example.com>
679 RCPT TO:<to@example.com>
680 RCPT TO:<author@example.com>
681 RCPT TO:<one@example.com>
682 RCPT TO:<two@example.com>
683 From: Example <from@example.com>
685 Cc: A <author@example.com>,
686 One <one@example.com>,
688 Subject: [PATCH 1/1] Second.
690 Message-Id: MESSAGE-ID-STRING
691 X-Mailer: X-MAILER-STRING
697 test_expect_success
$PREREQ '--suppress-cc=body --suppress-cc=cccmd' '
698 test_suppression body cccmd
701 test_expect_success
$PREREQ 'setup expect' "
702 cat >expected-suppress-sob <<\EOF
704 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
705 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
706 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
708 Server: relay.example.com
709 MAIL FROM:<from@example.com>
710 RCPT TO:<to@example.com>
711 RCPT TO:<author@example.com>
712 RCPT TO:<one@example.com>
713 RCPT TO:<two@example.com>
714 From: Example <from@example.com>
716 Cc: A <author@example.com>,
717 One <one@example.com>,
719 Subject: [PATCH 1/1] Second.
721 Message-Id: MESSAGE-ID-STRING
722 X-Mailer: X-MAILER-STRING
728 test_expect_success
$PREREQ '--suppress-cc=sob' '
729 test_might_fail git config --unset sendemail.cccmd &&
733 test_expect_success
$PREREQ 'setup expect' "
734 cat >expected-suppress-bodycc <<\EOF
736 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
737 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
738 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
739 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
741 Server: relay.example.com
742 MAIL FROM:<from@example.com>
743 RCPT TO:<to@example.com>
744 RCPT TO:<author@example.com>
745 RCPT TO:<one@example.com>
746 RCPT TO:<two@example.com>
747 RCPT TO:<committer@example.com>
748 From: Example <from@example.com>
750 Cc: A <author@example.com>,
751 One <one@example.com>,
753 C O Mitter <committer@example.com>
754 Subject: [PATCH 1/1] Second.
756 Message-Id: MESSAGE-ID-STRING
757 X-Mailer: X-MAILER-STRING
763 test_expect_success
$PREREQ '--suppress-cc=bodycc' '
764 test_suppression bodycc
767 test_expect_success
$PREREQ 'setup expect' "
768 cat >expected-suppress-cc <<\EOF
770 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
771 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
773 Server: relay.example.com
774 MAIL FROM:<from@example.com>
775 RCPT TO:<to@example.com>
776 RCPT TO:<author@example.com>
777 RCPT TO:<committer@example.com>
778 From: Example <from@example.com>
780 Cc: A <author@example.com>,
781 C O Mitter <committer@example.com>
782 Subject: [PATCH 1/1] Second.
784 Message-Id: MESSAGE-ID-STRING
785 X-Mailer: X-MAILER-STRING
791 test_expect_success
$PREREQ '--suppress-cc=cc' '
797 GIT_SEND_EMAIL_NOTTY
=1 \
799 --from="Example <nobody@example.com>" \
800 --to=nobody@example.com \
801 --smtp-server="$(pwd)/fake.sendmail" \
802 $@
$patches > stdout
&&
803 grep "Send this email" stdout
806 test_expect_success
$PREREQ '--confirm=always' '
807 test_confirm --confirm=always --suppress-cc=all
810 test_expect_success
$PREREQ '--confirm=auto' '
811 test_confirm --confirm=auto
814 test_expect_success
$PREREQ '--confirm=cc' '
815 test_confirm --confirm=cc
818 test_expect_success
$PREREQ '--confirm=compose' '
819 test_confirm --confirm=compose --compose
822 test_expect_success
$PREREQ 'confirm by default (due to cc)' '
823 CONFIRM=$(git config --get sendemail.confirm) &&
824 git config --unset sendemail.confirm &&
827 git config sendemail.confirm ${CONFIRM:-never}
831 test_expect_success
$PREREQ 'confirm by default (due to --compose)' '
832 CONFIRM=$(git config --get sendemail.confirm) &&
833 git config --unset sendemail.confirm &&
834 test_confirm --suppress-cc=all --compose
836 git config sendemail.confirm ${CONFIRM:-never}
840 test_expect_success
$PREREQ 'confirm detects EOF (inform assumes y)' '
841 CONFIRM=$(git config --get sendemail.confirm) &&
842 git config --unset sendemail.confirm &&
844 git format-patch -2 -o outdir &&
845 GIT_SEND_EMAIL_NOTTY=1 \
847 --from="Example <nobody@example.com>" \
848 --to=nobody@example.com \
849 --smtp-server="$(pwd)/fake.sendmail" \
850 outdir/*.patch < /dev/null
852 git config sendemail.confirm ${CONFIRM:-never}
856 test_expect_success
$PREREQ 'confirm detects EOF (auto causes failure)' '
857 CONFIRM=$(git config --get sendemail.confirm) &&
858 git config sendemail.confirm auto &&
859 GIT_SEND_EMAIL_NOTTY=1 &&
860 export GIT_SEND_EMAIL_NOTTY &&
861 test_must_fail git send-email \
862 --from="Example <nobody@example.com>" \
863 --to=nobody@example.com \
864 --smtp-server="$(pwd)/fake.sendmail" \
867 git config sendemail.confirm ${CONFIRM:-never}
871 test_expect_success
$PREREQ 'confirm does not loop forever' '
872 CONFIRM=$(git config --get sendemail.confirm) &&
873 git config sendemail.confirm auto &&
874 GIT_SEND_EMAIL_NOTTY=1 &&
875 export GIT_SEND_EMAIL_NOTTY &&
876 yes "bogus" | test_must_fail git send-email \
877 --from="Example <nobody@example.com>" \
878 --to=nobody@example.com \
879 --smtp-server="$(pwd)/fake.sendmail" \
882 git config sendemail.confirm ${CONFIRM:-never}
886 test_expect_success
$PREREQ 'utf8 Cc is rfc2047 encoded' '
887 clean_fake_sendmail &&
889 git format-patch -1 -o outdir --cc="àéìöú <utf8@example.com>" &&
891 --from="Example <nobody@example.com>" \
892 --to=nobody@example.com \
893 --smtp-server="$(pwd)/fake.sendmail" \
896 grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>"
899 test_expect_success
$PREREQ '--compose adds MIME for utf8 body' '
900 clean_fake_sendmail &&
901 (echo "#!$SHELL_PATH" &&
902 echo "echo utf8 body: àéìöú >>\"\$1\""
903 ) >fake-editor-utf8 &&
904 chmod +x fake-editor-utf8 &&
905 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
907 --compose --subject foo \
908 --from="Example <nobody@example.com>" \
909 --to=nobody@example.com \
910 --smtp-server="$(pwd)/fake.sendmail" \
912 grep "^utf8 body" msgtxt1 &&
913 grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
916 test_expect_success
$PREREQ '--compose respects user mime type' '
917 clean_fake_sendmail &&
918 (echo "#!$SHELL_PATH" &&
919 echo "(echo MIME-Version: 1.0"
920 echo " echo Content-Type: text/plain\\; charset=iso-8859-1"
921 echo " echo Content-Transfer-Encoding: 8bit"
922 echo " echo Subject: foo"
924 echo " echo utf8 body: àéìöú) >\"\$1\""
925 ) >fake-editor-utf8-mime &&
926 chmod +x fake-editor-utf8-mime &&
927 GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \
929 --compose --subject foo \
930 --from="Example <nobody@example.com>" \
931 --to=nobody@example.com \
932 --smtp-server="$(pwd)/fake.sendmail" \
934 grep "^utf8 body" msgtxt1 &&
935 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 &&
936 ! grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
939 test_expect_success
$PREREQ '--compose adds MIME for utf8 subject' '
940 clean_fake_sendmail &&
941 GIT_EDITOR="\"$(pwd)/fake-editor\"" \
943 --compose --subject utf8-sübjëct \
944 --from="Example <nobody@example.com>" \
945 --to=nobody@example.com \
946 --smtp-server="$(pwd)/fake.sendmail" \
948 grep "^fake edit" msgtxt1 &&
949 grep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
952 test_expect_success
$PREREQ 'utf8 author is correctly passed on' '
953 clean_fake_sendmail &&
954 test_commit weird_author &&
955 test_when_finished "git reset --hard HEAD^" &&
956 git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" &&
957 git format-patch --stdout -1 >funny_name.patch &&
958 git send-email --from="Example <nobody@example.com>" \
959 --to=nobody@example.com \
960 --smtp-server="$(pwd)/fake.sendmail" \
962 grep "^From: Füñný Nâmé <odd_?=mail@example.com>" msgtxt1
965 test_expect_success
$PREREQ 'utf8 sender is not duplicated' '
966 clean_fake_sendmail &&
967 test_commit weird_sender &&
968 test_when_finished "git reset --hard HEAD^" &&
969 git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" &&
970 git format-patch --stdout -1 >funny_name.patch &&
971 git send-email --from="Füñný Nâmé <odd_?=mail@example.com>" \
972 --to=nobody@example.com \
973 --smtp-server="$(pwd)/fake.sendmail" \
975 grep "^From: " msgtxt1 >msgfrom &&
976 test_line_count = 1 msgfrom
979 test_expect_success
$PREREQ 'sendemail.composeencoding works' '
980 clean_fake_sendmail &&
981 git config sendemail.composeencoding iso-8859-1 &&
982 (echo "#!$SHELL_PATH" &&
983 echo "echo utf8 body: àéìöú >>\"\$1\""
984 ) >fake-editor-utf8 &&
985 chmod +x fake-editor-utf8 &&
986 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
988 --compose --subject foo \
989 --from="Example <nobody@example.com>" \
990 --to=nobody@example.com \
991 --smtp-server="$(pwd)/fake.sendmail" \
993 grep "^utf8 body" msgtxt1 &&
994 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1
997 test_expect_success
$PREREQ '--compose-encoding works' '
998 clean_fake_sendmail &&
999 (echo "#!$SHELL_PATH" &&
1000 echo "echo utf8 body: àéìöú >>\"\$1\""
1001 ) >fake-editor-utf8 &&
1002 chmod +x fake-editor-utf8 &&
1003 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
1005 --compose-encoding iso-8859-1 \
1006 --compose --subject foo \
1007 --from="Example <nobody@example.com>" \
1008 --to=nobody@example.com \
1009 --smtp-server="$(pwd)/fake.sendmail" \
1011 grep "^utf8 body" msgtxt1 &&
1012 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1
1015 test_expect_success
$PREREQ '--compose-encoding overrides sendemail.composeencoding' '
1016 clean_fake_sendmail &&
1017 git config sendemail.composeencoding iso-8859-1 &&
1018 (echo "#!$SHELL_PATH" &&
1019 echo "echo utf8 body: àéìöú >>\"\$1\""
1020 ) >fake-editor-utf8 &&
1021 chmod +x fake-editor-utf8 &&
1022 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
1024 --compose-encoding iso-8859-2 \
1025 --compose --subject foo \
1026 --from="Example <nobody@example.com>" \
1027 --to=nobody@example.com \
1028 --smtp-server="$(pwd)/fake.sendmail" \
1030 grep "^utf8 body" msgtxt1 &&
1031 grep "^Content-Type: text/plain; charset=iso-8859-2" msgtxt1
1034 test_expect_success
$PREREQ '--compose-encoding adds correct MIME for subject' '
1035 clean_fake_sendmail &&
1036 GIT_EDITOR="\"$(pwd)/fake-editor\"" \
1038 --compose-encoding iso-8859-2 \
1039 --compose --subject utf8-sübjëct \
1040 --from="Example <nobody@example.com>" \
1041 --to=nobody@example.com \
1042 --smtp-server="$(pwd)/fake.sendmail" \
1044 grep "^fake edit" msgtxt1 &&
1045 grep "^Subject: =?iso-8859-2?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
1048 test_expect_success
$PREREQ 'detects ambiguous reference/file conflict' '
1049 echo master > master &&
1051 git commit -m"add master" &&
1052 test_must_fail git send-email --dry-run master 2>errors &&
1053 grep disambiguate errors
1056 test_expect_success
$PREREQ 'feed two files' '
1058 git format-patch -2 -o outdir &&
1061 --from="Example <nobody@example.com>" \
1062 --to=nobody@example.com \
1063 outdir/000?-*.patch 2>errors >out &&
1064 grep "^Subject: " out >subjects &&
1065 test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." &&
1066 test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add master"
1069 test_expect_success
$PREREQ 'in-reply-to but no threading' '
1072 --from="Example <nobody@example.com>" \
1073 --to=nobody@example.com \
1074 --in-reply-to="<in-reply-id@example.com>" \
1077 grep "In-Reply-To: <in-reply-id@example.com>"
1080 test_expect_success
$PREREQ 'no in-reply-to and no threading' '
1083 --from="Example <nobody@example.com>" \
1084 --to=nobody@example.com \
1086 $patches $patches >stdout &&
1087 ! grep "In-Reply-To: " stdout
1090 test_expect_success
$PREREQ 'threading but no chain-reply-to' '
1093 --from="Example <nobody@example.com>" \
1094 --to=nobody@example.com \
1096 --nochain-reply-to \
1097 $patches $patches >stdout &&
1098 grep "In-Reply-To: " stdout
1101 test_expect_success
$PREREQ 'sendemail.to works' '
1102 git config --replace-all sendemail.to "Somebody <somebody@ex.com>" &&
1105 --from="Example <nobody@example.com>" \
1106 $patches $patches >stdout &&
1107 grep "To: Somebody <somebody@ex.com>" stdout
1110 test_expect_success
$PREREQ '--no-to overrides sendemail.to' '
1113 --from="Example <nobody@example.com>" \
1115 --to=nobody@example.com \
1116 $patches $patches >stdout &&
1117 grep "To: nobody@example.com" stdout &&
1118 ! grep "To: Somebody <somebody@ex.com>" stdout
1121 test_expect_success
$PREREQ 'sendemail.cc works' '
1122 git config --replace-all sendemail.cc "Somebody <somebody@ex.com>" &&
1125 --from="Example <nobody@example.com>" \
1126 --to=nobody@example.com \
1127 $patches $patches >stdout &&
1128 grep "Cc: Somebody <somebody@ex.com>" stdout
1131 test_expect_success
$PREREQ '--no-cc overrides sendemail.cc' '
1134 --from="Example <nobody@example.com>" \
1136 --cc=bodies@example.com \
1137 --to=nobody@example.com \
1138 $patches $patches >stdout &&
1139 grep "Cc: bodies@example.com" stdout &&
1140 ! grep "Cc: Somebody <somebody@ex.com>" stdout
1143 test_expect_success
$PREREQ 'sendemail.bcc works' '
1144 git config --replace-all sendemail.bcc "Other <other@ex.com>" &&
1147 --from="Example <nobody@example.com>" \
1148 --to=nobody@example.com \
1149 --smtp-server relay.example.com \
1150 $patches $patches >stdout &&
1151 grep "RCPT TO:<other@ex.com>" stdout
1154 test_expect_success
$PREREQ '--no-bcc overrides sendemail.bcc' '
1157 --from="Example <nobody@example.com>" \
1159 --bcc=bodies@example.com \
1160 --to=nobody@example.com \
1161 --smtp-server relay.example.com \
1162 $patches $patches >stdout &&
1163 grep "RCPT TO:<bodies@example.com>" stdout &&
1164 ! grep "RCPT TO:<other@ex.com>" stdout
1167 test_expect_success
$PREREQ 'patches To headers are used by default' '
1168 patch=`git format-patch -1 --to="bodies@example.com"` &&
1169 test_when_finished "rm $patch" &&
1172 --from="Example <nobody@example.com>" \
1173 --smtp-server relay.example.com \
1175 grep "RCPT TO:<bodies@example.com>" stdout
1178 test_expect_success
$PREREQ 'patches To headers are appended to' '
1179 patch=`git format-patch -1 --to="bodies@example.com"` &&
1180 test_when_finished "rm $patch" &&
1183 --from="Example <nobody@example.com>" \
1184 --to=nobody@example.com \
1185 --smtp-server relay.example.com \
1187 grep "RCPT TO:<bodies@example.com>" stdout &&
1188 grep "RCPT TO:<nobody@example.com>" stdout
1191 test_expect_success
$PREREQ 'To headers from files reset each patch' '
1192 patch1=`git format-patch -1 --to="bodies@example.com"` &&
1193 patch2=`git format-patch -1 --to="other@example.com" HEAD~` &&
1194 test_when_finished "rm $patch1 && rm $patch2" &&
1197 --from="Example <nobody@example.com>" \
1198 --to="nobody@example.com" \
1199 --smtp-server relay.example.com \
1200 $patch1 $patch2 >stdout &&
1201 test $(grep -c "RCPT TO:<bodies@example.com>" stdout) = 1 &&
1202 test $(grep -c "RCPT TO:<nobody@example.com>" stdout) = 2 &&
1203 test $(grep -c "RCPT TO:<other@example.com>" stdout) = 1
1206 test_expect_success
$PREREQ 'setup expect' '
1207 cat >email-using-8bit <<EOF
1208 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1209 Message-Id: <bogus-message-id@example.com>
1210 From: author@example.com
1211 Date: Sat, 12 Jun 2010 15:53:58 +0200
1212 Subject: subject goes here
1214 Dieser deutsche Text enthält einen Umlaut!
1218 test_expect_success
$PREREQ 'setup expect' '
1220 Subject: subject goes here
1224 test_expect_success
$PREREQ 'ASCII subject is not RFC2047 quoted' '
1225 clean_fake_sendmail &&
1227 git send-email --from=author@example.com --to=nobody@example.com \
1228 --smtp-server="$(pwd)/fake.sendmail" \
1229 --8bit-encoding=UTF-8 \
1230 email-using-8bit >stdout &&
1231 grep "Subject" msgtxt1 >actual &&
1232 test_cmp expected actual
1235 test_expect_success
$PREREQ 'setup expect' '
1236 cat >content-type-decl <<EOF
1238 Content-Type: text/plain; charset=UTF-8
1239 Content-Transfer-Encoding: 8bit
1243 test_expect_success
$PREREQ 'asks about and fixes 8bit encodings' '
1244 clean_fake_sendmail &&
1246 git send-email --from=author@example.com --to=nobody@example.com \
1247 --smtp-server="$(pwd)/fake.sendmail" \
1248 email-using-8bit >stdout &&
1249 grep "do not declare a Content-Transfer-Encoding" stdout &&
1250 grep email-using-8bit stdout &&
1251 grep "Which 8bit encoding" stdout &&
1252 egrep "Content|MIME" msgtxt1 >actual &&
1253 test_cmp actual content-type-decl
1256 test_expect_success
$PREREQ 'sendemail.8bitEncoding works' '
1257 clean_fake_sendmail &&
1258 git config sendemail.assume8bitEncoding UTF-8 &&
1260 git send-email --from=author@example.com --to=nobody@example.com \
1261 --smtp-server="$(pwd)/fake.sendmail" \
1262 email-using-8bit >stdout &&
1263 egrep "Content|MIME" msgtxt1 >actual &&
1264 test_cmp actual content-type-decl
1267 test_expect_success
$PREREQ '--8bit-encoding overrides sendemail.8bitEncoding' '
1268 clean_fake_sendmail &&
1269 git config sendemail.assume8bitEncoding "bogus too" &&
1271 git send-email --from=author@example.com --to=nobody@example.com \
1272 --smtp-server="$(pwd)/fake.sendmail" \
1273 --8bit-encoding=UTF-8 \
1274 email-using-8bit >stdout &&
1275 egrep "Content|MIME" msgtxt1 >actual &&
1276 test_cmp actual content-type-decl
1279 test_expect_success
$PREREQ 'setup expect' '
1280 cat >email-using-8bit <<EOF
1281 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1282 Message-Id: <bogus-message-id@example.com>
1283 From: author@example.com
1284 Date: Sat, 12 Jun 2010 15:53:58 +0200
1285 Subject: Dieser Betreff enthält auch einen Umlaut!
1287 Nothing to see here.
1291 test_expect_success
$PREREQ 'setup expect' '
1293 Subject: =?UTF-8?q?Dieser=20Betreff=20enth=C3=A4lt=20auch=20einen=20Umlaut!?=
1297 test_expect_success
$PREREQ '--8bit-encoding also treats subject' '
1298 clean_fake_sendmail &&
1300 git send-email --from=author@example.com --to=nobody@example.com \
1301 --smtp-server="$(pwd)/fake.sendmail" \
1302 --8bit-encoding=UTF-8 \
1303 email-using-8bit >stdout &&
1304 grep "Subject" msgtxt1 >actual &&
1305 test_cmp expected actual
1308 # Note that the patches in this test are deliberately out of order; we
1309 # want to make sure it works even if the cover-letter is not in the
1311 test_expect_success
$PREREQ 'refusing to send cover letter template' '
1312 clean_fake_sendmail &&
1314 git format-patch --cover-letter -2 -o outdir &&
1315 test_must_fail git send-email \
1316 --from="Example <nobody@example.com>" \
1317 --to=nobody@example.com \
1318 --smtp-server="$(pwd)/fake.sendmail" \
1319 outdir/0002-*.patch \
1320 outdir/0000-*.patch \
1321 outdir/0001-*.patch \
1323 grep "SUBJECT HERE" errors &&
1324 test -z "$(ls msgtxt*)"
1327 test_expect_success
$PREREQ '--force sends cover letter template anyway' '
1328 clean_fake_sendmail &&
1330 git format-patch --cover-letter -2 -o outdir &&
1333 --from="Example <nobody@example.com>" \
1334 --to=nobody@example.com \
1335 --smtp-server="$(pwd)/fake.sendmail" \
1336 outdir/0002-*.patch \
1337 outdir/0000-*.patch \
1338 outdir/0001-*.patch \
1340 ! grep "SUBJECT HERE" errors &&
1341 test -n "$(ls msgtxt*)"
1344 test_expect_success
$PREREQ 'sendemail.aliasfiletype=mailrc' '
1345 clean_fake_sendmail &&
1346 echo "alias sbd somebody@example.org" >.mailrc &&
1347 git config --replace-all sendemail.aliasesfile "$(pwd)/.mailrc" &&
1348 git config sendemail.aliasfiletype mailrc &&
1350 --from="Example <nobody@example.com>" \
1352 --smtp-server="$(pwd)/fake.sendmail" \
1353 outdir/0001-*.patch \
1355 grep "^!somebody@example\.org!$" commandline1
1358 test_expect_success
$PREREQ 'sendemail.aliasfile=~/.mailrc' '
1359 clean_fake_sendmail &&
1360 echo "alias sbd someone@example.org" >~/.mailrc &&
1361 git config --replace-all sendemail.aliasesfile "~/.mailrc" &&
1362 git config sendemail.aliasfiletype mailrc &&
1364 --from="Example <nobody@example.com>" \
1366 --smtp-server="$(pwd)/fake.sendmail" \
1367 outdir/0001-*.patch \
1369 grep "^!someone@example\.org!$" commandline1