Merge branch 'jc/rev-parse-argh-dashed-multi-words'
[git/jrn.git] / t / t9001-send-email.sh
blob1ecdacb6fd0ceb7e43e6ec3bad018e7b6dc8100b
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 test_expect_success $PREREQ 'sanitized self name is suppressed' "
244 test_suppress_self_unquoted '\"A U. Thor\"' 'author@example.com' \
245 'self_name_sanitized_suppressed'
248 test_expect_success $PREREQ 'Show all headers' '
249 git send-email \
250 --dry-run \
251 --suppress-cc=sob \
252 --from="Example <from@example.com>" \
253 --to=to@example.com \
254 --cc=cc@example.com \
255 --bcc=bcc@example.com \
256 --in-reply-to="<unique-message-id@example.com>" \
257 --smtp-server relay.example.com \
258 $patches |
259 sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
260 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
261 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
262 >actual-show-all-headers &&
263 test_cmp expected-show-all-headers actual-show-all-headers
266 test_expect_success $PREREQ 'Prompting works' '
267 clean_fake_sendmail &&
268 (echo "to@example.com"
269 echo ""
270 ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
271 --smtp-server="$(pwd)/fake.sendmail" \
272 $patches \
273 2>errors &&
274 grep "^From: A U Thor <author@example.com>\$" msgtxt1 &&
275 grep "^To: to@example.com\$" msgtxt1
278 test_expect_success $PREREQ,AUTOIDENT 'implicit ident is allowed' '
279 clean_fake_sendmail &&
280 (sane_unset GIT_AUTHOR_NAME &&
281 sane_unset GIT_AUTHOR_EMAIL &&
282 sane_unset GIT_COMMITTER_NAME &&
283 sane_unset GIT_COMMITTER_EMAIL &&
284 GIT_SEND_EMAIL_NOTTY=1 git send-email \
285 --smtp-server="$(pwd)/fake.sendmail" \
286 --to=to@example.com \
287 $patches </dev/null 2>errors
291 test_expect_success $PREREQ,!AUTOIDENT 'broken implicit ident aborts send-email' '
292 clean_fake_sendmail &&
293 (sane_unset GIT_AUTHOR_NAME &&
294 sane_unset GIT_AUTHOR_EMAIL &&
295 sane_unset GIT_COMMITTER_NAME &&
296 sane_unset GIT_COMMITTER_EMAIL &&
297 GIT_SEND_EMAIL_NOTTY=1 && export GIT_SEND_EMAIL_NOTTY &&
298 test_must_fail git send-email \
299 --smtp-server="$(pwd)/fake.sendmail" \
300 --to=to@example.com \
301 $patches </dev/null 2>errors &&
302 test_i18ngrep "tell me who you are" errors
306 test_expect_success $PREREQ 'tocmd works' '
307 clean_fake_sendmail &&
308 cp $patches tocmd.patch &&
309 echo tocmd--tocmd@example.com >>tocmd.patch &&
311 echo "#!$SHELL_PATH"
312 echo sed -n -e s/^tocmd--//p \"\$1\"
313 } > tocmd-sed &&
314 chmod +x tocmd-sed &&
315 git send-email \
316 --from="Example <nobody@example.com>" \
317 --to-cmd=./tocmd-sed \
318 --smtp-server="$(pwd)/fake.sendmail" \
319 tocmd.patch \
321 grep "^To: tocmd@example.com" msgtxt1
324 test_expect_success $PREREQ 'cccmd works' '
325 clean_fake_sendmail &&
326 cp $patches cccmd.patch &&
327 echo "cccmd-- cccmd@example.com" >>cccmd.patch &&
329 echo "#!$SHELL_PATH"
330 echo sed -n -e s/^cccmd--//p \"\$1\"
331 } > cccmd-sed &&
332 chmod +x cccmd-sed &&
333 git send-email \
334 --from="Example <nobody@example.com>" \
335 --to=nobody@example.com \
336 --cc-cmd=./cccmd-sed \
337 --smtp-server="$(pwd)/fake.sendmail" \
338 cccmd.patch \
340 grep "^ cccmd@example.com" msgtxt1
343 test_expect_success $PREREQ 'reject long lines' '
344 z8=zzzzzzzz &&
345 z64=$z8$z8$z8$z8$z8$z8$z8$z8 &&
346 z512=$z64$z64$z64$z64$z64$z64$z64$z64 &&
347 clean_fake_sendmail &&
348 cp $patches longline.patch &&
349 echo $z512$z512 >>longline.patch &&
350 test_must_fail git send-email \
351 --from="Example <nobody@example.com>" \
352 --to=nobody@example.com \
353 --smtp-server="$(pwd)/fake.sendmail" \
354 $patches longline.patch \
355 2>errors &&
356 grep longline.patch errors
359 test_expect_success $PREREQ 'no patch was sent' '
360 ! test -e commandline1
363 test_expect_success $PREREQ 'Author From: in message body' '
364 clean_fake_sendmail &&
365 git send-email \
366 --from="Example <nobody@example.com>" \
367 --to=nobody@example.com \
368 --smtp-server="$(pwd)/fake.sendmail" \
369 $patches &&
370 sed "1,/^\$/d" < msgtxt1 > msgbody1 &&
371 grep "From: A <author@example.com>" msgbody1
374 test_expect_success $PREREQ 'Author From: not in message body' '
375 clean_fake_sendmail &&
376 git send-email \
377 --from="A <author@example.com>" \
378 --to=nobody@example.com \
379 --smtp-server="$(pwd)/fake.sendmail" \
380 $patches &&
381 sed "1,/^\$/d" < msgtxt1 > msgbody1 &&
382 ! grep "From: A <author@example.com>" msgbody1
385 test_expect_success $PREREQ 'allow long lines with --no-validate' '
386 git send-email \
387 --from="Example <nobody@example.com>" \
388 --to=nobody@example.com \
389 --smtp-server="$(pwd)/fake.sendmail" \
390 --novalidate \
391 $patches longline.patch \
392 2>errors
395 test_expect_success $PREREQ 'Invalid In-Reply-To' '
396 clean_fake_sendmail &&
397 git send-email \
398 --from="Example <nobody@example.com>" \
399 --to=nobody@example.com \
400 --in-reply-to=" " \
401 --smtp-server="$(pwd)/fake.sendmail" \
402 $patches \
403 2>errors &&
404 ! grep "^In-Reply-To: < *>" msgtxt1
407 test_expect_success $PREREQ 'Valid In-Reply-To when prompting' '
408 clean_fake_sendmail &&
409 (echo "From Example <from@example.com>"
410 echo "To Example <to@example.com>"
411 echo ""
412 ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
413 --smtp-server="$(pwd)/fake.sendmail" \
414 $patches 2>errors &&
415 ! grep "^In-Reply-To: < *>" msgtxt1
418 test_expect_success $PREREQ 'In-Reply-To without --chain-reply-to' '
419 clean_fake_sendmail &&
420 echo "<unique-message-id@example.com>" >expect &&
421 git send-email \
422 --from="Example <nobody@example.com>" \
423 --to=nobody@example.com \
424 --nochain-reply-to \
425 --in-reply-to="$(cat expect)" \
426 --smtp-server="$(pwd)/fake.sendmail" \
427 $patches $patches $patches \
428 2>errors &&
429 # The first message is a reply to --in-reply-to
430 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual &&
431 test_cmp expect actual &&
432 # Second and subsequent messages are replies to the first one
433 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect &&
434 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual &&
435 test_cmp expect actual &&
436 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual &&
437 test_cmp expect actual
440 test_expect_success $PREREQ 'In-Reply-To with --chain-reply-to' '
441 clean_fake_sendmail &&
442 echo "<unique-message-id@example.com>" >expect &&
443 git send-email \
444 --from="Example <nobody@example.com>" \
445 --to=nobody@example.com \
446 --chain-reply-to \
447 --in-reply-to="$(cat expect)" \
448 --smtp-server="$(pwd)/fake.sendmail" \
449 $patches $patches $patches \
450 2>errors &&
451 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual &&
452 test_cmp expect actual &&
453 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect &&
454 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual &&
455 test_cmp expect actual &&
456 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt2 >expect &&
457 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual &&
458 test_cmp expect actual
461 test_expect_success $PREREQ 'setup fake editor' '
462 (echo "#!$SHELL_PATH" &&
463 echo "echo fake edit >>\"\$1\""
464 ) >fake-editor &&
465 chmod +x fake-editor
468 test_set_editor "$(pwd)/fake-editor"
470 test_expect_success $PREREQ '--compose works' '
471 clean_fake_sendmail &&
472 git send-email \
473 --compose --subject foo \
474 --from="Example <nobody@example.com>" \
475 --to=nobody@example.com \
476 --smtp-server="$(pwd)/fake.sendmail" \
477 $patches \
478 2>errors
481 test_expect_success $PREREQ 'first message is compose text' '
482 grep "^fake edit" msgtxt1
485 test_expect_success $PREREQ 'second message is patch' '
486 grep "Subject:.*Second" msgtxt2
489 test_expect_success $PREREQ 'setup expect' "
490 cat >expected-suppress-sob <<\EOF
491 0001-Second.patch
492 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
493 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
494 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
495 Dry-OK. Log says:
496 Server: relay.example.com
497 MAIL FROM:<from@example.com>
498 RCPT TO:<to@example.com>
499 RCPT TO:<cc@example.com>
500 RCPT TO:<author@example.com>
501 RCPT TO:<one@example.com>
502 RCPT TO:<two@example.com>
503 From: Example <from@example.com>
504 To: to@example.com
505 Cc: cc@example.com,
506 A <author@example.com>,
507 One <one@example.com>,
508 two@example.com
509 Subject: [PATCH 1/1] Second.
510 Date: DATE-STRING
511 Message-Id: MESSAGE-ID-STRING
512 X-Mailer: X-MAILER-STRING
514 Result: OK
518 test_suppression () {
519 git send-email \
520 --dry-run \
521 --suppress-cc=$1 ${2+"--suppress-cc=$2"} \
522 --from="Example <from@example.com>" \
523 --to=to@example.com \
524 --smtp-server relay.example.com \
525 $patches |
526 sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
527 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
528 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
529 >actual-suppress-$1${2+"-$2"} &&
530 test_cmp expected-suppress-$1${2+"-$2"} actual-suppress-$1${2+"-$2"}
533 test_expect_success $PREREQ 'sendemail.cc set' '
534 git config sendemail.cc cc@example.com &&
535 test_suppression sob
538 test_expect_success $PREREQ 'setup expect' "
539 cat >expected-suppress-sob <<\EOF
540 0001-Second.patch
541 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
542 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
543 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
544 Dry-OK. Log says:
545 Server: relay.example.com
546 MAIL FROM:<from@example.com>
547 RCPT TO:<to@example.com>
548 RCPT TO:<author@example.com>
549 RCPT TO:<one@example.com>
550 RCPT TO:<two@example.com>
551 From: Example <from@example.com>
552 To: to@example.com
553 Cc: A <author@example.com>,
554 One <one@example.com>,
555 two@example.com
556 Subject: [PATCH 1/1] Second.
557 Date: DATE-STRING
558 Message-Id: MESSAGE-ID-STRING
559 X-Mailer: X-MAILER-STRING
561 Result: OK
565 test_expect_success $PREREQ 'sendemail.cc unset' '
566 git config --unset sendemail.cc &&
567 test_suppression sob
570 test_expect_success $PREREQ 'setup expect' "
571 cat >expected-suppress-cccmd <<\EOF
572 0001-Second.patch
573 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
574 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
575 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
576 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
577 Dry-OK. Log says:
578 Server: relay.example.com
579 MAIL FROM:<from@example.com>
580 RCPT TO:<to@example.com>
581 RCPT TO:<author@example.com>
582 RCPT TO:<one@example.com>
583 RCPT TO:<two@example.com>
584 RCPT TO:<committer@example.com>
585 From: Example <from@example.com>
586 To: to@example.com
587 Cc: A <author@example.com>,
588 One <one@example.com>,
589 two@example.com,
590 C O Mitter <committer@example.com>
591 Subject: [PATCH 1/1] Second.
592 Date: DATE-STRING
593 Message-Id: MESSAGE-ID-STRING
594 X-Mailer: X-MAILER-STRING
596 Result: OK
600 test_expect_success $PREREQ 'sendemail.cccmd' '
601 echo echo cc-cmd@example.com > cccmd &&
602 chmod +x cccmd &&
603 git config sendemail.cccmd ./cccmd &&
604 test_suppression cccmd
607 test_expect_success $PREREQ 'setup expect' '
608 cat >expected-suppress-all <<\EOF
609 0001-Second.patch
610 Dry-OK. Log says:
611 Server: relay.example.com
612 MAIL FROM:<from@example.com>
613 RCPT TO:<to@example.com>
614 From: Example <from@example.com>
615 To: to@example.com
616 Subject: [PATCH 1/1] Second.
617 Date: DATE-STRING
618 Message-Id: MESSAGE-ID-STRING
619 X-Mailer: X-MAILER-STRING
621 Result: OK
625 test_expect_success $PREREQ '--suppress-cc=all' '
626 test_suppression all
629 test_expect_success $PREREQ 'setup expect' "
630 cat >expected-suppress-body <<\EOF
631 0001-Second.patch
632 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
633 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
634 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
635 (cc-cmd) Adding cc: cc-cmd@example.com from: './cccmd'
636 Dry-OK. Log says:
637 Server: relay.example.com
638 MAIL FROM:<from@example.com>
639 RCPT TO:<to@example.com>
640 RCPT TO:<author@example.com>
641 RCPT TO:<one@example.com>
642 RCPT TO:<two@example.com>
643 RCPT TO:<cc-cmd@example.com>
644 From: Example <from@example.com>
645 To: to@example.com
646 Cc: A <author@example.com>,
647 One <one@example.com>,
648 two@example.com,
649 cc-cmd@example.com
650 Subject: [PATCH 1/1] Second.
651 Date: DATE-STRING
652 Message-Id: MESSAGE-ID-STRING
653 X-Mailer: X-MAILER-STRING
655 Result: OK
659 test_expect_success $PREREQ '--suppress-cc=body' '
660 test_suppression body
663 test_expect_success $PREREQ 'setup expect' "
664 cat >expected-suppress-body-cccmd <<\EOF
665 0001-Second.patch
666 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
667 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
668 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
669 Dry-OK. Log says:
670 Server: relay.example.com
671 MAIL FROM:<from@example.com>
672 RCPT TO:<to@example.com>
673 RCPT TO:<author@example.com>
674 RCPT TO:<one@example.com>
675 RCPT TO:<two@example.com>
676 From: Example <from@example.com>
677 To: to@example.com
678 Cc: A <author@example.com>,
679 One <one@example.com>,
680 two@example.com
681 Subject: [PATCH 1/1] Second.
682 Date: DATE-STRING
683 Message-Id: MESSAGE-ID-STRING
684 X-Mailer: X-MAILER-STRING
686 Result: OK
690 test_expect_success $PREREQ '--suppress-cc=body --suppress-cc=cccmd' '
691 test_suppression body cccmd
694 test_expect_success $PREREQ 'setup expect' "
695 cat >expected-suppress-sob <<\EOF
696 0001-Second.patch
697 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
698 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
699 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
700 Dry-OK. Log says:
701 Server: relay.example.com
702 MAIL FROM:<from@example.com>
703 RCPT TO:<to@example.com>
704 RCPT TO:<author@example.com>
705 RCPT TO:<one@example.com>
706 RCPT TO:<two@example.com>
707 From: Example <from@example.com>
708 To: to@example.com
709 Cc: A <author@example.com>,
710 One <one@example.com>,
711 two@example.com
712 Subject: [PATCH 1/1] Second.
713 Date: DATE-STRING
714 Message-Id: MESSAGE-ID-STRING
715 X-Mailer: X-MAILER-STRING
717 Result: OK
721 test_expect_success $PREREQ '--suppress-cc=sob' '
722 test_might_fail git config --unset sendemail.cccmd &&
723 test_suppression sob
726 test_expect_success $PREREQ 'setup expect' "
727 cat >expected-suppress-bodycc <<\EOF
728 0001-Second.patch
729 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
730 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
731 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
732 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
733 Dry-OK. Log says:
734 Server: relay.example.com
735 MAIL FROM:<from@example.com>
736 RCPT TO:<to@example.com>
737 RCPT TO:<author@example.com>
738 RCPT TO:<one@example.com>
739 RCPT TO:<two@example.com>
740 RCPT TO:<committer@example.com>
741 From: Example <from@example.com>
742 To: to@example.com
743 Cc: A <author@example.com>,
744 One <one@example.com>,
745 two@example.com,
746 C O Mitter <committer@example.com>
747 Subject: [PATCH 1/1] Second.
748 Date: DATE-STRING
749 Message-Id: MESSAGE-ID-STRING
750 X-Mailer: X-MAILER-STRING
752 Result: OK
756 test_expect_success $PREREQ '--suppress-cc=bodycc' '
757 test_suppression bodycc
760 test_expect_success $PREREQ 'setup expect' "
761 cat >expected-suppress-cc <<\EOF
762 0001-Second.patch
763 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
764 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
765 Dry-OK. Log says:
766 Server: relay.example.com
767 MAIL FROM:<from@example.com>
768 RCPT TO:<to@example.com>
769 RCPT TO:<author@example.com>
770 RCPT TO:<committer@example.com>
771 From: Example <from@example.com>
772 To: to@example.com
773 Cc: A <author@example.com>,
774 C O Mitter <committer@example.com>
775 Subject: [PATCH 1/1] Second.
776 Date: DATE-STRING
777 Message-Id: MESSAGE-ID-STRING
778 X-Mailer: X-MAILER-STRING
780 Result: OK
784 test_expect_success $PREREQ '--suppress-cc=cc' '
785 test_suppression cc
788 test_confirm () {
789 echo y | \
790 GIT_SEND_EMAIL_NOTTY=1 \
791 git send-email \
792 --from="Example <nobody@example.com>" \
793 --to=nobody@example.com \
794 --smtp-server="$(pwd)/fake.sendmail" \
795 $@ $patches > stdout &&
796 grep "Send this email" stdout
799 test_expect_success $PREREQ '--confirm=always' '
800 test_confirm --confirm=always --suppress-cc=all
803 test_expect_success $PREREQ '--confirm=auto' '
804 test_confirm --confirm=auto
807 test_expect_success $PREREQ '--confirm=cc' '
808 test_confirm --confirm=cc
811 test_expect_success $PREREQ '--confirm=compose' '
812 test_confirm --confirm=compose --compose
815 test_expect_success $PREREQ 'confirm by default (due to cc)' '
816 CONFIRM=$(git config --get sendemail.confirm) &&
817 git config --unset sendemail.confirm &&
818 test_confirm
819 ret="$?"
820 git config sendemail.confirm ${CONFIRM:-never}
821 test $ret = "0"
824 test_expect_success $PREREQ 'confirm by default (due to --compose)' '
825 CONFIRM=$(git config --get sendemail.confirm) &&
826 git config --unset sendemail.confirm &&
827 test_confirm --suppress-cc=all --compose
828 ret="$?"
829 git config sendemail.confirm ${CONFIRM:-never}
830 test $ret = "0"
833 test_expect_success $PREREQ 'confirm detects EOF (inform assumes y)' '
834 CONFIRM=$(git config --get sendemail.confirm) &&
835 git config --unset sendemail.confirm &&
836 rm -fr outdir &&
837 git format-patch -2 -o outdir &&
838 GIT_SEND_EMAIL_NOTTY=1 \
839 git send-email \
840 --from="Example <nobody@example.com>" \
841 --to=nobody@example.com \
842 --smtp-server="$(pwd)/fake.sendmail" \
843 outdir/*.patch < /dev/null
844 ret="$?"
845 git config sendemail.confirm ${CONFIRM:-never}
846 test $ret = "0"
849 test_expect_success $PREREQ 'confirm detects EOF (auto causes failure)' '
850 CONFIRM=$(git config --get sendemail.confirm) &&
851 git config sendemail.confirm auto &&
852 GIT_SEND_EMAIL_NOTTY=1 &&
853 export GIT_SEND_EMAIL_NOTTY &&
854 test_must_fail git send-email \
855 --from="Example <nobody@example.com>" \
856 --to=nobody@example.com \
857 --smtp-server="$(pwd)/fake.sendmail" \
858 $patches < /dev/null
859 ret="$?"
860 git config sendemail.confirm ${CONFIRM:-never}
861 test $ret = "0"
864 test_expect_success $PREREQ 'confirm does not loop forever' '
865 CONFIRM=$(git config --get sendemail.confirm) &&
866 git config sendemail.confirm auto &&
867 GIT_SEND_EMAIL_NOTTY=1 &&
868 export GIT_SEND_EMAIL_NOTTY &&
869 yes "bogus" | test_must_fail git send-email \
870 --from="Example <nobody@example.com>" \
871 --to=nobody@example.com \
872 --smtp-server="$(pwd)/fake.sendmail" \
873 $patches
874 ret="$?"
875 git config sendemail.confirm ${CONFIRM:-never}
876 test $ret = "0"
879 test_expect_success $PREREQ 'utf8 Cc is rfc2047 encoded' '
880 clean_fake_sendmail &&
881 rm -fr outdir &&
882 git format-patch -1 -o outdir --cc="àéìöú <utf8@example.com>" &&
883 git send-email \
884 --from="Example <nobody@example.com>" \
885 --to=nobody@example.com \
886 --smtp-server="$(pwd)/fake.sendmail" \
887 outdir/*.patch &&
888 grep "^ " msgtxt1 |
889 grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>"
892 test_expect_success $PREREQ '--compose adds MIME for utf8 body' '
893 clean_fake_sendmail &&
894 (echo "#!$SHELL_PATH" &&
895 echo "echo utf8 body: àéìöú >>\"\$1\""
896 ) >fake-editor-utf8 &&
897 chmod +x fake-editor-utf8 &&
898 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
899 git send-email \
900 --compose --subject foo \
901 --from="Example <nobody@example.com>" \
902 --to=nobody@example.com \
903 --smtp-server="$(pwd)/fake.sendmail" \
904 $patches &&
905 grep "^utf8 body" msgtxt1 &&
906 grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
909 test_expect_success $PREREQ '--compose respects user mime type' '
910 clean_fake_sendmail &&
911 (echo "#!$SHELL_PATH" &&
912 echo "(echo MIME-Version: 1.0"
913 echo " echo Content-Type: text/plain\\; charset=iso-8859-1"
914 echo " echo Content-Transfer-Encoding: 8bit"
915 echo " echo Subject: foo"
916 echo " echo "
917 echo " echo utf8 body: àéìöú) >\"\$1\""
918 ) >fake-editor-utf8-mime &&
919 chmod +x fake-editor-utf8-mime &&
920 GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \
921 git send-email \
922 --compose --subject foo \
923 --from="Example <nobody@example.com>" \
924 --to=nobody@example.com \
925 --smtp-server="$(pwd)/fake.sendmail" \
926 $patches &&
927 grep "^utf8 body" msgtxt1 &&
928 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 &&
929 ! grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
932 test_expect_success $PREREQ '--compose adds MIME for utf8 subject' '
933 clean_fake_sendmail &&
934 GIT_EDITOR="\"$(pwd)/fake-editor\"" \
935 git send-email \
936 --compose --subject utf8-sübjëct \
937 --from="Example <nobody@example.com>" \
938 --to=nobody@example.com \
939 --smtp-server="$(pwd)/fake.sendmail" \
940 $patches &&
941 grep "^fake edit" msgtxt1 &&
942 grep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
945 test_expect_success $PREREQ 'utf8 author is correctly passed on' '
946 clean_fake_sendmail &&
947 test_commit weird_author &&
948 test_when_finished "git reset --hard HEAD^" &&
949 git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" &&
950 git format-patch --stdout -1 >funny_name.patch &&
951 git send-email --from="Example <nobody@example.com>" \
952 --to=nobody@example.com \
953 --smtp-server="$(pwd)/fake.sendmail" \
954 funny_name.patch &&
955 grep "^From: Füñný Nâmé <odd_?=mail@example.com>" msgtxt1
958 test_expect_success $PREREQ 'utf8 sender is not duplicated' '
959 clean_fake_sendmail &&
960 test_commit weird_sender &&
961 test_when_finished "git reset --hard HEAD^" &&
962 git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" &&
963 git format-patch --stdout -1 >funny_name.patch &&
964 git send-email --from="Füñný Nâmé <odd_?=mail@example.com>" \
965 --to=nobody@example.com \
966 --smtp-server="$(pwd)/fake.sendmail" \
967 funny_name.patch &&
968 grep "^From: " msgtxt1 >msgfrom &&
969 test_line_count = 1 msgfrom
972 test_expect_success $PREREQ 'sendemail.composeencoding works' '
973 clean_fake_sendmail &&
974 git config sendemail.composeencoding iso-8859-1 &&
975 (echo "#!$SHELL_PATH" &&
976 echo "echo utf8 body: àéìöú >>\"\$1\""
977 ) >fake-editor-utf8 &&
978 chmod +x fake-editor-utf8 &&
979 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
980 git send-email \
981 --compose --subject foo \
982 --from="Example <nobody@example.com>" \
983 --to=nobody@example.com \
984 --smtp-server="$(pwd)/fake.sendmail" \
985 $patches &&
986 grep "^utf8 body" msgtxt1 &&
987 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1
990 test_expect_success $PREREQ '--compose-encoding works' '
991 clean_fake_sendmail &&
992 (echo "#!$SHELL_PATH" &&
993 echo "echo utf8 body: àéìöú >>\"\$1\""
994 ) >fake-editor-utf8 &&
995 chmod +x fake-editor-utf8 &&
996 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
997 git send-email \
998 --compose-encoding iso-8859-1 \
999 --compose --subject foo \
1000 --from="Example <nobody@example.com>" \
1001 --to=nobody@example.com \
1002 --smtp-server="$(pwd)/fake.sendmail" \
1003 $patches &&
1004 grep "^utf8 body" msgtxt1 &&
1005 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1
1008 test_expect_success $PREREQ '--compose-encoding overrides sendemail.composeencoding' '
1009 clean_fake_sendmail &&
1010 git config sendemail.composeencoding iso-8859-1 &&
1011 (echo "#!$SHELL_PATH" &&
1012 echo "echo utf8 body: àéìöú >>\"\$1\""
1013 ) >fake-editor-utf8 &&
1014 chmod +x fake-editor-utf8 &&
1015 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
1016 git send-email \
1017 --compose-encoding iso-8859-2 \
1018 --compose --subject foo \
1019 --from="Example <nobody@example.com>" \
1020 --to=nobody@example.com \
1021 --smtp-server="$(pwd)/fake.sendmail" \
1022 $patches &&
1023 grep "^utf8 body" msgtxt1 &&
1024 grep "^Content-Type: text/plain; charset=iso-8859-2" msgtxt1
1027 test_expect_success $PREREQ '--compose-encoding adds correct MIME for subject' '
1028 clean_fake_sendmail &&
1029 GIT_EDITOR="\"$(pwd)/fake-editor\"" \
1030 git send-email \
1031 --compose-encoding iso-8859-2 \
1032 --compose --subject utf8-sübjëct \
1033 --from="Example <nobody@example.com>" \
1034 --to=nobody@example.com \
1035 --smtp-server="$(pwd)/fake.sendmail" \
1036 $patches &&
1037 grep "^fake edit" msgtxt1 &&
1038 grep "^Subject: =?iso-8859-2?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
1041 test_expect_success $PREREQ 'detects ambiguous reference/file conflict' '
1042 echo master > master &&
1043 git add master &&
1044 git commit -m"add master" &&
1045 test_must_fail git send-email --dry-run master 2>errors &&
1046 grep disambiguate errors
1049 test_expect_success $PREREQ 'feed two files' '
1050 rm -fr outdir &&
1051 git format-patch -2 -o outdir &&
1052 git send-email \
1053 --dry-run \
1054 --from="Example <nobody@example.com>" \
1055 --to=nobody@example.com \
1056 outdir/000?-*.patch 2>errors >out &&
1057 grep "^Subject: " out >subjects &&
1058 test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." &&
1059 test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add master"
1062 test_expect_success $PREREQ 'in-reply-to but no threading' '
1063 git send-email \
1064 --dry-run \
1065 --from="Example <nobody@example.com>" \
1066 --to=nobody@example.com \
1067 --in-reply-to="<in-reply-id@example.com>" \
1068 --nothread \
1069 $patches |
1070 grep "In-Reply-To: <in-reply-id@example.com>"
1073 test_expect_success $PREREQ 'no in-reply-to and no threading' '
1074 git send-email \
1075 --dry-run \
1076 --from="Example <nobody@example.com>" \
1077 --to=nobody@example.com \
1078 --nothread \
1079 $patches $patches >stdout &&
1080 ! grep "In-Reply-To: " stdout
1083 test_expect_success $PREREQ 'threading but no chain-reply-to' '
1084 git send-email \
1085 --dry-run \
1086 --from="Example <nobody@example.com>" \
1087 --to=nobody@example.com \
1088 --thread \
1089 --nochain-reply-to \
1090 $patches $patches >stdout &&
1091 grep "In-Reply-To: " stdout
1094 test_expect_success $PREREQ 'sendemail.to works' '
1095 git config --replace-all sendemail.to "Somebody <somebody@ex.com>" &&
1096 git send-email \
1097 --dry-run \
1098 --from="Example <nobody@example.com>" \
1099 $patches $patches >stdout &&
1100 grep "To: Somebody <somebody@ex.com>" stdout
1103 test_expect_success $PREREQ '--no-to overrides sendemail.to' '
1104 git send-email \
1105 --dry-run \
1106 --from="Example <nobody@example.com>" \
1107 --no-to \
1108 --to=nobody@example.com \
1109 $patches $patches >stdout &&
1110 grep "To: nobody@example.com" stdout &&
1111 ! grep "To: Somebody <somebody@ex.com>" stdout
1114 test_expect_success $PREREQ 'sendemail.cc works' '
1115 git config --replace-all sendemail.cc "Somebody <somebody@ex.com>" &&
1116 git send-email \
1117 --dry-run \
1118 --from="Example <nobody@example.com>" \
1119 --to=nobody@example.com \
1120 $patches $patches >stdout &&
1121 grep "Cc: Somebody <somebody@ex.com>" stdout
1124 test_expect_success $PREREQ '--no-cc overrides sendemail.cc' '
1125 git send-email \
1126 --dry-run \
1127 --from="Example <nobody@example.com>" \
1128 --no-cc \
1129 --cc=bodies@example.com \
1130 --to=nobody@example.com \
1131 $patches $patches >stdout &&
1132 grep "Cc: bodies@example.com" stdout &&
1133 ! grep "Cc: Somebody <somebody@ex.com>" stdout
1136 test_expect_success $PREREQ 'sendemail.bcc works' '
1137 git config --replace-all sendemail.bcc "Other <other@ex.com>" &&
1138 git send-email \
1139 --dry-run \
1140 --from="Example <nobody@example.com>" \
1141 --to=nobody@example.com \
1142 --smtp-server relay.example.com \
1143 $patches $patches >stdout &&
1144 grep "RCPT TO:<other@ex.com>" stdout
1147 test_expect_success $PREREQ '--no-bcc overrides sendemail.bcc' '
1148 git send-email \
1149 --dry-run \
1150 --from="Example <nobody@example.com>" \
1151 --no-bcc \
1152 --bcc=bodies@example.com \
1153 --to=nobody@example.com \
1154 --smtp-server relay.example.com \
1155 $patches $patches >stdout &&
1156 grep "RCPT TO:<bodies@example.com>" stdout &&
1157 ! grep "RCPT TO:<other@ex.com>" stdout
1160 test_expect_success $PREREQ 'patches To headers are used by default' '
1161 patch=`git format-patch -1 --to="bodies@example.com"` &&
1162 test_when_finished "rm $patch" &&
1163 git send-email \
1164 --dry-run \
1165 --from="Example <nobody@example.com>" \
1166 --smtp-server relay.example.com \
1167 $patch >stdout &&
1168 grep "RCPT TO:<bodies@example.com>" stdout
1171 test_expect_success $PREREQ 'patches To headers are appended to' '
1172 patch=`git format-patch -1 --to="bodies@example.com"` &&
1173 test_when_finished "rm $patch" &&
1174 git send-email \
1175 --dry-run \
1176 --from="Example <nobody@example.com>" \
1177 --to=nobody@example.com \
1178 --smtp-server relay.example.com \
1179 $patch >stdout &&
1180 grep "RCPT TO:<bodies@example.com>" stdout &&
1181 grep "RCPT TO:<nobody@example.com>" stdout
1184 test_expect_success $PREREQ 'To headers from files reset each patch' '
1185 patch1=`git format-patch -1 --to="bodies@example.com"` &&
1186 patch2=`git format-patch -1 --to="other@example.com" HEAD~` &&
1187 test_when_finished "rm $patch1 && rm $patch2" &&
1188 git send-email \
1189 --dry-run \
1190 --from="Example <nobody@example.com>" \
1191 --to="nobody@example.com" \
1192 --smtp-server relay.example.com \
1193 $patch1 $patch2 >stdout &&
1194 test $(grep -c "RCPT TO:<bodies@example.com>" stdout) = 1 &&
1195 test $(grep -c "RCPT TO:<nobody@example.com>" stdout) = 2 &&
1196 test $(grep -c "RCPT TO:<other@example.com>" stdout) = 1
1199 test_expect_success $PREREQ 'setup expect' '
1200 cat >email-using-8bit <<EOF
1201 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1202 Message-Id: <bogus-message-id@example.com>
1203 From: author@example.com
1204 Date: Sat, 12 Jun 2010 15:53:58 +0200
1205 Subject: subject goes here
1207 Dieser deutsche Text enthält einen Umlaut!
1211 test_expect_success $PREREQ 'setup expect' '
1212 cat >expected <<EOF
1213 Subject: subject goes here
1217 test_expect_success $PREREQ 'ASCII subject is not RFC2047 quoted' '
1218 clean_fake_sendmail &&
1219 echo bogus |
1220 git send-email --from=author@example.com --to=nobody@example.com \
1221 --smtp-server="$(pwd)/fake.sendmail" \
1222 --8bit-encoding=UTF-8 \
1223 email-using-8bit >stdout &&
1224 grep "Subject" msgtxt1 >actual &&
1225 test_cmp expected actual
1228 test_expect_success $PREREQ 'setup expect' '
1229 cat >content-type-decl <<EOF
1230 MIME-Version: 1.0
1231 Content-Type: text/plain; charset=UTF-8
1232 Content-Transfer-Encoding: 8bit
1236 test_expect_success $PREREQ 'asks about and fixes 8bit encodings' '
1237 clean_fake_sendmail &&
1238 echo |
1239 git send-email --from=author@example.com --to=nobody@example.com \
1240 --smtp-server="$(pwd)/fake.sendmail" \
1241 email-using-8bit >stdout &&
1242 grep "do not declare a Content-Transfer-Encoding" stdout &&
1243 grep email-using-8bit stdout &&
1244 grep "Which 8bit encoding" stdout &&
1245 egrep "Content|MIME" msgtxt1 >actual &&
1246 test_cmp actual content-type-decl
1249 test_expect_success $PREREQ 'sendemail.8bitEncoding works' '
1250 clean_fake_sendmail &&
1251 git config sendemail.assume8bitEncoding UTF-8 &&
1252 echo bogus |
1253 git send-email --from=author@example.com --to=nobody@example.com \
1254 --smtp-server="$(pwd)/fake.sendmail" \
1255 email-using-8bit >stdout &&
1256 egrep "Content|MIME" msgtxt1 >actual &&
1257 test_cmp actual content-type-decl
1260 test_expect_success $PREREQ '--8bit-encoding overrides sendemail.8bitEncoding' '
1261 clean_fake_sendmail &&
1262 git config sendemail.assume8bitEncoding "bogus too" &&
1263 echo bogus |
1264 git send-email --from=author@example.com --to=nobody@example.com \
1265 --smtp-server="$(pwd)/fake.sendmail" \
1266 --8bit-encoding=UTF-8 \
1267 email-using-8bit >stdout &&
1268 egrep "Content|MIME" msgtxt1 >actual &&
1269 test_cmp actual content-type-decl
1272 test_expect_success $PREREQ 'setup expect' '
1273 cat >email-using-8bit <<EOF
1274 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1275 Message-Id: <bogus-message-id@example.com>
1276 From: author@example.com
1277 Date: Sat, 12 Jun 2010 15:53:58 +0200
1278 Subject: Dieser Betreff enthält auch einen Umlaut!
1280 Nothing to see here.
1284 test_expect_success $PREREQ 'setup expect' '
1285 cat >expected <<EOF
1286 Subject: =?UTF-8?q?Dieser=20Betreff=20enth=C3=A4lt=20auch=20einen=20Umlaut!?=
1290 test_expect_success $PREREQ '--8bit-encoding also treats subject' '
1291 clean_fake_sendmail &&
1292 echo bogus |
1293 git send-email --from=author@example.com --to=nobody@example.com \
1294 --smtp-server="$(pwd)/fake.sendmail" \
1295 --8bit-encoding=UTF-8 \
1296 email-using-8bit >stdout &&
1297 grep "Subject" msgtxt1 >actual &&
1298 test_cmp expected actual
1301 # Note that the patches in this test are deliberately out of order; we
1302 # want to make sure it works even if the cover-letter is not in the
1303 # first mail.
1304 test_expect_success $PREREQ 'refusing to send cover letter template' '
1305 clean_fake_sendmail &&
1306 rm -fr outdir &&
1307 git format-patch --cover-letter -2 -o outdir &&
1308 test_must_fail git send-email \
1309 --from="Example <nobody@example.com>" \
1310 --to=nobody@example.com \
1311 --smtp-server="$(pwd)/fake.sendmail" \
1312 outdir/0002-*.patch \
1313 outdir/0000-*.patch \
1314 outdir/0001-*.patch \
1315 2>errors >out &&
1316 grep "SUBJECT HERE" errors &&
1317 test -z "$(ls msgtxt*)"
1320 test_expect_success $PREREQ '--force sends cover letter template anyway' '
1321 clean_fake_sendmail &&
1322 rm -fr outdir &&
1323 git format-patch --cover-letter -2 -o outdir &&
1324 git send-email \
1325 --force \
1326 --from="Example <nobody@example.com>" \
1327 --to=nobody@example.com \
1328 --smtp-server="$(pwd)/fake.sendmail" \
1329 outdir/0002-*.patch \
1330 outdir/0000-*.patch \
1331 outdir/0001-*.patch \
1332 2>errors >out &&
1333 ! grep "SUBJECT HERE" errors &&
1334 test -n "$(ls msgtxt*)"
1337 test_expect_success $PREREQ 'sendemail.aliasfiletype=mailrc' '
1338 clean_fake_sendmail &&
1339 echo "alias sbd somebody@example.org" >.mailrc &&
1340 git config --replace-all sendemail.aliasesfile "$(pwd)/.mailrc" &&
1341 git config sendemail.aliasfiletype mailrc &&
1342 git send-email \
1343 --from="Example <nobody@example.com>" \
1344 --to=sbd \
1345 --smtp-server="$(pwd)/fake.sendmail" \
1346 outdir/0001-*.patch \
1347 2>errors >out &&
1348 grep "^!somebody@example\.org!$" commandline1
1351 test_expect_success $PREREQ 'sendemail.aliasfile=~/.mailrc' '
1352 clean_fake_sendmail &&
1353 echo "alias sbd someone@example.org" >~/.mailrc &&
1354 git config --replace-all sendemail.aliasesfile "~/.mailrc" &&
1355 git config sendemail.aliasfiletype mailrc &&
1356 git send-email \
1357 --from="Example <nobody@example.com>" \
1358 --to=sbd \
1359 --smtp-server="$(pwd)/fake.sendmail" \
1360 outdir/0001-*.patch \
1361 2>errors >out &&
1362 grep "^!someone@example\.org!$" commandline1
1365 test_done