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