Merge branch 'bb/iso-strict-utc'
[alt-git.git] / t / t9001-send-email.sh
blob5a771000c9ca0de56bf21e4d8212a6581727b189
1 #!/bin/sh
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
8 . ./test-lib.sh
10 # May be altered later in the test
11 PREREQ="PERL"
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 &&
22 git add 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 &&
28 shift
29 output=1
30 while test -f commandline$output
32 output=$(($output+1))
33 done
34 for a
36 echo "!$a!"
37 done >commandline$output
38 cat >"msgtxt$output"
39 EOF
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 --thread=shallow -s --in-reply-to="format" HEAD^1)
53 # Test no confirm early to ensure remaining tests will not hang
54 test_no_confirm () {
55 rm -f no_confirm_okay
56 echo n | \
57 GIT_SEND_EMAIL_NOTTY=1 \
58 git send-email \
59 --from="Example <from@example.com>" \
60 --to=nobody@example.com \
61 --smtp-server="$(pwd)/fake.sendmail" \
62 $@ \
63 $patches >stdout &&
64 ! grep "Send this email" stdout &&
65 >no_confirm_okay
68 # Exit immediately to prevent hang if a no-confirm test fails
69 check_no_confirm () {
70 if ! test -f no_confirm_okay
71 then
72 say 'confirm test failed; skipping remaining tests to prevent hanging'
73 PREREQ="$PREREQ,CHECK_NO_CONFIRM"
75 return 0
78 test_expect_success $PREREQ 'No confirm with --suppress-cc' '
79 test_no_confirm --suppress-cc=sob &&
80 check_no_confirm
84 test_expect_success $PREREQ 'No confirm with --confirm=never' '
85 test_no_confirm --confirm=never &&
86 check_no_confirm
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 &&
94 check_no_confirm
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
103 !nobody@example.com!
104 !author@example.com!
105 !one@example.com!
106 !two@example.com!
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
121 !patch@example.com!
122 !-i!
123 !nobody@example.com!
124 !author@example.com!
125 !one@example.com!
126 !two@example.com!
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
141 !nobody@example.com!
142 !-i!
143 !nobody@example.com!
144 !author@example.com!
145 !one@example.com!
146 !two@example.com!
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!
157 !author@example.com!
158 !one@example.com!
159 !two@example.com!
160 !three@example.com!
161 !four@example.com!
162 !five@example.com!
163 !six@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 &&
171 Test Cc: trailers.
173 Cc: one@example.com
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
207 0001-Second.patch
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'
211 Dry-OK. Log says:
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>
221 To: to@example.com
222 Cc: cc@example.com,
223 A <author@example.com>,
224 One <one@example.com>,
225 two@example.com
226 Subject: [PATCH 1/1] Second.
227 Date: DATE-STRING
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>
233 MIME-Version: 1.0
234 Content-Transfer-Encoding: 8bit
236 Result: OK
240 test_suppress_self () {
241 test_commit $3 &&
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 \
255 --suppress-cc=self \
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
270 unquoted-$3
272 cccmd--$1 <$2>
274 Cc: $1 <$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
283 quoted-$3
285 cccmd--"$1" <$2>
287 Cc: $1 <$2>
288 Cc: "$1" <$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' '
322 git send-email \
323 --dry-run \
324 --suppress-cc=sob \
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" \
343 $patches \
344 2>errors &&
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_grep "tell me who you are" errors
378 test_expect_success $PREREQ 'setup cmd 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"
385 write_script headercmd-sed <<-\EOF
386 sed -n -e "s/^headercmd--//p" "$1"
390 test_expect_success $PREREQ 'tocmd works' '
391 clean_fake_sendmail &&
392 cp $patches tocmd.patch &&
393 echo tocmd--tocmd@example.com >>tocmd.patch &&
394 git send-email \
395 --from="Example <nobody@example.com>" \
396 --to-cmd=./tocmd-sed \
397 --smtp-server="$(pwd)/fake.sendmail" \
398 tocmd.patch \
400 grep "^To: tocmd@example.com" msgtxt1
403 test_expect_success $PREREQ 'cccmd works' '
404 clean_fake_sendmail &&
405 cp $patches cccmd.patch &&
406 echo "cccmd-- cccmd@example.com" >>cccmd.patch &&
407 git send-email \
408 --from="Example <nobody@example.com>" \
409 --to=nobody@example.com \
410 --cc-cmd=./cccmd-sed \
411 --smtp-server="$(pwd)/fake.sendmail" \
412 cccmd.patch \
414 grep "^ cccmd@example.com" msgtxt1
417 test_expect_success $PREREQ 'headercmd works' '
418 clean_fake_sendmail &&
419 cp $patches headercmd.patch &&
420 echo "headercmd--X-Debbugs-CC: dummy@example.com" >>headercmd.patch &&
421 git send-email \
422 --from="Example <nobody@example.com>" \
423 --to=nobody@example.com \
424 --header-cmd=./headercmd-sed \
425 --smtp-server="$(pwd)/fake.sendmail" \
426 headercmd.patch \
428 grep "^X-Debbugs-CC: dummy@example.com" msgtxt1
431 test_expect_success $PREREQ '--no-header-cmd works' '
432 clean_fake_sendmail &&
433 cp $patches headercmd.patch &&
434 echo "headercmd--X-Debbugs-CC: dummy@example.com" >>headercmd.patch &&
435 git send-email \
436 --from="Example <nobody@example.com>" \
437 --to=nobody@example.com \
438 --header-cmd=./headercmd-sed \
439 --no-header-cmd \
440 --smtp-server="$(pwd)/fake.sendmail" \
441 headercmd.patch \
443 ! grep "^X-Debbugs-CC: dummy@example.com" msgtxt1
446 test_expect_success $PREREQ 'multiline fields are correctly unfolded' '
447 clean_fake_sendmail &&
448 cp $patches headercmd.patch &&
449 write_script headercmd-multiline <<-\EOF &&
450 echo "X-Debbugs-CC: someone@example.com
451 FoldedField: This is a tale
452 best told using
453 multiple lines."
455 git send-email \
456 --from="Example <nobody@example.com>" \
457 --to=nobody@example.com \
458 --header-cmd=./headercmd-multiline \
459 --smtp-server="$(pwd)/fake.sendmail" \
460 headercmd.patch &&
461 grep "^FoldedField: This is a tale best told using multiple lines.$" msgtxt1
464 # Blank lines in the middle of the output of a command are invalid.
465 test_expect_success $PREREQ 'malform output reported on blank lines in command output' '
466 clean_fake_sendmail &&
467 cp $patches headercmd.patch &&
468 write_script headercmd-malformed-output <<-\EOF &&
469 echo "X-Debbugs-CC: someone@example.com
471 SomeOtherField: someone-else@example.com"
473 ! git send-email \
474 --from="Example <nobody@example.com>" \
475 --to=nobody@example.com \
476 --header-cmd=./headercmd-malformed-output \
477 --smtp-server="$(pwd)/fake.sendmail" \
478 headercmd.patch
481 test_expect_success $PREREQ 'reject long lines' '
482 z8=zzzzzzzz &&
483 z64=$z8$z8$z8$z8$z8$z8$z8$z8 &&
484 z512=$z64$z64$z64$z64$z64$z64$z64$z64 &&
485 clean_fake_sendmail &&
486 cp $patches longline.patch &&
487 cat >>longline.patch <<-EOF &&
488 $z512$z512
489 not a long line
490 $z512$z512
492 test_must_fail git send-email \
493 --from="Example <nobody@example.com>" \
494 --to=nobody@example.com \
495 --smtp-server="$(pwd)/fake.sendmail" \
496 --transfer-encoding=8bit \
497 $patches longline.patch \
498 2>actual &&
499 cat >expect <<-\EOF &&
500 fatal: longline.patch:35 is longer than 998 characters
501 warning: no patches were sent
503 test_cmp expect actual
506 test_expect_success $PREREQ 'no patch was sent' '
507 ! test -e commandline1
510 test_expect_success $PREREQ 'Author From: in message body' '
511 clean_fake_sendmail &&
512 git send-email \
513 --from="Example <nobody@example.com>" \
514 --to=nobody@example.com \
515 --smtp-server="$(pwd)/fake.sendmail" \
516 $patches &&
517 sed "1,/^\$/d" <msgtxt1 >msgbody1 &&
518 grep "From: A <author@example.com>" msgbody1
521 test_expect_success $PREREQ 'Author From: not in message body' '
522 clean_fake_sendmail &&
523 git send-email \
524 --from="A <author@example.com>" \
525 --to=nobody@example.com \
526 --smtp-server="$(pwd)/fake.sendmail" \
527 $patches &&
528 sed "1,/^\$/d" <msgtxt1 >msgbody1 &&
529 ! grep "From: A <author@example.com>" msgbody1
532 test_expect_success $PREREQ 'allow long lines with --no-validate' '
533 git send-email \
534 --from="Example <nobody@example.com>" \
535 --to=nobody@example.com \
536 --smtp-server="$(pwd)/fake.sendmail" \
537 --no-validate \
538 $patches longline.patch \
539 2>errors
542 test_expect_success $PREREQ 'short lines with auto encoding are 8bit' '
543 clean_fake_sendmail &&
544 git send-email \
545 --from="A <author@example.com>" \
546 --to=nobody@example.com \
547 --smtp-server="$(pwd)/fake.sendmail" \
548 --transfer-encoding=auto \
549 $patches &&
550 grep "Content-Transfer-Encoding: 8bit" msgtxt1
553 test_expect_success $PREREQ 'long lines with auto encoding are quoted-printable' '
554 clean_fake_sendmail &&
555 git send-email \
556 --from="Example <nobody@example.com>" \
557 --to=nobody@example.com \
558 --smtp-server="$(pwd)/fake.sendmail" \
559 --transfer-encoding=auto \
560 --no-validate \
561 longline.patch &&
562 grep "Content-Transfer-Encoding: quoted-printable" msgtxt1
565 test_expect_success $PREREQ 'carriage returns with auto encoding are quoted-printable' '
566 clean_fake_sendmail &&
567 cp $patches cr.patch &&
568 printf "this is a line\r\n" >>cr.patch &&
569 git send-email \
570 --from="Example <nobody@example.com>" \
571 --to=nobody@example.com \
572 --smtp-server="$(pwd)/fake.sendmail" \
573 --transfer-encoding=auto \
574 --no-validate \
575 cr.patch &&
576 grep "Content-Transfer-Encoding: quoted-printable" msgtxt1
579 for enc in auto quoted-printable base64
581 test_expect_success $PREREQ "--validate passes with encoding $enc" '
582 git send-email \
583 --from="Example <nobody@example.com>" \
584 --to=nobody@example.com \
585 --smtp-server="$(pwd)/fake.sendmail" \
586 --transfer-encoding=$enc \
587 --validate \
588 $patches longline.patch
591 done
593 test_expect_success $PREREQ "--validate respects relative core.hooksPath path" '
594 clean_fake_sendmail &&
595 mkdir my-hooks &&
596 test_when_finished "rm my-hooks.ran" &&
597 write_script my-hooks/sendemail-validate <<-\EOF &&
598 >my-hooks.ran
599 exit 1
601 test_config core.hooksPath "my-hooks" &&
602 test_must_fail git send-email \
603 --from="Example <nobody@example.com>" \
604 --to=nobody@example.com \
605 --smtp-server="$(pwd)/fake.sendmail" \
606 --validate \
607 longline.patch 2>actual &&
608 test_path_is_file my-hooks.ran &&
609 cat >expect <<-EOF &&
610 fatal: longline.patch: rejected by sendemail-validate hook
611 fatal: command '"'"'git hook run --ignore-missing sendemail-validate -- <patch> <header>'"'"' died with exit code 1
612 warning: no patches were sent
614 test_cmp expect actual
617 test_expect_success $PREREQ "--validate respects absolute core.hooksPath path" '
618 hooks_path="$(pwd)/my-hooks" &&
619 test_config core.hooksPath "$hooks_path" &&
620 test_when_finished "rm my-hooks.ran" &&
621 test_must_fail git send-email \
622 --from="Example <nobody@example.com>" \
623 --to=nobody@example.com \
624 --smtp-server="$(pwd)/fake.sendmail" \
625 --validate \
626 longline.patch 2>actual &&
627 test_path_is_file my-hooks.ran &&
628 cat >expect <<-EOF &&
629 fatal: longline.patch: rejected by sendemail-validate hook
630 fatal: command '"'"'git hook run --ignore-missing sendemail-validate -- <patch> <header>'"'"' died with exit code 1
631 warning: no patches were sent
633 test_cmp expect actual
636 test_expect_success $PREREQ "--validate hook supports multiple addresses in arguments" '
637 hooks_path="$(pwd)/my-hooks" &&
638 test_config core.hooksPath "$hooks_path" &&
639 test_when_finished "rm my-hooks.ran" &&
640 test_must_fail git send-email \
641 --from="Example <nobody@example.com>" \
642 --to=nobody@example.com,abc@example.com \
643 --smtp-server="$(pwd)/fake.sendmail" \
644 --validate \
645 longline.patch 2>actual &&
646 test_path_is_file my-hooks.ran &&
647 cat >expect <<-EOF &&
648 fatal: longline.patch: rejected by sendemail-validate hook
649 fatal: command '"'"'git hook run --ignore-missing sendemail-validate -- <patch> <header>'"'"' died with exit code 1
650 warning: no patches were sent
652 test_cmp expect actual
655 test_expect_success $PREREQ "--validate hook supports header argument" '
656 write_script my-hooks/sendemail-validate <<-\EOF &&
657 if test "$#" -ge 2
658 then
659 grep "X-test-header: v1.0" "$2"
660 else
661 echo "No header arg passed"
662 exit 1
665 test_config core.hooksPath "my-hooks" &&
666 rm -fr outdir &&
667 git format-patch \
668 --add-header="X-test-header: v1.0" \
669 -n HEAD^1 -o outdir &&
670 git send-email \
671 --dry-run \
672 --to=nobody@example.com \
673 --smtp-server="$(pwd)/fake.sendmail" \
674 --validate \
675 outdir/000?-*.patch
678 test_expect_success $PREREQ 'clear message-id before parsing a new message' '
679 clean_fake_sendmail &&
680 echo true | write_script my-hooks/sendemail-validate &&
681 test_config core.hooksPath my-hooks &&
682 git send-email --validate --to=recipient@example.com \
683 --smtp-server="$(pwd)/fake.sendmail" \
684 $patches $threaded_patches &&
685 id0=$(grep "^Message-ID: " $threaded_patches) &&
686 id1=$(grep "^Message-ID: " msgtxt1) &&
687 id2=$(grep "^Message-ID: " msgtxt2) &&
688 test "z$id0" = "z$id2" &&
689 test "z$id1" != "z$id2"
692 for enc in 7bit 8bit quoted-printable base64
694 test_expect_success $PREREQ "--transfer-encoding=$enc produces correct header" '
695 clean_fake_sendmail &&
696 git send-email \
697 --from="Example <nobody@example.com>" \
698 --to=nobody@example.com \
699 --smtp-server="$(pwd)/fake.sendmail" \
700 --transfer-encoding=$enc \
701 $patches &&
702 grep "Content-Transfer-Encoding: $enc" msgtxt1
704 done
706 test_expect_success $PREREQ 'Invalid In-Reply-To' '
707 clean_fake_sendmail &&
708 git send-email \
709 --from="Example <nobody@example.com>" \
710 --to=nobody@example.com \
711 --in-reply-to=" " \
712 --smtp-server="$(pwd)/fake.sendmail" \
713 $patches \
714 2>errors &&
715 ! grep "^In-Reply-To: < *>" msgtxt1
718 test_expect_success $PREREQ 'Valid In-Reply-To when prompting' '
719 clean_fake_sendmail &&
720 (echo "From Example <from@example.com>" &&
721 echo "To Example <to@example.com>" &&
722 echo ""
723 ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
724 --smtp-server="$(pwd)/fake.sendmail" \
725 $patches 2>errors &&
726 ! grep "^In-Reply-To: < *>" msgtxt1
729 test_expect_success $PREREQ 'In-Reply-To without --chain-reply-to' '
730 clean_fake_sendmail &&
731 echo "<unique-message-id@example.com>" >expect &&
732 git send-email \
733 --from="Example <nobody@example.com>" \
734 --to=nobody@example.com \
735 --no-chain-reply-to \
736 --in-reply-to="$(cat expect)" \
737 --smtp-server="$(pwd)/fake.sendmail" \
738 $patches $patches $patches \
739 2>errors &&
740 # The first message is a reply to --in-reply-to
741 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual &&
742 test_cmp expect actual &&
743 # Second and subsequent messages are replies to the first one
744 sed -n -e "s/^Message-ID: *\(.*\)/\1/p" msgtxt1 >expect &&
745 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual &&
746 test_cmp expect actual &&
747 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual &&
748 test_cmp expect actual
751 test_expect_success $PREREQ 'In-Reply-To with --chain-reply-to' '
752 clean_fake_sendmail &&
753 echo "<unique-message-id@example.com>" >expect &&
754 git send-email \
755 --from="Example <nobody@example.com>" \
756 --to=nobody@example.com \
757 --chain-reply-to \
758 --in-reply-to="$(cat expect)" \
759 --smtp-server="$(pwd)/fake.sendmail" \
760 $patches $patches $patches \
761 2>errors &&
762 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual &&
763 test_cmp expect actual &&
764 sed -n -e "s/^Message-ID: *\(.*\)/\1/p" msgtxt1 >expect &&
765 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual &&
766 test_cmp expect actual &&
767 sed -n -e "s/^Message-ID: *\(.*\)/\1/p" msgtxt2 >expect &&
768 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual &&
769 test_cmp expect actual
772 test_set_editor "$(pwd)/fake-editor"
774 test_expect_success $PREREQ 'setup erroring fake editor' '
775 write_script fake-editor <<-\EOF
776 echo >&2 "I am about to error"
777 exit 1
781 test_expect_success $PREREQ 'fake editor dies with error' '
782 clean_fake_sendmail &&
783 test_must_fail git send-email \
784 --compose --subject foo \
785 --from="Example <nobody@example.com>" \
786 --to=nobody@example.com \
787 --smtp-server="$(pwd)/fake.sendmail" \
788 $patches 2>err &&
789 grep "I am about to error" err &&
790 grep "the editor exited uncleanly, aborting everything" err
793 test_expect_success $PREREQ 'setup fake editor' '
794 write_script fake-editor <<-\EOF
795 echo fake edit >>"$1"
799 test_expect_success $PREREQ '--compose works' '
800 clean_fake_sendmail &&
801 git send-email \
802 --compose --subject foo \
803 --from="Example <nobody@example.com>" \
804 --to=nobody@example.com \
805 --smtp-server="$(pwd)/fake.sendmail" \
806 $patches \
807 2>errors
810 test_expect_success $PREREQ 'first message is compose text' '
811 grep "^fake edit" msgtxt1
814 test_expect_success $PREREQ 'second message is patch' '
815 grep "Subject:.*Second" msgtxt2
818 test_expect_success $PREREQ 'setup expect' "
819 cat >expected-suppress-sob <<\EOF
820 0001-Second.patch
821 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
822 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
823 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
824 Dry-OK. Log says:
825 Server: relay.example.com
826 MAIL FROM:<from@example.com>
827 RCPT TO:<to@example.com>
828 RCPT TO:<cc@example.com>
829 RCPT TO:<author@example.com>
830 RCPT TO:<one@example.com>
831 RCPT TO:<two@example.com>
832 From: Example <from@example.com>
833 To: to@example.com
834 Cc: cc@example.com,
835 A <author@example.com>,
836 One <one@example.com>,
837 two@example.com
838 Subject: [PATCH 1/1] Second.
839 Date: DATE-STRING
840 Message-ID: MESSAGE-ID-STRING
841 X-Mailer: X-MAILER-STRING
842 MIME-Version: 1.0
843 Content-Transfer-Encoding: 8bit
845 Result: OK
849 test_suppression () {
850 git send-email \
851 --dry-run \
852 --suppress-cc=$1 ${2+"--suppress-cc=$2"} \
853 --from="Example <from@example.com>" \
854 --to=to@example.com \
855 --smtp-server relay.example.com \
856 $patches | replace_variable_fields \
857 >actual-suppress-$1${2+"-$2"} &&
858 test_cmp expected-suppress-$1${2+"-$2"} actual-suppress-$1${2+"-$2"}
861 test_expect_success $PREREQ 'sendemail.cc set' '
862 git config sendemail.cc cc@example.com &&
863 test_suppression sob
866 test_expect_success $PREREQ 'setup expect' "
867 cat >expected-suppress-sob <<\EOF
868 0001-Second.patch
869 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
870 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
871 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
872 Dry-OK. Log says:
873 Server: relay.example.com
874 MAIL FROM:<from@example.com>
875 RCPT TO:<to@example.com>
876 RCPT TO:<author@example.com>
877 RCPT TO:<one@example.com>
878 RCPT TO:<two@example.com>
879 From: Example <from@example.com>
880 To: to@example.com
881 Cc: A <author@example.com>,
882 One <one@example.com>,
883 two@example.com
884 Subject: [PATCH 1/1] Second.
885 Date: DATE-STRING
886 Message-ID: MESSAGE-ID-STRING
887 X-Mailer: X-MAILER-STRING
888 MIME-Version: 1.0
889 Content-Transfer-Encoding: 8bit
891 Result: OK
895 test_expect_success $PREREQ 'sendemail.cc unset' '
896 git config --unset sendemail.cc &&
897 test_suppression sob
900 test_expect_success $PREREQ 'setup expect' "
901 cat >expected-suppress-cccmd <<\EOF
902 0001-Second.patch
903 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
904 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
905 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
906 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
907 Dry-OK. Log says:
908 Server: relay.example.com
909 MAIL FROM:<from@example.com>
910 RCPT TO:<to@example.com>
911 RCPT TO:<author@example.com>
912 RCPT TO:<one@example.com>
913 RCPT TO:<two@example.com>
914 RCPT TO:<committer@example.com>
915 From: Example <from@example.com>
916 To: to@example.com
917 Cc: A <author@example.com>,
918 One <one@example.com>,
919 two@example.com,
920 C O Mitter <committer@example.com>
921 Subject: [PATCH 1/1] Second.
922 Date: DATE-STRING
923 Message-ID: MESSAGE-ID-STRING
924 X-Mailer: X-MAILER-STRING
925 MIME-Version: 1.0
926 Content-Transfer-Encoding: 8bit
928 Result: OK
932 test_expect_success $PREREQ 'sendemail.cccmd' '
933 write_script cccmd <<-\EOF &&
934 echo cc-cmd@example.com
936 git config sendemail.cccmd ./cccmd &&
937 test_suppression cccmd
940 test_expect_success $PREREQ 'setup expect' '
941 cat >expected-suppress-all <<\EOF
942 0001-Second.patch
943 Dry-OK. Log says:
944 Server: relay.example.com
945 MAIL FROM:<from@example.com>
946 RCPT TO:<to@example.com>
947 From: Example <from@example.com>
948 To: to@example.com
949 Subject: [PATCH 1/1] Second.
950 Date: DATE-STRING
951 Message-ID: MESSAGE-ID-STRING
952 X-Mailer: X-MAILER-STRING
953 MIME-Version: 1.0
954 Content-Transfer-Encoding: 8bit
956 Result: OK
960 test_expect_success $PREREQ '--suppress-cc=all' '
961 test_suppression all
964 test_expect_success $PREREQ 'setup expect' "
965 cat >expected-suppress-body <<\EOF
966 0001-Second.patch
967 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
968 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
969 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
970 (cc-cmd) Adding cc: cc-cmd@example.com from: './cccmd'
971 Dry-OK. Log says:
972 Server: relay.example.com
973 MAIL FROM:<from@example.com>
974 RCPT TO:<to@example.com>
975 RCPT TO:<author@example.com>
976 RCPT TO:<one@example.com>
977 RCPT TO:<two@example.com>
978 RCPT TO:<cc-cmd@example.com>
979 From: Example <from@example.com>
980 To: to@example.com
981 Cc: A <author@example.com>,
982 One <one@example.com>,
983 two@example.com,
984 cc-cmd@example.com
985 Subject: [PATCH 1/1] Second.
986 Date: DATE-STRING
987 Message-ID: MESSAGE-ID-STRING
988 X-Mailer: X-MAILER-STRING
989 MIME-Version: 1.0
990 Content-Transfer-Encoding: 8bit
992 Result: OK
996 test_expect_success $PREREQ '--suppress-cc=body' '
997 test_suppression body
1000 test_expect_success $PREREQ 'setup expect' "
1001 cat >expected-suppress-body-cccmd <<\EOF
1002 0001-Second.patch
1003 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
1004 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
1005 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
1006 Dry-OK. Log says:
1007 Server: relay.example.com
1008 MAIL FROM:<from@example.com>
1009 RCPT TO:<to@example.com>
1010 RCPT TO:<author@example.com>
1011 RCPT TO:<one@example.com>
1012 RCPT TO:<two@example.com>
1013 From: Example <from@example.com>
1014 To: to@example.com
1015 Cc: A <author@example.com>,
1016 One <one@example.com>,
1017 two@example.com
1018 Subject: [PATCH 1/1] Second.
1019 Date: DATE-STRING
1020 Message-ID: MESSAGE-ID-STRING
1021 X-Mailer: X-MAILER-STRING
1022 MIME-Version: 1.0
1023 Content-Transfer-Encoding: 8bit
1025 Result: OK
1029 test_expect_success $PREREQ '--suppress-cc=body --suppress-cc=cccmd' '
1030 test_suppression body cccmd
1033 test_expect_success $PREREQ 'setup expect' "
1034 cat >expected-suppress-sob <<\EOF
1035 0001-Second.patch
1036 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
1037 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
1038 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
1039 Dry-OK. Log says:
1040 Server: relay.example.com
1041 MAIL FROM:<from@example.com>
1042 RCPT TO:<to@example.com>
1043 RCPT TO:<author@example.com>
1044 RCPT TO:<one@example.com>
1045 RCPT TO:<two@example.com>
1046 From: Example <from@example.com>
1047 To: to@example.com
1048 Cc: A <author@example.com>,
1049 One <one@example.com>,
1050 two@example.com
1051 Subject: [PATCH 1/1] Second.
1052 Date: DATE-STRING
1053 Message-ID: MESSAGE-ID-STRING
1054 X-Mailer: X-MAILER-STRING
1055 MIME-Version: 1.0
1056 Content-Transfer-Encoding: 8bit
1058 Result: OK
1062 test_expect_success $PREREQ '--suppress-cc=sob' '
1063 test_might_fail git config --unset sendemail.cccmd &&
1064 test_suppression sob
1067 test_expect_success $PREREQ 'setup expect' "
1068 cat >expected-suppress-bodycc <<\EOF
1069 0001-Second.patch
1070 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
1071 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
1072 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
1073 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
1074 Dry-OK. Log says:
1075 Server: relay.example.com
1076 MAIL FROM:<from@example.com>
1077 RCPT TO:<to@example.com>
1078 RCPT TO:<author@example.com>
1079 RCPT TO:<one@example.com>
1080 RCPT TO:<two@example.com>
1081 RCPT TO:<committer@example.com>
1082 From: Example <from@example.com>
1083 To: to@example.com
1084 Cc: A <author@example.com>,
1085 One <one@example.com>,
1086 two@example.com,
1087 C O Mitter <committer@example.com>
1088 Subject: [PATCH 1/1] Second.
1089 Date: DATE-STRING
1090 Message-ID: MESSAGE-ID-STRING
1091 X-Mailer: X-MAILER-STRING
1092 MIME-Version: 1.0
1093 Content-Transfer-Encoding: 8bit
1095 Result: OK
1099 test_expect_success $PREREQ '--suppress-cc=bodycc' '
1100 test_suppression bodycc
1103 test_expect_success $PREREQ 'setup expect' "
1104 cat >expected-suppress-cc <<\EOF
1105 0001-Second.patch
1106 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
1107 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
1108 Dry-OK. Log says:
1109 Server: relay.example.com
1110 MAIL FROM:<from@example.com>
1111 RCPT TO:<to@example.com>
1112 RCPT TO:<author@example.com>
1113 RCPT TO:<committer@example.com>
1114 From: Example <from@example.com>
1115 To: to@example.com
1116 Cc: A <author@example.com>,
1117 C O Mitter <committer@example.com>
1118 Subject: [PATCH 1/1] Second.
1119 Date: DATE-STRING
1120 Message-ID: MESSAGE-ID-STRING
1121 X-Mailer: X-MAILER-STRING
1122 MIME-Version: 1.0
1123 Content-Transfer-Encoding: 8bit
1125 Result: OK
1129 test_expect_success $PREREQ '--suppress-cc=cc' '
1130 test_suppression cc
1133 test_confirm () {
1134 echo y | \
1135 GIT_SEND_EMAIL_NOTTY=1 \
1136 git send-email \
1137 --from="Example <nobody@example.com>" \
1138 --to=nobody@example.com \
1139 --smtp-server="$(pwd)/fake.sendmail" \
1140 $@ $patches >stdout &&
1141 grep "Send this email" stdout
1144 test_expect_success $PREREQ '--confirm=always' '
1145 test_confirm --confirm=always --suppress-cc=all
1148 test_expect_success $PREREQ '--confirm=auto' '
1149 test_confirm --confirm=auto
1152 test_expect_success $PREREQ '--confirm=cc' '
1153 test_confirm --confirm=cc
1156 test_expect_success $PREREQ '--confirm=compose' '
1157 test_confirm --confirm=compose --compose
1160 test_expect_success $PREREQ 'confirm by default (due to cc)' '
1161 test_when_finished git config sendemail.confirm never &&
1162 git config --unset sendemail.confirm &&
1163 test_confirm
1166 test_expect_success $PREREQ 'confirm by default (due to --compose)' '
1167 test_when_finished git config sendemail.confirm never &&
1168 git config --unset sendemail.confirm &&
1169 test_confirm --suppress-cc=all --compose
1172 test_expect_success $PREREQ 'confirm detects EOF (inform assumes y)' '
1173 test_when_finished git config sendemail.confirm never &&
1174 git config --unset sendemail.confirm &&
1175 rm -fr outdir &&
1176 git format-patch -2 -o outdir &&
1177 GIT_SEND_EMAIL_NOTTY=1 \
1178 git send-email \
1179 --from="Example <nobody@example.com>" \
1180 --to=nobody@example.com \
1181 --smtp-server="$(pwd)/fake.sendmail" \
1182 outdir/*.patch </dev/null
1185 test_expect_success $PREREQ 'confirm detects EOF (auto causes failure)' '
1186 test_when_finished git config sendemail.confirm never &&
1187 git config sendemail.confirm auto &&
1188 GIT_SEND_EMAIL_NOTTY=1 &&
1189 export GIT_SEND_EMAIL_NOTTY &&
1190 test_must_fail git send-email \
1191 --from="Example <nobody@example.com>" \
1192 --to=nobody@example.com \
1193 --smtp-server="$(pwd)/fake.sendmail" \
1194 $patches </dev/null
1197 test_expect_success $PREREQ 'confirm does not loop forever' '
1198 test_when_finished git config sendemail.confirm never &&
1199 git config sendemail.confirm auto &&
1200 GIT_SEND_EMAIL_NOTTY=1 &&
1201 export GIT_SEND_EMAIL_NOTTY &&
1202 yes "bogus" | test_must_fail git send-email \
1203 --from="Example <nobody@example.com>" \
1204 --to=nobody@example.com \
1205 --smtp-server="$(pwd)/fake.sendmail" \
1206 $patches
1209 test_expect_success $PREREQ 'utf8 Cc is rfc2047 encoded' '
1210 clean_fake_sendmail &&
1211 rm -fr outdir &&
1212 git format-patch -1 -o outdir --cc="àéìöú <utf8@example.com>" &&
1213 git send-email \
1214 --from="Example <nobody@example.com>" \
1215 --to=nobody@example.com \
1216 --smtp-server="$(pwd)/fake.sendmail" \
1217 outdir/*.patch &&
1218 grep "^ " msgtxt1 |
1219 grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>"
1222 test_expect_success $PREREQ '--compose adds MIME for utf8 body' '
1223 clean_fake_sendmail &&
1224 write_script fake-editor-utf8 <<-\EOF &&
1225 echo "utf8 body: àéìöú" >>"$1"
1227 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
1228 git send-email \
1229 --compose --subject foo \
1230 --from="Example <nobody@example.com>" \
1231 --to=nobody@example.com \
1232 --smtp-server="$(pwd)/fake.sendmail" \
1233 $patches &&
1234 grep "^utf8 body" msgtxt1 &&
1235 grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
1238 test_expect_success $PREREQ '--compose respects user mime type' '
1239 clean_fake_sendmail &&
1240 write_script fake-editor-utf8-mime <<-\EOF &&
1241 cat >"$1" <<-\EOM
1242 MIME-Version: 1.0
1243 Content-Type: text/plain; charset=iso-8859-1
1244 Content-Transfer-Encoding: 8bit
1245 Subject: foo
1247 utf8 body: àéìöú
1250 GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \
1251 git send-email \
1252 --compose --subject foo \
1253 --from="Example <nobody@example.com>" \
1254 --to=nobody@example.com \
1255 --smtp-server="$(pwd)/fake.sendmail" \
1256 $patches &&
1257 grep "^utf8 body" msgtxt1 &&
1258 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 &&
1259 ! grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
1262 test_expect_success $PREREQ '--compose adds MIME for utf8 subject' '
1263 clean_fake_sendmail &&
1264 GIT_EDITOR="\"$(pwd)/fake-editor\"" \
1265 git send-email \
1266 --compose --subject utf8-sübjëct \
1267 --from="Example <nobody@example.com>" \
1268 --to=nobody@example.com \
1269 --smtp-server="$(pwd)/fake.sendmail" \
1270 $patches &&
1271 grep "^fake edit" msgtxt1 &&
1272 grep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
1275 test_expect_success $PREREQ 'utf8 author is correctly passed on' '
1276 clean_fake_sendmail &&
1277 test_commit weird_author &&
1278 test_when_finished "git reset --hard HEAD^" &&
1279 git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" &&
1280 git format-patch --stdout -1 >funny_name.patch &&
1281 git send-email --from="Example <nobody@example.com>" \
1282 --to=nobody@example.com \
1283 --smtp-server="$(pwd)/fake.sendmail" \
1284 funny_name.patch &&
1285 grep "^From: Füñný Nâmé <odd_?=mail@example.com>" msgtxt1
1288 test_expect_success $PREREQ 'utf8 sender is not duplicated' '
1289 clean_fake_sendmail &&
1290 test_commit weird_sender &&
1291 test_when_finished "git reset --hard HEAD^" &&
1292 git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" &&
1293 git format-patch --stdout -1 >funny_name.patch &&
1294 git send-email --from="Füñný Nâmé <odd_?=mail@example.com>" \
1295 --to=nobody@example.com \
1296 --smtp-server="$(pwd)/fake.sendmail" \
1297 funny_name.patch &&
1298 grep "^From: " msgtxt1 >msgfrom &&
1299 test_line_count = 1 msgfrom
1302 test_expect_success $PREREQ 'sendemail.composeencoding works' '
1303 clean_fake_sendmail &&
1304 git config sendemail.composeencoding iso-8859-1 &&
1305 write_script fake-editor-utf8 <<-\EOF &&
1306 echo "utf8 body: àéìöú" >>"$1"
1308 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
1309 git send-email \
1310 --compose --subject foo \
1311 --from="Example <nobody@example.com>" \
1312 --to=nobody@example.com \
1313 --smtp-server="$(pwd)/fake.sendmail" \
1314 $patches &&
1315 grep "^utf8 body" msgtxt1 &&
1316 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1
1319 test_expect_success $PREREQ '--compose-encoding works' '
1320 clean_fake_sendmail &&
1321 write_script fake-editor-utf8 <<-\EOF &&
1322 echo "utf8 body: àéìöú" >>"$1"
1324 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
1325 git send-email \
1326 --compose-encoding iso-8859-1 \
1327 --compose --subject foo \
1328 --from="Example <nobody@example.com>" \
1329 --to=nobody@example.com \
1330 --smtp-server="$(pwd)/fake.sendmail" \
1331 $patches &&
1332 grep "^utf8 body" msgtxt1 &&
1333 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1
1336 test_expect_success $PREREQ '--compose-encoding overrides sendemail.composeencoding' '
1337 clean_fake_sendmail &&
1338 git config sendemail.composeencoding iso-8859-1 &&
1339 write_script fake-editor-utf8 <<-\EOF &&
1340 echo "utf8 body: àéìöú" >>"$1"
1342 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
1343 git send-email \
1344 --compose-encoding iso-8859-2 \
1345 --compose --subject foo \
1346 --from="Example <nobody@example.com>" \
1347 --to=nobody@example.com \
1348 --smtp-server="$(pwd)/fake.sendmail" \
1349 $patches &&
1350 grep "^utf8 body" msgtxt1 &&
1351 grep "^Content-Type: text/plain; charset=iso-8859-2" msgtxt1
1354 test_expect_success $PREREQ '--compose-encoding adds correct MIME for subject' '
1355 clean_fake_sendmail &&
1356 GIT_EDITOR="\"$(pwd)/fake-editor\"" \
1357 git send-email \
1358 --compose-encoding iso-8859-2 \
1359 --compose --subject utf8-sübjëct \
1360 --from="Example <nobody@example.com>" \
1361 --to=nobody@example.com \
1362 --smtp-server="$(pwd)/fake.sendmail" \
1363 $patches &&
1364 grep "^fake edit" msgtxt1 &&
1365 grep "^Subject: =?iso-8859-2?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
1368 test_expect_success $PREREQ 'detects ambiguous reference/file conflict' '
1369 echo main >main &&
1370 git add main &&
1371 git commit -m"add main" &&
1372 test_must_fail git send-email --dry-run main 2>errors &&
1373 grep disambiguate errors
1376 test_expect_success $PREREQ 'feed two files' '
1377 rm -fr outdir &&
1378 git format-patch -2 -o outdir &&
1379 git send-email \
1380 --dry-run \
1381 --from="Example <nobody@example.com>" \
1382 --to=nobody@example.com \
1383 outdir/000?-*.patch 2>errors >out &&
1384 grep "^Subject: " out >subjects &&
1385 test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." &&
1386 test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add main"
1389 test_expect_success $PREREQ 'in-reply-to but no threading' '
1390 git send-email \
1391 --dry-run \
1392 --from="Example <nobody@example.com>" \
1393 --to=nobody@example.com \
1394 --in-reply-to="<in-reply-id@example.com>" \
1395 --no-thread \
1396 $patches >out &&
1397 grep "In-Reply-To: <in-reply-id@example.com>" out
1400 test_expect_success $PREREQ 'no in-reply-to and no threading' '
1401 git send-email \
1402 --dry-run \
1403 --from="Example <nobody@example.com>" \
1404 --to=nobody@example.com \
1405 --no-thread \
1406 $patches >stdout &&
1407 ! grep "In-Reply-To: " stdout
1410 test_expect_success $PREREQ 'threading but no chain-reply-to' '
1411 git send-email \
1412 --dry-run \
1413 --from="Example <nobody@example.com>" \
1414 --to=nobody@example.com \
1415 --thread \
1416 --no-chain-reply-to \
1417 $patches $patches >stdout &&
1418 grep "In-Reply-To: " stdout
1421 test_expect_success $PREREQ 'override in-reply-to if no threading' '
1422 git send-email \
1423 --dry-run \
1424 --from="Example <nobody@example.com>" \
1425 --to=nobody@example.com \
1426 --no-thread \
1427 --in-reply-to="override" \
1428 $threaded_patches >stdout &&
1429 grep "In-Reply-To: <override>" stdout
1432 test_expect_success $PREREQ 'sendemail.to works' '
1433 git config --replace-all sendemail.to "Somebody <somebody@ex.com>" &&
1434 git send-email \
1435 --dry-run \
1436 --from="Example <nobody@example.com>" \
1437 $patches >stdout &&
1438 grep "To: Somebody <somebody@ex.com>" stdout
1441 test_expect_success $PREREQ 'setup sendemail.identity' '
1442 git config --replace-all sendemail.to "default@example.com" &&
1443 git config --replace-all sendemail.isp.to "isp@example.com" &&
1444 git config --replace-all sendemail.cloud.to "cloud@example.com"
1447 test_expect_success $PREREQ 'sendemail.identity: reads the correct identity config' '
1448 git -c sendemail.identity=cloud send-email \
1449 --dry-run \
1450 --from="nobody@example.com" \
1451 $patches >stdout &&
1452 grep "To: cloud@example.com" stdout
1455 test_expect_success $PREREQ 'sendemail.identity: identity overrides sendemail.identity' '
1456 git -c sendemail.identity=cloud send-email \
1457 --identity=isp \
1458 --dry-run \
1459 --from="nobody@example.com" \
1460 $patches >stdout &&
1461 grep "To: isp@example.com" stdout
1464 test_expect_success $PREREQ 'sendemail.identity: --no-identity clears previous identity' '
1465 git -c sendemail.identity=cloud send-email \
1466 --no-identity \
1467 --dry-run \
1468 --from="nobody@example.com" \
1469 $patches >stdout &&
1470 grep "To: default@example.com" stdout
1473 test_expect_success $PREREQ 'sendemail.identity: bool identity variable existence overrides' '
1474 git -c sendemail.identity=cloud \
1475 -c sendemail.xmailer=true \
1476 -c sendemail.cloud.xmailer=false \
1477 send-email \
1478 --dry-run \
1479 --from="nobody@example.com" \
1480 $patches >stdout &&
1481 grep "To: cloud@example.com" stdout &&
1482 ! grep "X-Mailer" stdout
1485 test_expect_success $PREREQ 'sendemail.identity: bool variable fallback' '
1486 git -c sendemail.identity=cloud \
1487 -c sendemail.xmailer=false \
1488 send-email \
1489 --dry-run \
1490 --from="nobody@example.com" \
1491 $patches >stdout &&
1492 grep "To: cloud@example.com" stdout &&
1493 ! grep "X-Mailer" stdout
1496 test_expect_success $PREREQ 'sendemail.identity: bool variable without a value' '
1497 git -c sendemail.xmailer \
1498 send-email \
1499 --dry-run \
1500 --from="nobody@example.com" \
1501 $patches >stdout &&
1502 grep "To: default@example.com" stdout &&
1503 grep "X-Mailer" stdout
1506 test_expect_success $PREREQ '--no-to overrides sendemail.to' '
1507 git send-email \
1508 --dry-run \
1509 --from="Example <nobody@example.com>" \
1510 --no-to \
1511 --to=nobody@example.com \
1512 $patches >stdout &&
1513 grep "To: nobody@example.com" stdout &&
1514 ! grep "To: Somebody <somebody@ex.com>" stdout
1517 test_expect_success $PREREQ 'sendemail.cc works' '
1518 git config --replace-all sendemail.cc "Somebody <somebody@ex.com>" &&
1519 git send-email \
1520 --dry-run \
1521 --from="Example <nobody@example.com>" \
1522 --to=nobody@example.com \
1523 $patches >stdout &&
1524 grep "Cc: Somebody <somebody@ex.com>" stdout
1527 test_expect_success $PREREQ '--no-cc overrides sendemail.cc' '
1528 git send-email \
1529 --dry-run \
1530 --from="Example <nobody@example.com>" \
1531 --no-cc \
1532 --cc=bodies@example.com \
1533 --to=nobody@example.com \
1534 $patches >stdout &&
1535 grep "Cc: bodies@example.com" stdout &&
1536 ! grep "Cc: Somebody <somebody@ex.com>" stdout
1539 test_expect_success $PREREQ 'sendemail.bcc works' '
1540 git config --replace-all sendemail.bcc "Other <other@ex.com>" &&
1541 git send-email \
1542 --dry-run \
1543 --from="Example <nobody@example.com>" \
1544 --to=nobody@example.com \
1545 --smtp-server relay.example.com \
1546 $patches >stdout &&
1547 grep "RCPT TO:<other@ex.com>" stdout
1550 test_expect_success $PREREQ '--no-bcc overrides sendemail.bcc' '
1551 git send-email \
1552 --dry-run \
1553 --from="Example <nobody@example.com>" \
1554 --no-bcc \
1555 --bcc=bodies@example.com \
1556 --to=nobody@example.com \
1557 --smtp-server relay.example.com \
1558 $patches >stdout &&
1559 grep "RCPT TO:<bodies@example.com>" stdout &&
1560 ! grep "RCPT TO:<other@ex.com>" stdout
1563 test_expect_success $PREREQ 'patches To headers are used by default' '
1564 patch=$(git format-patch -1 --to="bodies@example.com") &&
1565 test_when_finished "rm $patch" &&
1566 git send-email \
1567 --dry-run \
1568 --from="Example <nobody@example.com>" \
1569 --smtp-server relay.example.com \
1570 $patch >stdout &&
1571 grep "RCPT TO:<bodies@example.com>" stdout
1574 test_expect_success $PREREQ 'patches To headers are appended to' '
1575 patch=$(git format-patch -1 --to="bodies@example.com") &&
1576 test_when_finished "rm $patch" &&
1577 git send-email \
1578 --dry-run \
1579 --from="Example <nobody@example.com>" \
1580 --to=nobody@example.com \
1581 --smtp-server relay.example.com \
1582 $patch >stdout &&
1583 grep "RCPT TO:<bodies@example.com>" stdout &&
1584 grep "RCPT TO:<nobody@example.com>" stdout
1587 test_expect_success $PREREQ 'To headers from files reset each patch' '
1588 patch1=$(git format-patch -1 --to="bodies@example.com") &&
1589 patch2=$(git format-patch -1 --to="other@example.com" HEAD~) &&
1590 test_when_finished "rm $patch1 && rm $patch2" &&
1591 git send-email \
1592 --dry-run \
1593 --from="Example <nobody@example.com>" \
1594 --to="nobody@example.com" \
1595 --smtp-server relay.example.com \
1596 $patch1 $patch2 >stdout &&
1597 test $(grep -c "RCPT TO:<bodies@example.com>" stdout) = 1 &&
1598 test $(grep -c "RCPT TO:<nobody@example.com>" stdout) = 2 &&
1599 test $(grep -c "RCPT TO:<other@example.com>" stdout) = 1
1602 test_expect_success $PREREQ 'setup expect' '
1603 cat >email-using-8bit <<\EOF
1604 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1605 Message-ID: <bogus-message-id@example.com>
1606 From: author@example.com
1607 Date: Sat, 12 Jun 2010 15:53:58 +0200
1608 Subject: subject goes here
1610 Dieser deutsche Text enthält einen Umlaut!
1614 test_expect_success $PREREQ 'setup expect' '
1615 echo "Subject: subject goes here" >expected
1618 test_expect_success $PREREQ 'ASCII subject is not RFC2047 quoted' '
1619 clean_fake_sendmail &&
1620 echo bogus |
1621 git send-email --from=author@example.com --to=nobody@example.com \
1622 --smtp-server="$(pwd)/fake.sendmail" \
1623 --8bit-encoding=UTF-8 \
1624 email-using-8bit >stdout &&
1625 grep "Subject" msgtxt1 >actual &&
1626 test_cmp expected actual
1629 test_expect_success $PREREQ 'setup expect' '
1630 cat >content-type-decl <<-\EOF
1631 MIME-Version: 1.0
1632 Content-Type: text/plain; charset=UTF-8
1633 Content-Transfer-Encoding: 8bit
1637 test_expect_success $PREREQ 'asks about and fixes 8bit encodings' '
1638 clean_fake_sendmail &&
1639 echo |
1640 git send-email --from=author@example.com --to=nobody@example.com \
1641 --smtp-server="$(pwd)/fake.sendmail" \
1642 email-using-8bit >stdout &&
1643 grep "do not declare a Content-Transfer-Encoding" stdout &&
1644 grep email-using-8bit stdout &&
1645 grep "Which 8bit encoding" stdout &&
1646 grep -E "Content|MIME" msgtxt1 >actual &&
1647 test_cmp content-type-decl actual
1650 test_expect_success $PREREQ 'sendemail.8bitEncoding works' '
1651 clean_fake_sendmail &&
1652 git config sendemail.assume8bitEncoding UTF-8 &&
1653 echo bogus |
1654 git send-email --from=author@example.com --to=nobody@example.com \
1655 --smtp-server="$(pwd)/fake.sendmail" \
1656 email-using-8bit >stdout &&
1657 grep -E "Content|MIME" msgtxt1 >actual &&
1658 test_cmp content-type-decl actual
1661 test_expect_success $PREREQ 'sendemail.8bitEncoding in .git/config overrides --global .gitconfig' '
1662 clean_fake_sendmail &&
1663 git config sendemail.assume8bitEncoding UTF-8 &&
1664 test_when_finished "rm -rf home" &&
1665 mkdir home &&
1666 git config -f home/.gitconfig sendemail.assume8bitEncoding "bogus too" &&
1667 echo bogus |
1668 env HOME="$(pwd)/home" DEBUG=1 \
1669 git send-email --from=author@example.com --to=nobody@example.com \
1670 --smtp-server="$(pwd)/fake.sendmail" \
1671 email-using-8bit >stdout &&
1672 grep -E "Content|MIME" msgtxt1 >actual &&
1673 test_cmp content-type-decl actual
1676 test_expect_success $PREREQ '--8bit-encoding overrides sendemail.8bitEncoding' '
1677 clean_fake_sendmail &&
1678 git config sendemail.assume8bitEncoding "bogus too" &&
1679 echo bogus |
1680 git send-email --from=author@example.com --to=nobody@example.com \
1681 --smtp-server="$(pwd)/fake.sendmail" \
1682 --8bit-encoding=UTF-8 \
1683 email-using-8bit >stdout &&
1684 grep -E "Content|MIME" msgtxt1 >actual &&
1685 test_cmp content-type-decl actual
1688 test_expect_success $PREREQ 'setup expect' '
1689 cat >email-using-8bit <<-\EOF
1690 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1691 Message-ID: <bogus-message-id@example.com>
1692 From: author@example.com
1693 Date: Sat, 12 Jun 2010 15:53:58 +0200
1694 Subject: Dieser Betreff enthält auch einen Umlaut!
1696 Nothing to see here.
1700 test_expect_success $PREREQ 'setup expect' '
1701 cat >expected <<-\EOF
1702 Subject: =?UTF-8?q?Dieser=20Betreff=20enth=C3=A4lt=20auch=20einen=20Umlaut!?=
1706 test_expect_success $PREREQ '--8bit-encoding also treats subject' '
1707 clean_fake_sendmail &&
1708 echo bogus |
1709 git send-email --from=author@example.com --to=nobody@example.com \
1710 --smtp-server="$(pwd)/fake.sendmail" \
1711 --8bit-encoding=UTF-8 \
1712 email-using-8bit >stdout &&
1713 grep "Subject" msgtxt1 >actual &&
1714 test_cmp expected actual
1717 test_expect_success $PREREQ 'setup expect' '
1718 cat >email-using-8bit <<-\EOF
1719 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1720 Message-ID: <bogus-message-id@example.com>
1721 From: A U Thor <author@example.com>
1722 Date: Sat, 12 Jun 2010 15:53:58 +0200
1723 Content-Type: text/plain; charset=UTF-8
1724 Subject: Nothing to see here.
1726 Dieser Betreff enthält auch einen Umlaut!
1730 test_expect_success $PREREQ '--transfer-encoding overrides sendemail.transferEncoding' '
1731 clean_fake_sendmail &&
1732 test_must_fail git -c sendemail.transferEncoding=8bit \
1733 send-email \
1734 --transfer-encoding=7bit \
1735 --smtp-server="$(pwd)/fake.sendmail" \
1736 email-using-8bit \
1737 2>errors >out &&
1738 grep "cannot send message as 7bit" errors &&
1739 test -z "$(ls msgtxt*)"
1742 test_expect_success $PREREQ 'sendemail.transferEncoding via config' '
1743 clean_fake_sendmail &&
1744 test_must_fail git -c sendemail.transferEncoding=7bit \
1745 send-email \
1746 --smtp-server="$(pwd)/fake.sendmail" \
1747 email-using-8bit \
1748 2>errors >out &&
1749 grep "cannot send message as 7bit" errors &&
1750 test -z "$(ls msgtxt*)"
1753 test_expect_success $PREREQ 'sendemail.transferEncoding via cli' '
1754 clean_fake_sendmail &&
1755 test_must_fail git send-email \
1756 --transfer-encoding=7bit \
1757 --smtp-server="$(pwd)/fake.sendmail" \
1758 email-using-8bit \
1759 2>errors >out &&
1760 grep "cannot send message as 7bit" errors &&
1761 test -z "$(ls msgtxt*)"
1764 test_expect_success $PREREQ 'setup expect' '
1765 cat >expected <<-\EOF
1766 Dieser Betreff enth=C3=A4lt auch einen Umlaut!
1770 test_expect_success $PREREQ '8-bit and sendemail.transferencoding=quoted-printable' '
1771 clean_fake_sendmail &&
1772 git send-email \
1773 --transfer-encoding=quoted-printable \
1774 --smtp-server="$(pwd)/fake.sendmail" \
1775 email-using-8bit \
1776 2>errors >out &&
1777 sed "1,/^$/d" msgtxt1 >actual &&
1778 test_cmp expected actual
1781 test_expect_success $PREREQ 'setup expect' '
1782 cat >expected <<-\EOF
1783 RGllc2VyIEJldHJlZmYgZW50aMOkbHQgYXVjaCBlaW5lbiBVbWxhdXQhCg==
1787 test_expect_success $PREREQ '8-bit and sendemail.transferencoding=base64' '
1788 clean_fake_sendmail &&
1789 git send-email \
1790 --transfer-encoding=base64 \
1791 --smtp-server="$(pwd)/fake.sendmail" \
1792 email-using-8bit \
1793 2>errors >out &&
1794 sed "1,/^$/d" msgtxt1 >actual &&
1795 test_cmp expected actual
1798 test_expect_success $PREREQ 'setup expect' '
1799 cat >email-using-qp <<-\EOF
1800 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1801 Message-ID: <bogus-message-id@example.com>
1802 From: A U Thor <author@example.com>
1803 Date: Sat, 12 Jun 2010 15:53:58 +0200
1804 MIME-Version: 1.0
1805 Content-Transfer-Encoding: quoted-printable
1806 Content-Type: text/plain; charset=UTF-8
1807 Subject: Nothing to see here.
1809 Dieser Betreff enth=C3=A4lt auch einen Umlaut!
1813 test_expect_success $PREREQ 'convert from quoted-printable to base64' '
1814 clean_fake_sendmail &&
1815 git send-email \
1816 --transfer-encoding=base64 \
1817 --smtp-server="$(pwd)/fake.sendmail" \
1818 email-using-qp \
1819 2>errors >out &&
1820 sed "1,/^$/d" msgtxt1 >actual &&
1821 test_cmp expected actual
1824 test_expect_success $PREREQ 'setup expect' "
1825 tr -d '\\015' | tr '%' '\\015' >email-using-crlf <<EOF
1826 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1827 Message-ID: <bogus-message-id@example.com>
1828 From: A U Thor <author@example.com>
1829 Date: Sat, 12 Jun 2010 15:53:58 +0200
1830 Content-Type: text/plain; charset=UTF-8
1831 Subject: Nothing to see here.
1833 Look, I have a CRLF and an = sign!%
1837 test_expect_success $PREREQ 'setup expect' '
1838 cat >expected <<-\EOF
1839 Look, I have a CRLF and an =3D sign!=0D
1843 test_expect_success $PREREQ 'CRLF and sendemail.transferencoding=quoted-printable' '
1844 clean_fake_sendmail &&
1845 git send-email \
1846 --transfer-encoding=quoted-printable \
1847 --smtp-server="$(pwd)/fake.sendmail" \
1848 email-using-crlf \
1849 2>errors >out &&
1850 sed "1,/^$/d" msgtxt1 >actual &&
1851 test_cmp expected actual
1854 test_expect_success $PREREQ 'setup expect' '
1855 cat >expected <<-\EOF
1856 TG9vaywgSSBoYXZlIGEgQ1JMRiBhbmQgYW4gPSBzaWduIQ0K
1860 test_expect_success $PREREQ 'CRLF and sendemail.transferencoding=base64' '
1861 clean_fake_sendmail &&
1862 git send-email \
1863 --transfer-encoding=base64 \
1864 --smtp-server="$(pwd)/fake.sendmail" \
1865 email-using-crlf \
1866 2>errors >out &&
1867 sed "1,/^$/d" msgtxt1 >actual &&
1868 test_cmp expected actual
1872 # Note that the patches in this test are deliberately out of order; we
1873 # want to make sure it works even if the cover-letter is not in the
1874 # first mail.
1875 test_expect_success $PREREQ 'refusing to send cover letter template' '
1876 clean_fake_sendmail &&
1877 rm -fr outdir &&
1878 git format-patch --cover-letter -2 -o outdir &&
1879 test_must_fail git send-email \
1880 --from="Example <nobody@example.com>" \
1881 --to=nobody@example.com \
1882 --smtp-server="$(pwd)/fake.sendmail" \
1883 outdir/0002-*.patch \
1884 outdir/0000-*.patch \
1885 outdir/0001-*.patch \
1886 2>errors >out &&
1887 grep "SUBJECT HERE" errors &&
1888 test -z "$(ls msgtxt*)"
1891 test_expect_success $PREREQ '--force sends cover letter template anyway' '
1892 clean_fake_sendmail &&
1893 rm -fr outdir &&
1894 git format-patch --cover-letter -2 -o outdir &&
1895 git send-email \
1896 --force \
1897 --from="Example <nobody@example.com>" \
1898 --to=nobody@example.com \
1899 --smtp-server="$(pwd)/fake.sendmail" \
1900 outdir/0002-*.patch \
1901 outdir/0000-*.patch \
1902 outdir/0001-*.patch \
1903 2>errors >out &&
1904 ! grep "SUBJECT HERE" errors &&
1905 test -n "$(ls msgtxt*)"
1908 test_cover_addresses () {
1909 header="$1"
1910 shift
1911 clean_fake_sendmail &&
1912 rm -fr outdir &&
1913 git format-patch --cover-letter -2 -o outdir &&
1914 cover=$(echo outdir/0000-*.patch) &&
1915 mv $cover cover-to-edit.patch &&
1916 perl -pe "s/^From:/$header: extra\@address.com\nFrom:/" cover-to-edit.patch >"$cover" &&
1917 git send-email \
1918 --force \
1919 --from="Example <nobody@example.com>" \
1920 --no-to --no-cc \
1921 "$@" \
1922 --smtp-server="$(pwd)/fake.sendmail" \
1923 outdir/0000-*.patch \
1924 outdir/0001-*.patch \
1925 outdir/0002-*.patch \
1926 2>errors >out &&
1927 grep "^$header: extra@address.com" msgtxt1 >to1 &&
1928 grep "^$header: extra@address.com" msgtxt2 >to2 &&
1929 grep "^$header: extra@address.com" msgtxt3 >to3 &&
1930 test_line_count = 1 to1 &&
1931 test_line_count = 1 to2 &&
1932 test_line_count = 1 to3
1935 test_expect_success $PREREQ 'to-cover adds To to all mail' '
1936 test_cover_addresses "To" --to-cover
1939 test_expect_success $PREREQ 'cc-cover adds Cc to all mail' '
1940 test_cover_addresses "Cc" --cc-cover
1943 test_expect_success $PREREQ 'tocover adds To to all mail' '
1944 test_config sendemail.tocover true &&
1945 test_cover_addresses "To"
1948 test_expect_success $PREREQ 'cccover adds Cc to all mail' '
1949 test_config sendemail.cccover true &&
1950 test_cover_addresses "Cc"
1953 test_expect_success $PREREQ 'escaped quotes in sendemail.aliasfiletype=mutt' '
1954 clean_fake_sendmail &&
1955 echo "alias sbd \\\"Dot U. Sir\\\" <somebody@example.org>" >.mutt &&
1956 git config --replace-all sendemail.aliasesfile "$(pwd)/.mutt" &&
1957 git config sendemail.aliasfiletype mutt &&
1958 git send-email \
1959 --from="Example <nobody@example.com>" \
1960 --to=sbd \
1961 --smtp-server="$(pwd)/fake.sendmail" \
1962 outdir/0001-*.patch \
1963 2>errors >out &&
1964 grep "^!somebody@example\.org!$" commandline1 &&
1965 grep -F "To: \"Dot U. Sir\" <somebody@example.org>" out
1968 test_expect_success $PREREQ 'sendemail.aliasfiletype=mailrc' '
1969 clean_fake_sendmail &&
1970 echo "alias sbd somebody@example.org" >.mailrc &&
1971 git config --replace-all sendemail.aliasesfile "$(pwd)/.mailrc" &&
1972 git config sendemail.aliasfiletype mailrc &&
1973 git send-email \
1974 --from="Example <nobody@example.com>" \
1975 --to=sbd \
1976 --smtp-server="$(pwd)/fake.sendmail" \
1977 outdir/0001-*.patch \
1978 2>errors >out &&
1979 grep "^!somebody@example\.org!$" commandline1
1982 test_expect_success $PREREQ 'sendemail.aliasesfile=~/.mailrc' '
1983 clean_fake_sendmail &&
1984 echo "alias sbd someone@example.org" >"$HOME/.mailrc" &&
1985 git config --replace-all sendemail.aliasesfile "~/.mailrc" &&
1986 git config sendemail.aliasfiletype mailrc &&
1987 git send-email \
1988 --from="Example <nobody@example.com>" \
1989 --to=sbd \
1990 --smtp-server="$(pwd)/fake.sendmail" \
1991 outdir/0001-*.patch \
1992 2>errors >out &&
1993 grep "^!someone@example\.org!$" commandline1
1996 test_dump_aliases () {
1997 msg="$1" && shift &&
1998 filetype="$1" && shift &&
1999 printf '%s\n' "$@" >expect &&
2000 cat >.tmp-email-aliases &&
2002 test_expect_success $PREREQ "$msg" '
2003 clean_fake_sendmail && rm -fr outdir &&
2004 git config --replace-all sendemail.aliasesfile \
2005 "$(pwd)/.tmp-email-aliases" &&
2006 git config sendemail.aliasfiletype "$filetype" &&
2007 git send-email --dump-aliases 2>errors >actual &&
2008 test_cmp expect actual
2012 test_dump_aliases '--dump-aliases sendmail format' \
2013 'sendmail' \
2014 'abgroup' \
2015 'alice' \
2016 'bcgrp' \
2017 'bob' \
2018 'chloe' <<-\EOF
2019 alice: Alice W Land <awol@example.com>
2020 bob: Robert Bobbyton <bob@example.com>
2021 chloe: chloe@example.com
2022 abgroup: alice, bob
2023 bcgrp: bob, chloe, Other <o@example.com>
2026 test_dump_aliases '--dump-aliases mutt format' \
2027 'mutt' \
2028 'alice' \
2029 'bob' \
2030 'chloe' \
2031 'donald' <<-\EOF
2032 alias alice Alice W Land <awol@example.com>
2033 alias donald Donald C Carlton <donc@example.com>
2034 alias bob Robert Bobbyton <bob@example.com>
2035 alias chloe chloe@example.com
2038 test_dump_aliases '--dump-aliases mailrc format' \
2039 'mailrc' \
2040 'alice' \
2041 'bob' \
2042 'chloe' \
2043 'eve' <<-\EOF
2044 alias alice Alice W Land <awol@example.com>
2045 alias eve Eve <eve@example.com>
2046 alias bob Robert Bobbyton <bob@example.com>
2047 alias chloe chloe@example.com
2050 test_dump_aliases '--dump-aliases pine format' \
2051 'pine' \
2052 'alice' \
2053 'bob' \
2054 'chloe' \
2055 'eve' <<-\EOF
2056 alice Alice W Land <awol@example.com>
2057 eve Eve <eve@example.com>
2058 bob Robert Bobbyton <bob@example.com>
2059 chloe chloe@example.com
2062 test_dump_aliases '--dump-aliases gnus format' \
2063 'gnus' \
2064 'alice' \
2065 'bob' \
2066 'chloe' \
2067 'eve' <<-\EOF
2068 (define-mail-alias "alice" "awol@example.com")
2069 (define-mail-alias "eve" "eve@example.com")
2070 (define-mail-alias "bob" "bob@example.com")
2071 (define-mail-alias "chloe" "chloe@example.com")
2074 test_expect_success '--dump-aliases must be used alone' '
2075 test_must_fail git send-email --dump-aliases --to=janice@example.com -1 refs/heads/accounting
2078 test_expect_success $PREREQ 'aliases and sendemail.identity' '
2079 test_must_fail git \
2080 -c sendemail.identity=cloud \
2081 -c sendemail.aliasesfile=default-aliases \
2082 -c sendemail.cloud.aliasesfile=cloud-aliases \
2083 send-email -1 2>stderr &&
2084 test_grep "cloud-aliases" stderr
2087 test_sendmail_aliases () {
2088 msg="$1" && shift &&
2089 expect="$@" &&
2090 cat >.tmp-email-aliases &&
2092 test_expect_success $PREREQ "$msg" '
2093 clean_fake_sendmail && rm -fr outdir &&
2094 git format-patch -1 -o outdir &&
2095 git config --replace-all sendemail.aliasesfile \
2096 "$(pwd)/.tmp-email-aliases" &&
2097 git config sendemail.aliasfiletype sendmail &&
2098 git send-email \
2099 --from="Example <nobody@example.com>" \
2100 --to=alice --to=bcgrp \
2101 --smtp-server="$(pwd)/fake.sendmail" \
2102 outdir/0001-*.patch \
2103 2>errors >out &&
2104 for i in $expect
2106 grep "^!$i!$" commandline1 || return 1
2107 done
2111 test_sendmail_aliases 'sendemail.aliasfiletype=sendmail' \
2112 'awol@example\.com' \
2113 'bob@example\.com' \
2114 'chloe@example\.com' \
2115 'o@example\.com' <<-\EOF
2116 alice: Alice W Land <awol@example.com>
2117 bob: Robert Bobbyton <bob@example.com>
2118 # this is a comment
2119 # this is also a comment
2120 chloe: chloe@example.com
2121 abgroup: alice, bob
2122 bcgrp: bob, chloe, Other <o@example.com>
2125 test_sendmail_aliases 'sendmail aliases line folding' \
2126 alice1 \
2127 bob1 bob2 \
2128 chuck1 chuck2 \
2129 darla1 darla2 darla3 \
2130 elton1 elton2 elton3 \
2131 fred1 fred2 \
2132 greg1 <<-\EOF
2133 alice: alice1
2134 bob: bob1,\
2135 bob2
2136 chuck: chuck1,
2137 chuck2
2138 darla: darla1,\
2139 darla2,
2140 darla3
2141 elton: elton1,
2142 elton2,\
2143 elton3
2144 fred: fred1,\
2145 fred2
2146 greg: greg1
2147 bcgrp: bob, chuck, darla, elton, fred, greg
2150 test_sendmail_aliases 'sendmail aliases tolerate bogus line folding' \
2151 alice1 bob1 <<-\EOF
2152 alice: alice1
2153 bcgrp: bob1\
2156 test_sendmail_aliases 'sendmail aliases empty' alice bcgrp <<-\EOF
2159 test_expect_success $PREREQ 'alias support in To header' '
2160 clean_fake_sendmail &&
2161 echo "alias sbd someone@example.org" >.mailrc &&
2162 test_config sendemail.aliasesfile ".mailrc" &&
2163 test_config sendemail.aliasfiletype mailrc &&
2164 git format-patch --stdout -1 --to=sbd >aliased.patch &&
2165 git send-email \
2166 --from="Example <nobody@example.com>" \
2167 --smtp-server="$(pwd)/fake.sendmail" \
2168 aliased.patch \
2169 2>errors >out &&
2170 grep "^!someone@example\.org!$" commandline1
2173 test_expect_success $PREREQ 'alias support in Cc header' '
2174 clean_fake_sendmail &&
2175 echo "alias sbd someone@example.org" >.mailrc &&
2176 test_config sendemail.aliasesfile ".mailrc" &&
2177 test_config sendemail.aliasfiletype mailrc &&
2178 git format-patch --stdout -1 --cc=sbd >aliased.patch &&
2179 git send-email \
2180 --from="Example <nobody@example.com>" \
2181 --smtp-server="$(pwd)/fake.sendmail" \
2182 aliased.patch \
2183 2>errors >out &&
2184 grep "^!someone@example\.org!$" commandline1
2187 test_expect_success $PREREQ 'tocmd works with aliases' '
2188 clean_fake_sendmail &&
2189 echo "alias sbd someone@example.org" >.mailrc &&
2190 test_config sendemail.aliasesfile ".mailrc" &&
2191 test_config sendemail.aliasfiletype mailrc &&
2192 git format-patch --stdout -1 >tocmd.patch &&
2193 echo tocmd--sbd >>tocmd.patch &&
2194 git send-email \
2195 --from="Example <nobody@example.com>" \
2196 --to-cmd=./tocmd-sed \
2197 --smtp-server="$(pwd)/fake.sendmail" \
2198 tocmd.patch \
2199 2>errors >out &&
2200 grep "^!someone@example\.org!$" commandline1
2203 test_expect_success $PREREQ 'cccmd works with aliases' '
2204 clean_fake_sendmail &&
2205 echo "alias sbd someone@example.org" >.mailrc &&
2206 test_config sendemail.aliasesfile ".mailrc" &&
2207 test_config sendemail.aliasfiletype mailrc &&
2208 git format-patch --stdout -1 >cccmd.patch &&
2209 echo cccmd--sbd >>cccmd.patch &&
2210 git send-email \
2211 --from="Example <nobody@example.com>" \
2212 --cc-cmd=./cccmd-sed \
2213 --smtp-server="$(pwd)/fake.sendmail" \
2214 cccmd.patch \
2215 2>errors >out &&
2216 grep "^!someone@example\.org!$" commandline1
2219 do_xmailer_test () {
2220 expected=$1 params=$2 &&
2221 git format-patch -1 &&
2222 git send-email \
2223 --from="Example <nobody@example.com>" \
2224 --to=someone@example.com \
2225 --smtp-server="$(pwd)/fake.sendmail" \
2226 $params \
2227 0001-*.patch \
2228 2>errors >out &&
2229 { grep '^X-Mailer:' out || :; } >mailer &&
2230 test_line_count = $expected mailer
2233 test_expect_success $PREREQ '--[no-]xmailer without any configuration' '
2234 do_xmailer_test 1 "--xmailer" &&
2235 do_xmailer_test 0 "--no-xmailer"
2238 test_expect_success $PREREQ '--[no-]xmailer with sendemail.xmailer=true' '
2239 test_config sendemail.xmailer true &&
2240 do_xmailer_test 1 "" &&
2241 do_xmailer_test 0 "--no-xmailer" &&
2242 do_xmailer_test 1 "--xmailer"
2245 test_expect_success $PREREQ '--[no-]xmailer with sendemail.xmailer' '
2246 test_when_finished "test_unconfig sendemail.xmailer" &&
2247 cat >>.git/config <<-\EOF &&
2248 [sendemail]
2249 xmailer
2251 test_config sendemail.xmailer true &&
2252 do_xmailer_test 1 "" &&
2253 do_xmailer_test 0 "--no-xmailer" &&
2254 do_xmailer_test 1 "--xmailer"
2257 test_expect_success $PREREQ '--[no-]xmailer with sendemail.xmailer=false' '
2258 test_config sendemail.xmailer false &&
2259 do_xmailer_test 0 "" &&
2260 do_xmailer_test 0 "--no-xmailer" &&
2261 do_xmailer_test 1 "--xmailer"
2264 test_expect_success $PREREQ '--[no-]xmailer with sendemail.xmailer=' '
2265 test_config sendemail.xmailer "" &&
2266 do_xmailer_test 0 "" &&
2267 do_xmailer_test 0 "--no-xmailer" &&
2268 do_xmailer_test 1 "--xmailer"
2271 test_expect_success $PREREQ 'setup expected-list' '
2272 git send-email \
2273 --dry-run \
2274 --from="Example <from@example.com>" \
2275 --to="To 1 <to1@example.com>" \
2276 --to="to2@example.com" \
2277 --to="to3@example.com" \
2278 --cc="Cc 1 <cc1@example.com>" \
2279 --cc="Cc2 <cc2@example.com>" \
2280 --bcc="bcc1@example.com" \
2281 --bcc="bcc2@example.com" \
2282 0001-add-main.patch | replace_variable_fields \
2283 >expected-list
2286 test_expect_success $PREREQ 'use email list in --cc --to and --bcc' '
2287 git send-email \
2288 --dry-run \
2289 --from="Example <from@example.com>" \
2290 --to="To 1 <to1@example.com>, to2@example.com" \
2291 --to="to3@example.com" \
2292 --cc="Cc 1 <cc1@example.com>, Cc2 <cc2@example.com>" \
2293 --bcc="bcc1@example.com, bcc2@example.com" \
2294 0001-add-main.patch | replace_variable_fields \
2295 >actual-list &&
2296 test_cmp expected-list actual-list
2299 test_expect_success $PREREQ 'aliases work with email list' '
2300 echo "alias to2 to2@example.com" >.mutt &&
2301 echo "alias cc1 Cc 1 <cc1@example.com>" >>.mutt &&
2302 test_config sendemail.aliasesfile ".mutt" &&
2303 test_config sendemail.aliasfiletype mutt &&
2304 git send-email \
2305 --dry-run \
2306 --from="Example <from@example.com>" \
2307 --to="To 1 <to1@example.com>, to2, to3@example.com" \
2308 --cc="cc1, Cc2 <cc2@example.com>" \
2309 --bcc="bcc1@example.com, bcc2@example.com" \
2310 0001-add-main.patch | replace_variable_fields \
2311 >actual-list &&
2312 test_cmp expected-list actual-list
2315 test_expect_success $PREREQ 'leading and trailing whitespaces are removed' '
2316 echo "alias to2 to2@example.com" >.mutt &&
2317 echo "alias cc1 Cc 1 <cc1@example.com>" >>.mutt &&
2318 test_config sendemail.aliasesfile ".mutt" &&
2319 test_config sendemail.aliasfiletype mutt &&
2320 TO1=$(echo "QTo 1 <to1@example.com>" | q_to_tab) &&
2321 TO2=$(echo "QZto2" | qz_to_tab_space) &&
2322 CC1=$(echo "cc1" | append_cr) &&
2323 BCC1=$(echo " bcc1@example.com Q" | q_to_nul) &&
2324 git send-email \
2325 --dry-run \
2326 --from=" Example <from@example.com>" \
2327 --to="$TO1" \
2328 --to="$TO2" \
2329 --to=" to3@example.com " \
2330 --cc="$CC1" \
2331 --cc="Cc2 <cc2@example.com>" \
2332 --bcc="$BCC1" \
2333 --bcc="bcc2@example.com" \
2334 0001-add-main.patch | replace_variable_fields \
2335 >actual-list &&
2336 test_cmp expected-list actual-list
2339 test_expect_success $PREREQ 'test using command name with --sendmail-cmd' '
2340 clean_fake_sendmail &&
2341 PATH="$PWD:$PATH" \
2342 git send-email \
2343 --from="Example <nobody@example.com>" \
2344 --to=nobody@example.com \
2345 --sendmail-cmd="fake.sendmail" \
2346 HEAD^ &&
2347 test_path_is_file commandline1
2350 test_expect_success $PREREQ 'test using arguments with --sendmail-cmd' '
2351 clean_fake_sendmail &&
2352 git send-email \
2353 --from="Example <nobody@example.com>" \
2354 --to=nobody@example.com \
2355 --sendmail-cmd='\''"$(pwd)/fake.sendmail" -f nobody@example.com'\'' \
2356 HEAD^ &&
2357 test_path_is_file commandline1
2360 test_expect_success $PREREQ 'test shell expression with --sendmail-cmd' '
2361 clean_fake_sendmail &&
2362 git send-email \
2363 --from="Example <nobody@example.com>" \
2364 --to=nobody@example.com \
2365 --sendmail-cmd='\''f() { "$(pwd)/fake.sendmail" "$@"; };f'\'' \
2366 HEAD^ &&
2367 test_path_is_file commandline1
2370 test_expect_success $PREREQ 'set up in-reply-to/references patches' '
2371 cat >has-reply.patch <<-\EOF &&
2372 From: A U Thor <author@example.com>
2373 Subject: patch with in-reply-to
2374 Message-ID: <patch.with.in.reply.to@example.com>
2375 In-Reply-To: <replied.to@example.com>
2376 References: <replied.to@example.com>
2378 This is the body.
2380 cat >no-reply.patch <<-\EOF
2381 From: A U Thor <author@example.com>
2382 Subject: patch without in-reply-to
2383 Message-ID: <patch.without.in.reply.to@example.com>
2385 This is the body.
2389 test_expect_success $PREREQ 'patch reply headers correct with --no-thread' '
2390 clean_fake_sendmail &&
2391 git send-email \
2392 --no-thread \
2393 --to=nobody@example.com \
2394 --smtp-server="$(pwd)/fake.sendmail" \
2395 has-reply.patch no-reply.patch &&
2396 grep "In-Reply-To: <replied.to@example.com>" msgtxt1 &&
2397 grep "References: <replied.to@example.com>" msgtxt1 &&
2398 ! grep replied.to@example.com msgtxt2
2401 test_expect_success $PREREQ 'cmdline in-reply-to used with --no-thread' '
2402 clean_fake_sendmail &&
2403 git send-email \
2404 --no-thread \
2405 --in-reply-to="<cmdline.reply@example.com>" \
2406 --to=nobody@example.com \
2407 --smtp-server="$(pwd)/fake.sendmail" \
2408 has-reply.patch no-reply.patch &&
2409 grep "In-Reply-To: <cmdline.reply@example.com>" msgtxt1 &&
2410 grep "References: <cmdline.reply@example.com>" msgtxt1 &&
2411 grep "In-Reply-To: <cmdline.reply@example.com>" msgtxt2 &&
2412 grep "References: <cmdline.reply@example.com>" msgtxt2
2415 test_expect_success $PREREQ 'invoke hook' '
2416 test_hook sendemail-validate <<-\EOF &&
2417 # test that we have the correct environment variable, pwd, and
2418 # argument
2419 case "$GIT_DIR" in
2420 *.git)
2421 true
2424 false
2426 esac &&
2427 test -f 0001-add-main.patch &&
2428 grep "add main" "$1"
2431 mkdir subdir &&
2433 # Test that it works even if we are not at the root of the
2434 # working tree
2435 cd subdir &&
2436 git send-email \
2437 --from="Example <nobody@example.com>" \
2438 --to=nobody@example.com \
2439 --smtp-server="$(pwd)/../fake.sendmail" \
2440 ../0001-add-main.patch &&
2442 # Verify error message when a patch is rejected by the hook
2443 sed -e "s/add main/x/" ../0001-add-main.patch >../another.patch &&
2444 test_must_fail git send-email \
2445 --from="Example <nobody@example.com>" \
2446 --to=nobody@example.com \
2447 --smtp-server="$(pwd)/../fake.sendmail" \
2448 ../another.patch 2>err &&
2449 test_grep "rejected by sendemail-validate hook" err
2453 expected_file_counter_output () {
2454 total=$1
2455 count=0
2456 while test $count -ne $total
2458 count=$((count + 1)) &&
2459 echo "$count/$total" || return
2460 done
2463 test_expect_success $PREREQ '--validate hook allows counting of messages' '
2464 test_when_finished "rm -rf my-hooks.log" &&
2465 test_config core.hooksPath "my-hooks" &&
2466 mkdir -p my-hooks &&
2468 write_script my-hooks/sendemail-validate <<-\EOF &&
2469 num=$GIT_SENDEMAIL_FILE_COUNTER &&
2470 tot=$GIT_SENDEMAIL_FILE_TOTAL &&
2471 echo "$num/$tot" >>my-hooks.log || exit 1
2474 >my-hooks.log &&
2475 expected_file_counter_output 4 >expect &&
2476 git send-email \
2477 --from="Example <from@example.com>" \
2478 --to=nobody@example.com \
2479 --smtp-server="$(pwd)/fake.sendmail" \
2480 --validate -3 --cover-letter --force &&
2481 test_cmp expect my-hooks.log
2484 test_expect_success $PREREQ 'test that send-email works outside a repo' '
2485 nongit git send-email \
2486 --from="Example <nobody@example.com>" \
2487 --to=nobody@example.com \
2488 --smtp-server="$(pwd)/fake.sendmail" \
2489 "$(pwd)/0001-add-main.patch"
2492 test_expect_success $PREREQ 'send-email relays -v 3 to format-patch' '
2493 test_when_finished "rm -f out" &&
2494 git send-email --dry-run -v 3 -1 >out &&
2495 grep "PATCH v3" out
2498 test_expect_success $PREREQ 'test that sendmail config is rejected' '
2499 test_config sendmail.program sendmail &&
2500 test_must_fail git send-email \
2501 --from="Example <nobody@example.com>" \
2502 --to=nobody@example.com \
2503 --smtp-server="$(pwd)/fake.sendmail" \
2504 HEAD^ 2>err &&
2505 test_grep "found configuration options for '"'"sendmail"'"'" err
2508 test_expect_success $PREREQ 'test that sendmail config rejection is specific' '
2509 test_config resendmail.program sendmail &&
2510 git send-email \
2511 --from="Example <nobody@example.com>" \
2512 --to=nobody@example.com \
2513 --smtp-server="$(pwd)/fake.sendmail" \
2514 HEAD^
2517 test_expect_success $PREREQ 'test forbidSendmailVariables behavior override' '
2518 test_config sendmail.program sendmail &&
2519 test_config sendemail.forbidSendmailVariables false &&
2520 git send-email \
2521 --from="Example <nobody@example.com>" \
2522 --to=nobody@example.com \
2523 --smtp-server="$(pwd)/fake.sendmail" \
2524 HEAD^
2527 test_expect_success $PREREQ '--compose handles lowercase headers' '
2528 write_script fake-editor <<-\EOF &&
2529 sed "s/^From:.*/from: edited-from@example.com/i" "$1" >"$1.tmp" &&
2530 mv "$1.tmp" "$1"
2532 clean_fake_sendmail &&
2533 git send-email \
2534 --compose \
2535 --from="Example <from@example.com>" \
2536 --to=nobody@example.com \
2537 --smtp-server="$(pwd)/fake.sendmail" \
2538 HEAD^ &&
2539 grep "From: edited-from@example.com" msgtxt1
2542 test_expect_success $PREREQ '--compose handles to headers' '
2543 write_script fake-editor <<-\EOF &&
2544 sed "s/^To: .*/&, edited-to@example.com/" <"$1" >"$1.tmp" &&
2545 echo this is the body >>"$1.tmp" &&
2546 mv "$1.tmp" "$1"
2548 clean_fake_sendmail &&
2549 GIT_SEND_EMAIL_NOTTY=1 \
2550 git send-email \
2551 --compose \
2552 --from="Example <from@example.com>" \
2553 --to=nobody@example.com \
2554 --smtp-server="$(pwd)/fake.sendmail" \
2555 HEAD^ &&
2556 # Check both that the cover letter used our modified "to" line,
2557 # but also that it was picked up for the patch.
2558 q_to_tab >expect <<-\EOF &&
2559 To: nobody@example.com,
2560 Qedited-to@example.com
2562 grep -A1 "^To:" msgtxt1 >msgtxt1.to &&
2563 test_cmp expect msgtxt1.to &&
2564 grep -A1 "^To:" msgtxt2 >msgtxt2.to &&
2565 test_cmp expect msgtxt2.to
2568 test_done