t/send-email: add test with quoted sender
[alt-git.git] / t / t9001-send-email.sh
blob39d82f46e4777b5742681dd9d525c0d75caa4734
1 #!/bin/sh
3 test_description='git send-email'
4 . ./test-lib.sh
6 # May be altered later in the test
7 PREREQ="PERL"
9 test_expect_success $PREREQ \
10 'prepare reference tree' \
11 'echo "1A quick brown fox jumps over the" >file &&
12 echo "lazy dog" >>file &&
13 git add file &&
14 GIT_AUTHOR_NAME="A" git commit -a -m "Initial."'
16 test_expect_success $PREREQ \
17 'Setup helper tool' \
18 '(echo "#!$SHELL_PATH"
19 echo shift
20 echo output=1
21 echo "while test -f commandline\$output; do output=\$((\$output+1)); done"
22 echo for a
23 echo do
24 echo " echo \"!\$a!\""
25 echo "done >commandline\$output"
26 test_have_prereq MINGW && echo "dos2unix commandline\$output"
27 echo "cat > msgtxt\$output"
28 ) >fake.sendmail &&
29 chmod +x ./fake.sendmail &&
30 git add fake.sendmail &&
31 GIT_AUTHOR_NAME="A" git commit -a -m "Second."'
33 clean_fake_sendmail() {
34 rm -f commandline* msgtxt*
37 test_expect_success $PREREQ 'Extract patches' '
38 patches=`git format-patch -s --cc="One <one@example.com>" --cc=two@example.com -n HEAD^1`
41 # Test no confirm early to ensure remaining tests will not hang
42 test_no_confirm () {
43 rm -f no_confirm_okay
44 echo n | \
45 GIT_SEND_EMAIL_NOTTY=1 \
46 git send-email \
47 --from="Example <from@example.com>" \
48 --to=nobody@example.com \
49 --smtp-server="$(pwd)/fake.sendmail" \
50 $@ \
51 $patches > stdout &&
52 test_must_fail grep "Send this email" stdout &&
53 > no_confirm_okay
56 # Exit immediately to prevent hang if a no-confirm test fails
57 check_no_confirm () {
58 if ! test -f no_confirm_okay
59 then
60 say 'confirm test failed; skipping remaining tests to prevent hanging'
61 PREREQ="$PREREQ,CHECK_NO_CONFIRM"
63 return 0
66 test_expect_success $PREREQ 'No confirm with --suppress-cc' '
67 test_no_confirm --suppress-cc=sob &&
68 check_no_confirm
72 test_expect_success $PREREQ 'No confirm with --confirm=never' '
73 test_no_confirm --confirm=never &&
74 check_no_confirm
77 # leave sendemail.confirm set to never after this so that none of the
78 # remaining tests prompt unintentionally.
79 test_expect_success $PREREQ 'No confirm with sendemail.confirm=never' '
80 git config sendemail.confirm never &&
81 test_no_confirm --compose --subject=foo &&
82 check_no_confirm
85 test_expect_success $PREREQ 'Send patches' '
86 git send-email --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors
89 test_expect_success $PREREQ 'setup expect' '
90 cat >expected <<\EOF
91 !nobody@example.com!
92 !author@example.com!
93 !one@example.com!
94 !two@example.com!
95 EOF
98 test_expect_success $PREREQ \
99 'Verify commandline' \
100 'test_cmp expected commandline1'
102 test_expect_success $PREREQ 'Send patches with --envelope-sender' '
103 clean_fake_sendmail &&
104 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
107 test_expect_success $PREREQ 'setup expect' '
108 cat >expected <<\EOF
109 !patch@example.com!
110 !-i!
111 !nobody@example.com!
112 !author@example.com!
113 !one@example.com!
114 !two@example.com!
118 test_expect_success $PREREQ \
119 'Verify commandline' \
120 'test_cmp expected commandline1'
122 test_expect_success $PREREQ 'Send patches with --envelope-sender=auto' '
123 clean_fake_sendmail &&
124 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
127 test_expect_success $PREREQ 'setup expect' '
128 cat >expected <<\EOF
129 !nobody@example.com!
130 !-i!
131 !nobody@example.com!
132 !author@example.com!
133 !one@example.com!
134 !two@example.com!
138 test_expect_success $PREREQ \
139 'Verify commandline' \
140 'test_cmp expected commandline1'
142 test_expect_success $PREREQ 'setup expect' "
143 cat >expected-show-all-headers <<\EOF
144 0001-Second.patch
145 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
146 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
147 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
148 Dry-OK. Log says:
149 Server: relay.example.com
150 MAIL FROM:<from@example.com>
151 RCPT TO:<to@example.com>
152 RCPT TO:<cc@example.com>
153 RCPT TO:<author@example.com>
154 RCPT TO:<one@example.com>
155 RCPT TO:<two@example.com>
156 RCPT TO:<bcc@example.com>
157 From: Example <from@example.com>
158 To: to@example.com
159 Cc: cc@example.com,
160 A <author@example.com>,
161 One <one@example.com>,
162 two@example.com
163 Subject: [PATCH 1/1] Second.
164 Date: DATE-STRING
165 Message-Id: MESSAGE-ID-STRING
166 X-Mailer: X-MAILER-STRING
167 In-Reply-To: <unique-message-id@example.com>
168 References: <unique-message-id@example.com>
170 Result: OK
174 test_suppress_self () {
175 test_commit $3 &&
176 test_when_finished "git reset --hard HEAD^" &&
178 write_script cccmd-sed <<-EOF &&
179 sed -n -e s/^cccmd--//p "\$1"
182 git commit --amend --author="$1 <$2>" -F - &&
183 clean_fake_sendmail &&
184 git format-patch --stdout -1 >"suppress-self-$3.patch" &&
186 git send-email --from="$1 <$2>" \
187 --to=nobody@example.com \
188 --cc-cmd=./cccmd-sed \
189 --suppress-cc=self \
190 --smtp-server="$(pwd)/fake.sendmail" \
191 suppress-self-$3.patch &&
193 mv msgtxt1 msgtxt1-$3 &&
194 sed -e '/^$/q' msgtxt1-$3 >"msghdr1-$3" &&
195 >"expected-no-cc-$3" &&
197 (grep '^Cc:' msghdr1-$3 >"actual-no-cc-$3";
198 test_cmp expected-no-cc-$3 actual-no-cc-$3)
201 test_suppress_self_unquoted () {
202 test_suppress_self "$1" "$2" "unquoted-$3" <<-EOF
203 test suppress-cc.self unquoted-$3 with name $1 email $2
205 unquoted-$3
207 cccmd--$1 <$2>
209 Cc: $1 <$2>
210 Signed-off-by: $1 <$2>
214 test_suppress_self_quoted () {
215 test_suppress_self "$1" "$2" "quoted-$3" <<-EOF
216 test suppress-cc.self quoted-$3 with name $1 email $2
218 quoted-$3
220 cccmd--"$1" <$2>
222 Cc: $1 <$2>
223 Cc: "$1" <$2>
224 Signed-off-by: $1 <$2>
225 Signed-off-by: "$1" <$2>
229 test_expect_success $PREREQ 'self name is suppressed' "
230 test_suppress_self_unquoted 'A U Thor' 'author@example.com' \
231 'self_name_suppressed'
234 test_expect_success $PREREQ 'self name with dot is suppressed' "
235 test_suppress_self_quoted 'A U. Thor' 'author@example.com' \
236 'self_name_dot_suppressed'
239 test_expect_success $PREREQ 'Show all headers' '
240 git send-email \
241 --dry-run \
242 --suppress-cc=sob \
243 --from="Example <from@example.com>" \
244 --to=to@example.com \
245 --cc=cc@example.com \
246 --bcc=bcc@example.com \
247 --in-reply-to="<unique-message-id@example.com>" \
248 --smtp-server relay.example.com \
249 $patches |
250 sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
251 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
252 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
253 >actual-show-all-headers &&
254 test_cmp expected-show-all-headers actual-show-all-headers
257 test_expect_success $PREREQ 'Prompting works' '
258 clean_fake_sendmail &&
259 (echo "to@example.com"
260 echo ""
261 ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
262 --smtp-server="$(pwd)/fake.sendmail" \
263 $patches \
264 2>errors &&
265 grep "^From: A U Thor <author@example.com>\$" msgtxt1 &&
266 grep "^To: to@example.com\$" msgtxt1
269 test_expect_success $PREREQ,AUTOIDENT 'implicit ident is allowed' '
270 clean_fake_sendmail &&
271 (sane_unset GIT_AUTHOR_NAME &&
272 sane_unset GIT_AUTHOR_EMAIL &&
273 sane_unset GIT_COMMITTER_NAME &&
274 sane_unset GIT_COMMITTER_EMAIL &&
275 GIT_SEND_EMAIL_NOTTY=1 git send-email \
276 --smtp-server="$(pwd)/fake.sendmail" \
277 --to=to@example.com \
278 $patches </dev/null 2>errors
282 test_expect_success $PREREQ,!AUTOIDENT 'broken implicit ident aborts send-email' '
283 clean_fake_sendmail &&
284 (sane_unset GIT_AUTHOR_NAME &&
285 sane_unset GIT_AUTHOR_EMAIL &&
286 sane_unset GIT_COMMITTER_NAME &&
287 sane_unset GIT_COMMITTER_EMAIL &&
288 GIT_SEND_EMAIL_NOTTY=1 && export GIT_SEND_EMAIL_NOTTY &&
289 test_must_fail git send-email \
290 --smtp-server="$(pwd)/fake.sendmail" \
291 --to=to@example.com \
292 $patches </dev/null 2>errors &&
293 test_i18ngrep "tell me who you are" errors
297 test_expect_success $PREREQ 'tocmd works' '
298 clean_fake_sendmail &&
299 cp $patches tocmd.patch &&
300 echo tocmd--tocmd@example.com >>tocmd.patch &&
302 echo "#!$SHELL_PATH"
303 echo sed -n -e s/^tocmd--//p \"\$1\"
304 } > tocmd-sed &&
305 chmod +x tocmd-sed &&
306 git send-email \
307 --from="Example <nobody@example.com>" \
308 --to-cmd=./tocmd-sed \
309 --smtp-server="$(pwd)/fake.sendmail" \
310 tocmd.patch \
312 grep "^To: tocmd@example.com" msgtxt1
315 test_expect_success $PREREQ 'cccmd works' '
316 clean_fake_sendmail &&
317 cp $patches cccmd.patch &&
318 echo "cccmd-- cccmd@example.com" >>cccmd.patch &&
320 echo "#!$SHELL_PATH"
321 echo sed -n -e s/^cccmd--//p \"\$1\"
322 } > cccmd-sed &&
323 chmod +x cccmd-sed &&
324 git send-email \
325 --from="Example <nobody@example.com>" \
326 --to=nobody@example.com \
327 --cc-cmd=./cccmd-sed \
328 --smtp-server="$(pwd)/fake.sendmail" \
329 cccmd.patch \
331 grep "^ cccmd@example.com" msgtxt1
334 test_expect_success $PREREQ 'reject long lines' '
335 z8=zzzzzzzz &&
336 z64=$z8$z8$z8$z8$z8$z8$z8$z8 &&
337 z512=$z64$z64$z64$z64$z64$z64$z64$z64 &&
338 clean_fake_sendmail &&
339 cp $patches longline.patch &&
340 echo $z512$z512 >>longline.patch &&
341 test_must_fail git send-email \
342 --from="Example <nobody@example.com>" \
343 --to=nobody@example.com \
344 --smtp-server="$(pwd)/fake.sendmail" \
345 $patches longline.patch \
346 2>errors &&
347 grep longline.patch errors
350 test_expect_success $PREREQ 'no patch was sent' '
351 ! test -e commandline1
354 test_expect_success $PREREQ 'Author From: in message body' '
355 clean_fake_sendmail &&
356 git send-email \
357 --from="Example <nobody@example.com>" \
358 --to=nobody@example.com \
359 --smtp-server="$(pwd)/fake.sendmail" \
360 $patches &&
361 sed "1,/^\$/d" < msgtxt1 > msgbody1 &&
362 grep "From: A <author@example.com>" msgbody1
365 test_expect_success $PREREQ 'Author From: not in message body' '
366 clean_fake_sendmail &&
367 git send-email \
368 --from="A <author@example.com>" \
369 --to=nobody@example.com \
370 --smtp-server="$(pwd)/fake.sendmail" \
371 $patches &&
372 sed "1,/^\$/d" < msgtxt1 > msgbody1 &&
373 ! grep "From: A <author@example.com>" msgbody1
376 test_expect_success $PREREQ 'allow long lines with --no-validate' '
377 git send-email \
378 --from="Example <nobody@example.com>" \
379 --to=nobody@example.com \
380 --smtp-server="$(pwd)/fake.sendmail" \
381 --novalidate \
382 $patches longline.patch \
383 2>errors
386 test_expect_success $PREREQ 'Invalid In-Reply-To' '
387 clean_fake_sendmail &&
388 git send-email \
389 --from="Example <nobody@example.com>" \
390 --to=nobody@example.com \
391 --in-reply-to=" " \
392 --smtp-server="$(pwd)/fake.sendmail" \
393 $patches \
394 2>errors &&
395 ! grep "^In-Reply-To: < *>" msgtxt1
398 test_expect_success $PREREQ 'Valid In-Reply-To when prompting' '
399 clean_fake_sendmail &&
400 (echo "From Example <from@example.com>"
401 echo "To Example <to@example.com>"
402 echo ""
403 ) | env GIT_SEND_EMAIL_NOTTY=1 git send-email \
404 --smtp-server="$(pwd)/fake.sendmail" \
405 $patches 2>errors &&
406 ! grep "^In-Reply-To: < *>" msgtxt1
409 test_expect_success $PREREQ 'In-Reply-To without --chain-reply-to' '
410 clean_fake_sendmail &&
411 echo "<unique-message-id@example.com>" >expect &&
412 git send-email \
413 --from="Example <nobody@example.com>" \
414 --to=nobody@example.com \
415 --nochain-reply-to \
416 --in-reply-to="$(cat expect)" \
417 --smtp-server="$(pwd)/fake.sendmail" \
418 $patches $patches $patches \
419 2>errors &&
420 # The first message is a reply to --in-reply-to
421 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual &&
422 test_cmp expect actual &&
423 # Second and subsequent messages are replies to the first one
424 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect &&
425 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual &&
426 test_cmp expect actual &&
427 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual &&
428 test_cmp expect actual
431 test_expect_success $PREREQ 'In-Reply-To with --chain-reply-to' '
432 clean_fake_sendmail &&
433 echo "<unique-message-id@example.com>" >expect &&
434 git send-email \
435 --from="Example <nobody@example.com>" \
436 --to=nobody@example.com \
437 --chain-reply-to \
438 --in-reply-to="$(cat expect)" \
439 --smtp-server="$(pwd)/fake.sendmail" \
440 $patches $patches $patches \
441 2>errors &&
442 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual &&
443 test_cmp expect actual &&
444 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect &&
445 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual &&
446 test_cmp expect actual &&
447 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt2 >expect &&
448 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual &&
449 test_cmp expect actual
452 test_expect_success $PREREQ 'setup fake editor' '
453 (echo "#!$SHELL_PATH" &&
454 echo "echo fake edit >>\"\$1\""
455 ) >fake-editor &&
456 chmod +x fake-editor
459 test_set_editor "$(pwd)/fake-editor"
461 test_expect_success $PREREQ '--compose works' '
462 clean_fake_sendmail &&
463 git send-email \
464 --compose --subject foo \
465 --from="Example <nobody@example.com>" \
466 --to=nobody@example.com \
467 --smtp-server="$(pwd)/fake.sendmail" \
468 $patches \
469 2>errors
472 test_expect_success $PREREQ 'first message is compose text' '
473 grep "^fake edit" msgtxt1
476 test_expect_success $PREREQ 'second message is patch' '
477 grep "Subject:.*Second" msgtxt2
480 test_expect_success $PREREQ 'setup expect' "
481 cat >expected-suppress-sob <<\EOF
482 0001-Second.patch
483 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
484 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
485 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
486 Dry-OK. Log says:
487 Server: relay.example.com
488 MAIL FROM:<from@example.com>
489 RCPT TO:<to@example.com>
490 RCPT TO:<cc@example.com>
491 RCPT TO:<author@example.com>
492 RCPT TO:<one@example.com>
493 RCPT TO:<two@example.com>
494 From: Example <from@example.com>
495 To: to@example.com
496 Cc: cc@example.com,
497 A <author@example.com>,
498 One <one@example.com>,
499 two@example.com
500 Subject: [PATCH 1/1] Second.
501 Date: DATE-STRING
502 Message-Id: MESSAGE-ID-STRING
503 X-Mailer: X-MAILER-STRING
505 Result: OK
509 test_suppression () {
510 git send-email \
511 --dry-run \
512 --suppress-cc=$1 ${2+"--suppress-cc=$2"} \
513 --from="Example <from@example.com>" \
514 --to=to@example.com \
515 --smtp-server relay.example.com \
516 $patches |
517 sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
518 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
519 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
520 >actual-suppress-$1${2+"-$2"} &&
521 test_cmp expected-suppress-$1${2+"-$2"} actual-suppress-$1${2+"-$2"}
524 test_expect_success $PREREQ 'sendemail.cc set' '
525 git config sendemail.cc cc@example.com &&
526 test_suppression sob
529 test_expect_success $PREREQ 'setup expect' "
530 cat >expected-suppress-sob <<\EOF
531 0001-Second.patch
532 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
533 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
534 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
535 Dry-OK. Log says:
536 Server: relay.example.com
537 MAIL FROM:<from@example.com>
538 RCPT TO:<to@example.com>
539 RCPT TO:<author@example.com>
540 RCPT TO:<one@example.com>
541 RCPT TO:<two@example.com>
542 From: Example <from@example.com>
543 To: to@example.com
544 Cc: A <author@example.com>,
545 One <one@example.com>,
546 two@example.com
547 Subject: [PATCH 1/1] Second.
548 Date: DATE-STRING
549 Message-Id: MESSAGE-ID-STRING
550 X-Mailer: X-MAILER-STRING
552 Result: OK
556 test_expect_success $PREREQ 'sendemail.cc unset' '
557 git config --unset sendemail.cc &&
558 test_suppression sob
561 test_expect_success $PREREQ 'setup expect' "
562 cat >expected-suppress-cccmd <<\EOF
563 0001-Second.patch
564 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
565 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
566 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
567 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
568 Dry-OK. Log says:
569 Server: relay.example.com
570 MAIL FROM:<from@example.com>
571 RCPT TO:<to@example.com>
572 RCPT TO:<author@example.com>
573 RCPT TO:<one@example.com>
574 RCPT TO:<two@example.com>
575 RCPT TO:<committer@example.com>
576 From: Example <from@example.com>
577 To: to@example.com
578 Cc: A <author@example.com>,
579 One <one@example.com>,
580 two@example.com,
581 C O Mitter <committer@example.com>
582 Subject: [PATCH 1/1] Second.
583 Date: DATE-STRING
584 Message-Id: MESSAGE-ID-STRING
585 X-Mailer: X-MAILER-STRING
587 Result: OK
591 test_expect_success $PREREQ 'sendemail.cccmd' '
592 echo echo cc-cmd@example.com > cccmd &&
593 chmod +x cccmd &&
594 git config sendemail.cccmd ./cccmd &&
595 test_suppression cccmd
598 test_expect_success $PREREQ 'setup expect' '
599 cat >expected-suppress-all <<\EOF
600 0001-Second.patch
601 Dry-OK. Log says:
602 Server: relay.example.com
603 MAIL FROM:<from@example.com>
604 RCPT TO:<to@example.com>
605 From: Example <from@example.com>
606 To: to@example.com
607 Subject: [PATCH 1/1] Second.
608 Date: DATE-STRING
609 Message-Id: MESSAGE-ID-STRING
610 X-Mailer: X-MAILER-STRING
612 Result: OK
616 test_expect_success $PREREQ '--suppress-cc=all' '
617 test_suppression all
620 test_expect_success $PREREQ 'setup expect' "
621 cat >expected-suppress-body <<\EOF
622 0001-Second.patch
623 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
624 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
625 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
626 (cc-cmd) Adding cc: cc-cmd@example.com from: './cccmd'
627 Dry-OK. Log says:
628 Server: relay.example.com
629 MAIL FROM:<from@example.com>
630 RCPT TO:<to@example.com>
631 RCPT TO:<author@example.com>
632 RCPT TO:<one@example.com>
633 RCPT TO:<two@example.com>
634 RCPT TO:<cc-cmd@example.com>
635 From: Example <from@example.com>
636 To: to@example.com
637 Cc: A <author@example.com>,
638 One <one@example.com>,
639 two@example.com,
640 cc-cmd@example.com
641 Subject: [PATCH 1/1] Second.
642 Date: DATE-STRING
643 Message-Id: MESSAGE-ID-STRING
644 X-Mailer: X-MAILER-STRING
646 Result: OK
650 test_expect_success $PREREQ '--suppress-cc=body' '
651 test_suppression body
654 test_expect_success $PREREQ 'setup expect' "
655 cat >expected-suppress-body-cccmd <<\EOF
656 0001-Second.patch
657 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
658 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
659 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
660 Dry-OK. Log says:
661 Server: relay.example.com
662 MAIL FROM:<from@example.com>
663 RCPT TO:<to@example.com>
664 RCPT TO:<author@example.com>
665 RCPT TO:<one@example.com>
666 RCPT TO:<two@example.com>
667 From: Example <from@example.com>
668 To: to@example.com
669 Cc: A <author@example.com>,
670 One <one@example.com>,
671 two@example.com
672 Subject: [PATCH 1/1] Second.
673 Date: DATE-STRING
674 Message-Id: MESSAGE-ID-STRING
675 X-Mailer: X-MAILER-STRING
677 Result: OK
681 test_expect_success $PREREQ '--suppress-cc=body --suppress-cc=cccmd' '
682 test_suppression body cccmd
685 test_expect_success $PREREQ 'setup expect' "
686 cat >expected-suppress-sob <<\EOF
687 0001-Second.patch
688 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
689 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
690 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
691 Dry-OK. Log says:
692 Server: relay.example.com
693 MAIL FROM:<from@example.com>
694 RCPT TO:<to@example.com>
695 RCPT TO:<author@example.com>
696 RCPT TO:<one@example.com>
697 RCPT TO:<two@example.com>
698 From: Example <from@example.com>
699 To: to@example.com
700 Cc: A <author@example.com>,
701 One <one@example.com>,
702 two@example.com
703 Subject: [PATCH 1/1] Second.
704 Date: DATE-STRING
705 Message-Id: MESSAGE-ID-STRING
706 X-Mailer: X-MAILER-STRING
708 Result: OK
712 test_expect_success $PREREQ '--suppress-cc=sob' '
713 test_might_fail git config --unset sendemail.cccmd &&
714 test_suppression sob
717 test_expect_success $PREREQ 'setup expect' "
718 cat >expected-suppress-bodycc <<\EOF
719 0001-Second.patch
720 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
721 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
722 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
723 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
724 Dry-OK. Log says:
725 Server: relay.example.com
726 MAIL FROM:<from@example.com>
727 RCPT TO:<to@example.com>
728 RCPT TO:<author@example.com>
729 RCPT TO:<one@example.com>
730 RCPT TO:<two@example.com>
731 RCPT TO:<committer@example.com>
732 From: Example <from@example.com>
733 To: to@example.com
734 Cc: A <author@example.com>,
735 One <one@example.com>,
736 two@example.com,
737 C O Mitter <committer@example.com>
738 Subject: [PATCH 1/1] Second.
739 Date: DATE-STRING
740 Message-Id: MESSAGE-ID-STRING
741 X-Mailer: X-MAILER-STRING
743 Result: OK
747 test_expect_success $PREREQ '--suppress-cc=bodycc' '
748 test_suppression bodycc
751 test_expect_success $PREREQ 'setup expect' "
752 cat >expected-suppress-cc <<\EOF
753 0001-Second.patch
754 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
755 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
756 Dry-OK. Log says:
757 Server: relay.example.com
758 MAIL FROM:<from@example.com>
759 RCPT TO:<to@example.com>
760 RCPT TO:<author@example.com>
761 RCPT TO:<committer@example.com>
762 From: Example <from@example.com>
763 To: to@example.com
764 Cc: A <author@example.com>,
765 C O Mitter <committer@example.com>
766 Subject: [PATCH 1/1] Second.
767 Date: DATE-STRING
768 Message-Id: MESSAGE-ID-STRING
769 X-Mailer: X-MAILER-STRING
771 Result: OK
775 test_expect_success $PREREQ '--suppress-cc=cc' '
776 test_suppression cc
779 test_confirm () {
780 echo y | \
781 GIT_SEND_EMAIL_NOTTY=1 \
782 git send-email \
783 --from="Example <nobody@example.com>" \
784 --to=nobody@example.com \
785 --smtp-server="$(pwd)/fake.sendmail" \
786 $@ $patches > stdout &&
787 grep "Send this email" stdout
790 test_expect_success $PREREQ '--confirm=always' '
791 test_confirm --confirm=always --suppress-cc=all
794 test_expect_success $PREREQ '--confirm=auto' '
795 test_confirm --confirm=auto
798 test_expect_success $PREREQ '--confirm=cc' '
799 test_confirm --confirm=cc
802 test_expect_success $PREREQ '--confirm=compose' '
803 test_confirm --confirm=compose --compose
806 test_expect_success $PREREQ 'confirm by default (due to cc)' '
807 CONFIRM=$(git config --get sendemail.confirm) &&
808 git config --unset sendemail.confirm &&
809 test_confirm
810 ret="$?"
811 git config sendemail.confirm ${CONFIRM:-never}
812 test $ret = "0"
815 test_expect_success $PREREQ 'confirm by default (due to --compose)' '
816 CONFIRM=$(git config --get sendemail.confirm) &&
817 git config --unset sendemail.confirm &&
818 test_confirm --suppress-cc=all --compose
819 ret="$?"
820 git config sendemail.confirm ${CONFIRM:-never}
821 test $ret = "0"
824 test_expect_success $PREREQ 'confirm detects EOF (inform assumes y)' '
825 CONFIRM=$(git config --get sendemail.confirm) &&
826 git config --unset sendemail.confirm &&
827 rm -fr outdir &&
828 git format-patch -2 -o outdir &&
829 GIT_SEND_EMAIL_NOTTY=1 \
830 git send-email \
831 --from="Example <nobody@example.com>" \
832 --to=nobody@example.com \
833 --smtp-server="$(pwd)/fake.sendmail" \
834 outdir/*.patch < /dev/null
835 ret="$?"
836 git config sendemail.confirm ${CONFIRM:-never}
837 test $ret = "0"
840 test_expect_success $PREREQ 'confirm detects EOF (auto causes failure)' '
841 CONFIRM=$(git config --get sendemail.confirm) &&
842 git config sendemail.confirm auto &&
843 GIT_SEND_EMAIL_NOTTY=1 &&
844 export GIT_SEND_EMAIL_NOTTY &&
845 test_must_fail git send-email \
846 --from="Example <nobody@example.com>" \
847 --to=nobody@example.com \
848 --smtp-server="$(pwd)/fake.sendmail" \
849 $patches < /dev/null
850 ret="$?"
851 git config sendemail.confirm ${CONFIRM:-never}
852 test $ret = "0"
855 test_expect_success $PREREQ 'confirm does not loop forever' '
856 CONFIRM=$(git config --get sendemail.confirm) &&
857 git config sendemail.confirm auto &&
858 GIT_SEND_EMAIL_NOTTY=1 &&
859 export GIT_SEND_EMAIL_NOTTY &&
860 yes "bogus" | test_must_fail git send-email \
861 --from="Example <nobody@example.com>" \
862 --to=nobody@example.com \
863 --smtp-server="$(pwd)/fake.sendmail" \
864 $patches
865 ret="$?"
866 git config sendemail.confirm ${CONFIRM:-never}
867 test $ret = "0"
870 test_expect_success $PREREQ 'utf8 Cc is rfc2047 encoded' '
871 clean_fake_sendmail &&
872 rm -fr outdir &&
873 git format-patch -1 -o outdir --cc="àéìöú <utf8@example.com>" &&
874 git send-email \
875 --from="Example <nobody@example.com>" \
876 --to=nobody@example.com \
877 --smtp-server="$(pwd)/fake.sendmail" \
878 outdir/*.patch &&
879 grep "^ " msgtxt1 |
880 grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>"
883 test_expect_success $PREREQ '--compose adds MIME for utf8 body' '
884 clean_fake_sendmail &&
885 (echo "#!$SHELL_PATH" &&
886 echo "echo utf8 body: àéìöú >>\"\$1\""
887 ) >fake-editor-utf8 &&
888 chmod +x fake-editor-utf8 &&
889 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
890 git send-email \
891 --compose --subject foo \
892 --from="Example <nobody@example.com>" \
893 --to=nobody@example.com \
894 --smtp-server="$(pwd)/fake.sendmail" \
895 $patches &&
896 grep "^utf8 body" msgtxt1 &&
897 grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
900 test_expect_success $PREREQ '--compose respects user mime type' '
901 clean_fake_sendmail &&
902 (echo "#!$SHELL_PATH" &&
903 echo "(echo MIME-Version: 1.0"
904 echo " echo Content-Type: text/plain\\; charset=iso-8859-1"
905 echo " echo Content-Transfer-Encoding: 8bit"
906 echo " echo Subject: foo"
907 echo " echo "
908 echo " echo utf8 body: àéìöú) >\"\$1\""
909 ) >fake-editor-utf8-mime &&
910 chmod +x fake-editor-utf8-mime &&
911 GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \
912 git send-email \
913 --compose --subject foo \
914 --from="Example <nobody@example.com>" \
915 --to=nobody@example.com \
916 --smtp-server="$(pwd)/fake.sendmail" \
917 $patches &&
918 grep "^utf8 body" msgtxt1 &&
919 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 &&
920 ! grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
923 test_expect_success $PREREQ '--compose adds MIME for utf8 subject' '
924 clean_fake_sendmail &&
925 GIT_EDITOR="\"$(pwd)/fake-editor\"" \
926 git send-email \
927 --compose --subject utf8-sübjëct \
928 --from="Example <nobody@example.com>" \
929 --to=nobody@example.com \
930 --smtp-server="$(pwd)/fake.sendmail" \
931 $patches &&
932 grep "^fake edit" msgtxt1 &&
933 grep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
936 test_expect_success $PREREQ 'utf8 author is correctly passed on' '
937 clean_fake_sendmail &&
938 test_commit weird_author &&
939 test_when_finished "git reset --hard HEAD^" &&
940 git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" &&
941 git format-patch --stdout -1 >funny_name.patch &&
942 git send-email --from="Example <nobody@example.com>" \
943 --to=nobody@example.com \
944 --smtp-server="$(pwd)/fake.sendmail" \
945 funny_name.patch &&
946 grep "^From: Füñný Nâmé <odd_?=mail@example.com>" msgtxt1
949 test_expect_success $PREREQ 'sendemail.composeencoding works' '
950 clean_fake_sendmail &&
951 git config sendemail.composeencoding iso-8859-1 &&
952 (echo "#!$SHELL_PATH" &&
953 echo "echo utf8 body: àéìöú >>\"\$1\""
954 ) >fake-editor-utf8 &&
955 chmod +x fake-editor-utf8 &&
956 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
957 git send-email \
958 --compose --subject foo \
959 --from="Example <nobody@example.com>" \
960 --to=nobody@example.com \
961 --smtp-server="$(pwd)/fake.sendmail" \
962 $patches &&
963 grep "^utf8 body" msgtxt1 &&
964 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1
967 test_expect_success $PREREQ '--compose-encoding works' '
968 clean_fake_sendmail &&
969 (echo "#!$SHELL_PATH" &&
970 echo "echo utf8 body: àéìöú >>\"\$1\""
971 ) >fake-editor-utf8 &&
972 chmod +x fake-editor-utf8 &&
973 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
974 git send-email \
975 --compose-encoding iso-8859-1 \
976 --compose --subject foo \
977 --from="Example <nobody@example.com>" \
978 --to=nobody@example.com \
979 --smtp-server="$(pwd)/fake.sendmail" \
980 $patches &&
981 grep "^utf8 body" msgtxt1 &&
982 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1
985 test_expect_success $PREREQ '--compose-encoding overrides sendemail.composeencoding' '
986 clean_fake_sendmail &&
987 git config sendemail.composeencoding iso-8859-1 &&
988 (echo "#!$SHELL_PATH" &&
989 echo "echo utf8 body: àéìöú >>\"\$1\""
990 ) >fake-editor-utf8 &&
991 chmod +x fake-editor-utf8 &&
992 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
993 git send-email \
994 --compose-encoding iso-8859-2 \
995 --compose --subject foo \
996 --from="Example <nobody@example.com>" \
997 --to=nobody@example.com \
998 --smtp-server="$(pwd)/fake.sendmail" \
999 $patches &&
1000 grep "^utf8 body" msgtxt1 &&
1001 grep "^Content-Type: text/plain; charset=iso-8859-2" msgtxt1
1004 test_expect_success $PREREQ '--compose-encoding adds correct MIME for subject' '
1005 clean_fake_sendmail &&
1006 GIT_EDITOR="\"$(pwd)/fake-editor\"" \
1007 git send-email \
1008 --compose-encoding iso-8859-2 \
1009 --compose --subject utf8-sübjëct \
1010 --from="Example <nobody@example.com>" \
1011 --to=nobody@example.com \
1012 --smtp-server="$(pwd)/fake.sendmail" \
1013 $patches &&
1014 grep "^fake edit" msgtxt1 &&
1015 grep "^Subject: =?iso-8859-2?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
1018 test_expect_success $PREREQ 'detects ambiguous reference/file conflict' '
1019 echo master > master &&
1020 git add master &&
1021 git commit -m"add master" &&
1022 test_must_fail git send-email --dry-run master 2>errors &&
1023 grep disambiguate errors
1026 test_expect_success $PREREQ 'feed two files' '
1027 rm -fr outdir &&
1028 git format-patch -2 -o outdir &&
1029 git send-email \
1030 --dry-run \
1031 --from="Example <nobody@example.com>" \
1032 --to=nobody@example.com \
1033 outdir/000?-*.patch 2>errors >out &&
1034 grep "^Subject: " out >subjects &&
1035 test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." &&
1036 test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add master"
1039 test_expect_success $PREREQ 'in-reply-to but no threading' '
1040 git send-email \
1041 --dry-run \
1042 --from="Example <nobody@example.com>" \
1043 --to=nobody@example.com \
1044 --in-reply-to="<in-reply-id@example.com>" \
1045 --nothread \
1046 $patches |
1047 grep "In-Reply-To: <in-reply-id@example.com>"
1050 test_expect_success $PREREQ 'no in-reply-to and no threading' '
1051 git send-email \
1052 --dry-run \
1053 --from="Example <nobody@example.com>" \
1054 --to=nobody@example.com \
1055 --nothread \
1056 $patches $patches >stdout &&
1057 ! grep "In-Reply-To: " stdout
1060 test_expect_success $PREREQ 'threading but no chain-reply-to' '
1061 git send-email \
1062 --dry-run \
1063 --from="Example <nobody@example.com>" \
1064 --to=nobody@example.com \
1065 --thread \
1066 --nochain-reply-to \
1067 $patches $patches >stdout &&
1068 grep "In-Reply-To: " stdout
1071 test_expect_success $PREREQ 'warning with an implicit --chain-reply-to' '
1072 git send-email \
1073 --dry-run \
1074 --from="Example <nobody@example.com>" \
1075 --to=nobody@example.com \
1076 outdir/000?-*.patch 2>errors >out &&
1077 grep "no-chain-reply-to" errors
1080 test_expect_success $PREREQ 'no warning with an explicit --chain-reply-to' '
1081 git send-email \
1082 --dry-run \
1083 --from="Example <nobody@example.com>" \
1084 --to=nobody@example.com \
1085 --chain-reply-to \
1086 outdir/000?-*.patch 2>errors >out &&
1087 ! grep "no-chain-reply-to" errors
1090 test_expect_success $PREREQ 'no warning with an explicit --no-chain-reply-to' '
1091 git send-email \
1092 --dry-run \
1093 --from="Example <nobody@example.com>" \
1094 --to=nobody@example.com \
1095 --nochain-reply-to \
1096 outdir/000?-*.patch 2>errors >out &&
1097 ! grep "no-chain-reply-to" errors
1100 test_expect_success $PREREQ 'no warning with sendemail.chainreplyto = false' '
1101 git config sendemail.chainreplyto false &&
1102 git send-email \
1103 --dry-run \
1104 --from="Example <nobody@example.com>" \
1105 --to=nobody@example.com \
1106 outdir/000?-*.patch 2>errors >out &&
1107 ! grep "no-chain-reply-to" errors
1110 test_expect_success $PREREQ 'no warning with sendemail.chainreplyto = true' '
1111 git config sendemail.chainreplyto true &&
1112 git send-email \
1113 --dry-run \
1114 --from="Example <nobody@example.com>" \
1115 --to=nobody@example.com \
1116 outdir/000?-*.patch 2>errors >out &&
1117 ! grep "no-chain-reply-to" errors
1120 test_expect_success $PREREQ 'sendemail.to works' '
1121 git config --replace-all sendemail.to "Somebody <somebody@ex.com>" &&
1122 git send-email \
1123 --dry-run \
1124 --from="Example <nobody@example.com>" \
1125 $patches $patches >stdout &&
1126 grep "To: Somebody <somebody@ex.com>" stdout
1129 test_expect_success $PREREQ '--no-to overrides sendemail.to' '
1130 git send-email \
1131 --dry-run \
1132 --from="Example <nobody@example.com>" \
1133 --no-to \
1134 --to=nobody@example.com \
1135 $patches $patches >stdout &&
1136 grep "To: nobody@example.com" stdout &&
1137 ! grep "To: Somebody <somebody@ex.com>" stdout
1140 test_expect_success $PREREQ 'sendemail.cc works' '
1141 git config --replace-all sendemail.cc "Somebody <somebody@ex.com>" &&
1142 git send-email \
1143 --dry-run \
1144 --from="Example <nobody@example.com>" \
1145 --to=nobody@example.com \
1146 $patches $patches >stdout &&
1147 grep "Cc: Somebody <somebody@ex.com>" stdout
1150 test_expect_success $PREREQ '--no-cc overrides sendemail.cc' '
1151 git send-email \
1152 --dry-run \
1153 --from="Example <nobody@example.com>" \
1154 --no-cc \
1155 --cc=bodies@example.com \
1156 --to=nobody@example.com \
1157 $patches $patches >stdout &&
1158 grep "Cc: bodies@example.com" stdout &&
1159 ! grep "Cc: Somebody <somebody@ex.com>" stdout
1162 test_expect_success $PREREQ 'sendemail.bcc works' '
1163 git config --replace-all sendemail.bcc "Other <other@ex.com>" &&
1164 git send-email \
1165 --dry-run \
1166 --from="Example <nobody@example.com>" \
1167 --to=nobody@example.com \
1168 --smtp-server relay.example.com \
1169 $patches $patches >stdout &&
1170 grep "RCPT TO:<other@ex.com>" stdout
1173 test_expect_success $PREREQ '--no-bcc overrides sendemail.bcc' '
1174 git send-email \
1175 --dry-run \
1176 --from="Example <nobody@example.com>" \
1177 --no-bcc \
1178 --bcc=bodies@example.com \
1179 --to=nobody@example.com \
1180 --smtp-server relay.example.com \
1181 $patches $patches >stdout &&
1182 grep "RCPT TO:<bodies@example.com>" stdout &&
1183 ! grep "RCPT TO:<other@ex.com>" stdout
1186 test_expect_success $PREREQ 'patches To headers are used by default' '
1187 patch=`git format-patch -1 --to="bodies@example.com"` &&
1188 test_when_finished "rm $patch" &&
1189 git send-email \
1190 --dry-run \
1191 --from="Example <nobody@example.com>" \
1192 --smtp-server relay.example.com \
1193 $patch >stdout &&
1194 grep "RCPT TO:<bodies@example.com>" stdout
1197 test_expect_success $PREREQ 'patches To headers are appended to' '
1198 patch=`git format-patch -1 --to="bodies@example.com"` &&
1199 test_when_finished "rm $patch" &&
1200 git send-email \
1201 --dry-run \
1202 --from="Example <nobody@example.com>" \
1203 --to=nobody@example.com \
1204 --smtp-server relay.example.com \
1205 $patch >stdout &&
1206 grep "RCPT TO:<bodies@example.com>" stdout &&
1207 grep "RCPT TO:<nobody@example.com>" stdout
1210 test_expect_success $PREREQ 'To headers from files reset each patch' '
1211 patch1=`git format-patch -1 --to="bodies@example.com"` &&
1212 patch2=`git format-patch -1 --to="other@example.com" HEAD~` &&
1213 test_when_finished "rm $patch1 && rm $patch2" &&
1214 git send-email \
1215 --dry-run \
1216 --from="Example <nobody@example.com>" \
1217 --to="nobody@example.com" \
1218 --smtp-server relay.example.com \
1219 $patch1 $patch2 >stdout &&
1220 test $(grep -c "RCPT TO:<bodies@example.com>" stdout) = 1 &&
1221 test $(grep -c "RCPT TO:<nobody@example.com>" stdout) = 2 &&
1222 test $(grep -c "RCPT TO:<other@example.com>" stdout) = 1
1225 test_expect_success $PREREQ 'setup expect' '
1226 cat >email-using-8bit <<EOF
1227 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1228 Message-Id: <bogus-message-id@example.com>
1229 From: author@example.com
1230 Date: Sat, 12 Jun 2010 15:53:58 +0200
1231 Subject: subject goes here
1233 Dieser deutsche Text enthält einen Umlaut!
1237 test_expect_success $PREREQ 'setup expect' '
1238 cat >expected <<EOF
1239 Subject: subject goes here
1243 test_expect_success $PREREQ 'ASCII subject is not RFC2047 quoted' '
1244 clean_fake_sendmail &&
1245 echo bogus |
1246 git send-email --from=author@example.com --to=nobody@example.com \
1247 --smtp-server="$(pwd)/fake.sendmail" \
1248 --8bit-encoding=UTF-8 \
1249 email-using-8bit >stdout &&
1250 grep "Subject" msgtxt1 >actual &&
1251 test_cmp expected actual
1254 test_expect_success $PREREQ 'setup expect' '
1255 cat >content-type-decl <<EOF
1256 MIME-Version: 1.0
1257 Content-Type: text/plain; charset=UTF-8
1258 Content-Transfer-Encoding: 8bit
1262 test_expect_success $PREREQ 'asks about and fixes 8bit encodings' '
1263 clean_fake_sendmail &&
1264 echo |
1265 git send-email --from=author@example.com --to=nobody@example.com \
1266 --smtp-server="$(pwd)/fake.sendmail" \
1267 email-using-8bit >stdout &&
1268 grep "do not declare a Content-Transfer-Encoding" stdout &&
1269 grep email-using-8bit stdout &&
1270 grep "Which 8bit encoding" stdout &&
1271 egrep "Content|MIME" msgtxt1 >actual &&
1272 test_cmp actual content-type-decl
1275 test_expect_success $PREREQ 'sendemail.8bitEncoding works' '
1276 clean_fake_sendmail &&
1277 git config sendemail.assume8bitEncoding UTF-8 &&
1278 echo bogus |
1279 git send-email --from=author@example.com --to=nobody@example.com \
1280 --smtp-server="$(pwd)/fake.sendmail" \
1281 email-using-8bit >stdout &&
1282 egrep "Content|MIME" msgtxt1 >actual &&
1283 test_cmp actual content-type-decl
1286 test_expect_success $PREREQ '--8bit-encoding overrides sendemail.8bitEncoding' '
1287 clean_fake_sendmail &&
1288 git config sendemail.assume8bitEncoding "bogus too" &&
1289 echo bogus |
1290 git send-email --from=author@example.com --to=nobody@example.com \
1291 --smtp-server="$(pwd)/fake.sendmail" \
1292 --8bit-encoding=UTF-8 \
1293 email-using-8bit >stdout &&
1294 egrep "Content|MIME" msgtxt1 >actual &&
1295 test_cmp actual content-type-decl
1298 test_expect_success $PREREQ 'setup expect' '
1299 cat >email-using-8bit <<EOF
1300 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1301 Message-Id: <bogus-message-id@example.com>
1302 From: author@example.com
1303 Date: Sat, 12 Jun 2010 15:53:58 +0200
1304 Subject: Dieser Betreff enthält auch einen Umlaut!
1306 Nothing to see here.
1310 test_expect_success $PREREQ 'setup expect' '
1311 cat >expected <<EOF
1312 Subject: =?UTF-8?q?Dieser=20Betreff=20enth=C3=A4lt=20auch=20einen=20Umlaut!?=
1316 test_expect_success $PREREQ '--8bit-encoding also treats subject' '
1317 clean_fake_sendmail &&
1318 echo bogus |
1319 git send-email --from=author@example.com --to=nobody@example.com \
1320 --smtp-server="$(pwd)/fake.sendmail" \
1321 --8bit-encoding=UTF-8 \
1322 email-using-8bit >stdout &&
1323 grep "Subject" msgtxt1 >actual &&
1324 test_cmp expected actual
1327 # Note that the patches in this test are deliberately out of order; we
1328 # want to make sure it works even if the cover-letter is not in the
1329 # first mail.
1330 test_expect_success $PREREQ 'refusing to send cover letter template' '
1331 clean_fake_sendmail &&
1332 rm -fr outdir &&
1333 git format-patch --cover-letter -2 -o outdir &&
1334 test_must_fail git send-email \
1335 --from="Example <nobody@example.com>" \
1336 --to=nobody@example.com \
1337 --smtp-server="$(pwd)/fake.sendmail" \
1338 outdir/0002-*.patch \
1339 outdir/0000-*.patch \
1340 outdir/0001-*.patch \
1341 2>errors >out &&
1342 grep "SUBJECT HERE" errors &&
1343 test -z "$(ls msgtxt*)"
1346 test_expect_success $PREREQ '--force sends cover letter template anyway' '
1347 clean_fake_sendmail &&
1348 rm -fr outdir &&
1349 git format-patch --cover-letter -2 -o outdir &&
1350 git send-email \
1351 --force \
1352 --from="Example <nobody@example.com>" \
1353 --to=nobody@example.com \
1354 --smtp-server="$(pwd)/fake.sendmail" \
1355 outdir/0002-*.patch \
1356 outdir/0000-*.patch \
1357 outdir/0001-*.patch \
1358 2>errors >out &&
1359 ! grep "SUBJECT HERE" errors &&
1360 test -n "$(ls msgtxt*)"
1363 test_expect_success $PREREQ 'sendemail.aliasfiletype=mailrc' '
1364 clean_fake_sendmail &&
1365 echo "alias sbd somebody@example.org" >.mailrc &&
1366 git config --replace-all sendemail.aliasesfile "$(pwd)/.mailrc" &&
1367 git config sendemail.aliasfiletype mailrc &&
1368 git send-email \
1369 --from="Example <nobody@example.com>" \
1370 --to=sbd \
1371 --smtp-server="$(pwd)/fake.sendmail" \
1372 outdir/0001-*.patch \
1373 2>errors >out &&
1374 grep "^!somebody@example\.org!$" commandline1
1377 test_expect_success $PREREQ 'sendemail.aliasfile=~/.mailrc' '
1378 clean_fake_sendmail &&
1379 echo "alias sbd someone@example.org" >~/.mailrc &&
1380 git config --replace-all sendemail.aliasesfile "~/.mailrc" &&
1381 git config sendemail.aliasfiletype mailrc &&
1382 git send-email \
1383 --from="Example <nobody@example.com>" \
1384 --to=sbd \
1385 --smtp-server="$(pwd)/fake.sendmail" \
1386 outdir/0001-*.patch \
1387 2>errors >out &&
1388 grep "^!someone@example\.org!$" commandline1
1391 test_done