t/send-email.sh: add test for suppress-cc=self
[git/jrn.git] / t / t9001-send-email.sh
blobf4745ce7422cf7b8bb84a5f2ab77931574ba65af
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 Cc: $1 <$2>
208 Signed-off-by: $1 <$2>
212 test_expect_success $PREREQ 'self name is suppressed' "
213 test_suppress_self_unquoted 'A U Thor' 'author@redhat.com' \
214 'self_name_suppressed'
217 test_expect_success $PREREQ 'Show all headers' '
218 git send-email \
219 --dry-run \
220 --suppress-cc=sob \
221 --from="Example <from@example.com>" \
222 --to=to@example.com \
223 --cc=cc@example.com \
224 --bcc=bcc@example.com \
225 --in-reply-to="<unique-message-id@example.com>" \
226 --smtp-server relay.example.com \
227 $patches |
228 sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
229 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
230 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
231 >actual-show-all-headers &&
232 test_cmp expected-show-all-headers actual-show-all-headers
235 test_expect_success $PREREQ 'Prompting works' '
236 clean_fake_sendmail &&
237 (echo "to@example.com"
238 echo ""
239 ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
240 --smtp-server="$(pwd)/fake.sendmail" \
241 $patches \
242 2>errors &&
243 grep "^From: A U Thor <author@example.com>\$" msgtxt1 &&
244 grep "^To: to@example.com\$" msgtxt1
247 test_expect_success $PREREQ,AUTOIDENT 'implicit ident is allowed' '
248 clean_fake_sendmail &&
249 (sane_unset GIT_AUTHOR_NAME &&
250 sane_unset GIT_AUTHOR_EMAIL &&
251 sane_unset GIT_COMMITTER_NAME &&
252 sane_unset GIT_COMMITTER_EMAIL &&
253 GIT_SEND_EMAIL_NOTTY=1 git send-email \
254 --smtp-server="$(pwd)/fake.sendmail" \
255 --to=to@example.com \
256 $patches </dev/null 2>errors
260 test_expect_success $PREREQ,!AUTOIDENT 'broken implicit ident aborts send-email' '
261 clean_fake_sendmail &&
262 (sane_unset GIT_AUTHOR_NAME &&
263 sane_unset GIT_AUTHOR_EMAIL &&
264 sane_unset GIT_COMMITTER_NAME &&
265 sane_unset GIT_COMMITTER_EMAIL &&
266 GIT_SEND_EMAIL_NOTTY=1 && export GIT_SEND_EMAIL_NOTTY &&
267 test_must_fail git send-email \
268 --smtp-server="$(pwd)/fake.sendmail" \
269 --to=to@example.com \
270 $patches </dev/null 2>errors &&
271 test_i18ngrep "tell me who you are" errors
275 test_expect_success $PREREQ 'tocmd works' '
276 clean_fake_sendmail &&
277 cp $patches tocmd.patch &&
278 echo tocmd--tocmd@example.com >>tocmd.patch &&
280 echo "#!$SHELL_PATH"
281 echo sed -n -e s/^tocmd--//p \"\$1\"
282 } > tocmd-sed &&
283 chmod +x tocmd-sed &&
284 git send-email \
285 --from="Example <nobody@example.com>" \
286 --to-cmd=./tocmd-sed \
287 --smtp-server="$(pwd)/fake.sendmail" \
288 tocmd.patch \
290 grep "^To: tocmd@example.com" msgtxt1
293 test_expect_success $PREREQ 'cccmd works' '
294 clean_fake_sendmail &&
295 cp $patches cccmd.patch &&
296 echo "cccmd-- cccmd@example.com" >>cccmd.patch &&
298 echo "#!$SHELL_PATH"
299 echo sed -n -e s/^cccmd--//p \"\$1\"
300 } > cccmd-sed &&
301 chmod +x cccmd-sed &&
302 git send-email \
303 --from="Example <nobody@example.com>" \
304 --to=nobody@example.com \
305 --cc-cmd=./cccmd-sed \
306 --smtp-server="$(pwd)/fake.sendmail" \
307 cccmd.patch \
309 grep "^ cccmd@example.com" msgtxt1
312 test_expect_success $PREREQ 'reject long lines' '
313 z8=zzzzzzzz &&
314 z64=$z8$z8$z8$z8$z8$z8$z8$z8 &&
315 z512=$z64$z64$z64$z64$z64$z64$z64$z64 &&
316 clean_fake_sendmail &&
317 cp $patches longline.patch &&
318 echo $z512$z512 >>longline.patch &&
319 test_must_fail git send-email \
320 --from="Example <nobody@example.com>" \
321 --to=nobody@example.com \
322 --smtp-server="$(pwd)/fake.sendmail" \
323 $patches longline.patch \
324 2>errors &&
325 grep longline.patch errors
328 test_expect_success $PREREQ 'no patch was sent' '
329 ! test -e commandline1
332 test_expect_success $PREREQ 'Author From: in message body' '
333 clean_fake_sendmail &&
334 git send-email \
335 --from="Example <nobody@example.com>" \
336 --to=nobody@example.com \
337 --smtp-server="$(pwd)/fake.sendmail" \
338 $patches &&
339 sed "1,/^\$/d" < msgtxt1 > msgbody1 &&
340 grep "From: A <author@example.com>" msgbody1
343 test_expect_success $PREREQ 'Author From: not in message body' '
344 clean_fake_sendmail &&
345 git send-email \
346 --from="A <author@example.com>" \
347 --to=nobody@example.com \
348 --smtp-server="$(pwd)/fake.sendmail" \
349 $patches &&
350 sed "1,/^\$/d" < msgtxt1 > msgbody1 &&
351 ! grep "From: A <author@example.com>" msgbody1
354 test_expect_success $PREREQ 'allow long lines with --no-validate' '
355 git send-email \
356 --from="Example <nobody@example.com>" \
357 --to=nobody@example.com \
358 --smtp-server="$(pwd)/fake.sendmail" \
359 --novalidate \
360 $patches longline.patch \
361 2>errors
364 test_expect_success $PREREQ 'Invalid In-Reply-To' '
365 clean_fake_sendmail &&
366 git send-email \
367 --from="Example <nobody@example.com>" \
368 --to=nobody@example.com \
369 --in-reply-to=" " \
370 --smtp-server="$(pwd)/fake.sendmail" \
371 $patches \
372 2>errors &&
373 ! grep "^In-Reply-To: < *>" msgtxt1
376 test_expect_success $PREREQ 'Valid In-Reply-To when prompting' '
377 clean_fake_sendmail &&
378 (echo "From Example <from@example.com>"
379 echo "To Example <to@example.com>"
380 echo ""
381 ) | env GIT_SEND_EMAIL_NOTTY=1 git send-email \
382 --smtp-server="$(pwd)/fake.sendmail" \
383 $patches 2>errors &&
384 ! grep "^In-Reply-To: < *>" msgtxt1
387 test_expect_success $PREREQ 'In-Reply-To without --chain-reply-to' '
388 clean_fake_sendmail &&
389 echo "<unique-message-id@example.com>" >expect &&
390 git send-email \
391 --from="Example <nobody@example.com>" \
392 --to=nobody@example.com \
393 --nochain-reply-to \
394 --in-reply-to="$(cat expect)" \
395 --smtp-server="$(pwd)/fake.sendmail" \
396 $patches $patches $patches \
397 2>errors &&
398 # The first message is a reply to --in-reply-to
399 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual &&
400 test_cmp expect actual &&
401 # Second and subsequent messages are replies to the first one
402 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect &&
403 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual &&
404 test_cmp expect actual &&
405 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual &&
406 test_cmp expect actual
409 test_expect_success $PREREQ 'In-Reply-To with --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 --chain-reply-to \
416 --in-reply-to="$(cat expect)" \
417 --smtp-server="$(pwd)/fake.sendmail" \
418 $patches $patches $patches \
419 2>errors &&
420 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual &&
421 test_cmp expect actual &&
422 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect &&
423 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual &&
424 test_cmp expect actual &&
425 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt2 >expect &&
426 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual &&
427 test_cmp expect actual
430 test_expect_success $PREREQ 'setup fake editor' '
431 (echo "#!$SHELL_PATH" &&
432 echo "echo fake edit >>\"\$1\""
433 ) >fake-editor &&
434 chmod +x fake-editor
437 test_set_editor "$(pwd)/fake-editor"
439 test_expect_success $PREREQ '--compose works' '
440 clean_fake_sendmail &&
441 git send-email \
442 --compose --subject foo \
443 --from="Example <nobody@example.com>" \
444 --to=nobody@example.com \
445 --smtp-server="$(pwd)/fake.sendmail" \
446 $patches \
447 2>errors
450 test_expect_success $PREREQ 'first message is compose text' '
451 grep "^fake edit" msgtxt1
454 test_expect_success $PREREQ 'second message is patch' '
455 grep "Subject:.*Second" msgtxt2
458 test_expect_success $PREREQ 'setup expect' "
459 cat >expected-suppress-sob <<\EOF
460 0001-Second.patch
461 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
462 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
463 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
464 Dry-OK. Log says:
465 Server: relay.example.com
466 MAIL FROM:<from@example.com>
467 RCPT TO:<to@example.com>
468 RCPT TO:<cc@example.com>
469 RCPT TO:<author@example.com>
470 RCPT TO:<one@example.com>
471 RCPT TO:<two@example.com>
472 From: Example <from@example.com>
473 To: to@example.com
474 Cc: cc@example.com,
475 A <author@example.com>,
476 One <one@example.com>,
477 two@example.com
478 Subject: [PATCH 1/1] Second.
479 Date: DATE-STRING
480 Message-Id: MESSAGE-ID-STRING
481 X-Mailer: X-MAILER-STRING
483 Result: OK
487 test_suppression () {
488 git send-email \
489 --dry-run \
490 --suppress-cc=$1 ${2+"--suppress-cc=$2"} \
491 --from="Example <from@example.com>" \
492 --to=to@example.com \
493 --smtp-server relay.example.com \
494 $patches |
495 sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
496 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
497 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
498 >actual-suppress-$1${2+"-$2"} &&
499 test_cmp expected-suppress-$1${2+"-$2"} actual-suppress-$1${2+"-$2"}
502 test_expect_success $PREREQ 'sendemail.cc set' '
503 git config sendemail.cc cc@example.com &&
504 test_suppression sob
507 test_expect_success $PREREQ 'setup expect' "
508 cat >expected-suppress-sob <<\EOF
509 0001-Second.patch
510 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
511 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
512 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
513 Dry-OK. Log says:
514 Server: relay.example.com
515 MAIL FROM:<from@example.com>
516 RCPT TO:<to@example.com>
517 RCPT TO:<author@example.com>
518 RCPT TO:<one@example.com>
519 RCPT TO:<two@example.com>
520 From: Example <from@example.com>
521 To: to@example.com
522 Cc: A <author@example.com>,
523 One <one@example.com>,
524 two@example.com
525 Subject: [PATCH 1/1] Second.
526 Date: DATE-STRING
527 Message-Id: MESSAGE-ID-STRING
528 X-Mailer: X-MAILER-STRING
530 Result: OK
534 test_expect_success $PREREQ 'sendemail.cc unset' '
535 git config --unset sendemail.cc &&
536 test_suppression sob
539 test_expect_success $PREREQ 'setup expect' "
540 cat >expected-suppress-cccmd <<\EOF
541 0001-Second.patch
542 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
543 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
544 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
545 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
546 Dry-OK. Log says:
547 Server: relay.example.com
548 MAIL FROM:<from@example.com>
549 RCPT TO:<to@example.com>
550 RCPT TO:<author@example.com>
551 RCPT TO:<one@example.com>
552 RCPT TO:<two@example.com>
553 RCPT TO:<committer@example.com>
554 From: Example <from@example.com>
555 To: to@example.com
556 Cc: A <author@example.com>,
557 One <one@example.com>,
558 two@example.com,
559 C O Mitter <committer@example.com>
560 Subject: [PATCH 1/1] Second.
561 Date: DATE-STRING
562 Message-Id: MESSAGE-ID-STRING
563 X-Mailer: X-MAILER-STRING
565 Result: OK
569 test_expect_success $PREREQ 'sendemail.cccmd' '
570 echo echo cc-cmd@example.com > cccmd &&
571 chmod +x cccmd &&
572 git config sendemail.cccmd ./cccmd &&
573 test_suppression cccmd
576 test_expect_success $PREREQ 'setup expect' '
577 cat >expected-suppress-all <<\EOF
578 0001-Second.patch
579 Dry-OK. Log says:
580 Server: relay.example.com
581 MAIL FROM:<from@example.com>
582 RCPT TO:<to@example.com>
583 From: Example <from@example.com>
584 To: to@example.com
585 Subject: [PATCH 1/1] Second.
586 Date: DATE-STRING
587 Message-Id: MESSAGE-ID-STRING
588 X-Mailer: X-MAILER-STRING
590 Result: OK
594 test_expect_success $PREREQ '--suppress-cc=all' '
595 test_suppression all
598 test_expect_success $PREREQ 'setup expect' "
599 cat >expected-suppress-body <<\EOF
600 0001-Second.patch
601 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
602 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
603 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
604 (cc-cmd) Adding cc: cc-cmd@example.com from: './cccmd'
605 Dry-OK. Log says:
606 Server: relay.example.com
607 MAIL FROM:<from@example.com>
608 RCPT TO:<to@example.com>
609 RCPT TO:<author@example.com>
610 RCPT TO:<one@example.com>
611 RCPT TO:<two@example.com>
612 RCPT TO:<cc-cmd@example.com>
613 From: Example <from@example.com>
614 To: to@example.com
615 Cc: A <author@example.com>,
616 One <one@example.com>,
617 two@example.com,
618 cc-cmd@example.com
619 Subject: [PATCH 1/1] Second.
620 Date: DATE-STRING
621 Message-Id: MESSAGE-ID-STRING
622 X-Mailer: X-MAILER-STRING
624 Result: OK
628 test_expect_success $PREREQ '--suppress-cc=body' '
629 test_suppression body
632 test_expect_success $PREREQ 'setup expect' "
633 cat >expected-suppress-body-cccmd <<\EOF
634 0001-Second.patch
635 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
636 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
637 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
638 Dry-OK. Log says:
639 Server: relay.example.com
640 MAIL FROM:<from@example.com>
641 RCPT TO:<to@example.com>
642 RCPT TO:<author@example.com>
643 RCPT TO:<one@example.com>
644 RCPT TO:<two@example.com>
645 From: Example <from@example.com>
646 To: to@example.com
647 Cc: A <author@example.com>,
648 One <one@example.com>,
649 two@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 --suppress-cc=cccmd' '
660 test_suppression body cccmd
663 test_expect_success $PREREQ 'setup expect' "
664 cat >expected-suppress-sob <<\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=sob' '
691 test_might_fail git config --unset sendemail.cccmd &&
692 test_suppression sob
695 test_expect_success $PREREQ 'setup expect' "
696 cat >expected-suppress-bodycc <<\EOF
697 0001-Second.patch
698 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
699 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
700 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
701 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
702 Dry-OK. Log says:
703 Server: relay.example.com
704 MAIL FROM:<from@example.com>
705 RCPT TO:<to@example.com>
706 RCPT TO:<author@example.com>
707 RCPT TO:<one@example.com>
708 RCPT TO:<two@example.com>
709 RCPT TO:<committer@example.com>
710 From: Example <from@example.com>
711 To: to@example.com
712 Cc: A <author@example.com>,
713 One <one@example.com>,
714 two@example.com,
715 C O Mitter <committer@example.com>
716 Subject: [PATCH 1/1] Second.
717 Date: DATE-STRING
718 Message-Id: MESSAGE-ID-STRING
719 X-Mailer: X-MAILER-STRING
721 Result: OK
725 test_expect_success $PREREQ '--suppress-cc=bodycc' '
726 test_suppression bodycc
729 test_expect_success $PREREQ 'setup expect' "
730 cat >expected-suppress-cc <<\EOF
731 0001-Second.patch
732 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
733 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
734 Dry-OK. Log says:
735 Server: relay.example.com
736 MAIL FROM:<from@example.com>
737 RCPT TO:<to@example.com>
738 RCPT TO:<author@example.com>
739 RCPT TO:<committer@example.com>
740 From: Example <from@example.com>
741 To: to@example.com
742 Cc: A <author@example.com>,
743 C O Mitter <committer@example.com>
744 Subject: [PATCH 1/1] Second.
745 Date: DATE-STRING
746 Message-Id: MESSAGE-ID-STRING
747 X-Mailer: X-MAILER-STRING
749 Result: OK
753 test_expect_success $PREREQ '--suppress-cc=cc' '
754 test_suppression cc
757 test_confirm () {
758 echo y | \
759 GIT_SEND_EMAIL_NOTTY=1 \
760 git send-email \
761 --from="Example <nobody@example.com>" \
762 --to=nobody@example.com \
763 --smtp-server="$(pwd)/fake.sendmail" \
764 $@ $patches > stdout &&
765 grep "Send this email" stdout
768 test_expect_success $PREREQ '--confirm=always' '
769 test_confirm --confirm=always --suppress-cc=all
772 test_expect_success $PREREQ '--confirm=auto' '
773 test_confirm --confirm=auto
776 test_expect_success $PREREQ '--confirm=cc' '
777 test_confirm --confirm=cc
780 test_expect_success $PREREQ '--confirm=compose' '
781 test_confirm --confirm=compose --compose
784 test_expect_success $PREREQ 'confirm by default (due to cc)' '
785 CONFIRM=$(git config --get sendemail.confirm) &&
786 git config --unset sendemail.confirm &&
787 test_confirm
788 ret="$?"
789 git config sendemail.confirm ${CONFIRM:-never}
790 test $ret = "0"
793 test_expect_success $PREREQ 'confirm by default (due to --compose)' '
794 CONFIRM=$(git config --get sendemail.confirm) &&
795 git config --unset sendemail.confirm &&
796 test_confirm --suppress-cc=all --compose
797 ret="$?"
798 git config sendemail.confirm ${CONFIRM:-never}
799 test $ret = "0"
802 test_expect_success $PREREQ 'confirm detects EOF (inform assumes y)' '
803 CONFIRM=$(git config --get sendemail.confirm) &&
804 git config --unset sendemail.confirm &&
805 rm -fr outdir &&
806 git format-patch -2 -o outdir &&
807 GIT_SEND_EMAIL_NOTTY=1 \
808 git send-email \
809 --from="Example <nobody@example.com>" \
810 --to=nobody@example.com \
811 --smtp-server="$(pwd)/fake.sendmail" \
812 outdir/*.patch < /dev/null
813 ret="$?"
814 git config sendemail.confirm ${CONFIRM:-never}
815 test $ret = "0"
818 test_expect_success $PREREQ 'confirm detects EOF (auto causes failure)' '
819 CONFIRM=$(git config --get sendemail.confirm) &&
820 git config sendemail.confirm auto &&
821 GIT_SEND_EMAIL_NOTTY=1 &&
822 export GIT_SEND_EMAIL_NOTTY &&
823 test_must_fail git send-email \
824 --from="Example <nobody@example.com>" \
825 --to=nobody@example.com \
826 --smtp-server="$(pwd)/fake.sendmail" \
827 $patches < /dev/null
828 ret="$?"
829 git config sendemail.confirm ${CONFIRM:-never}
830 test $ret = "0"
833 test_expect_success $PREREQ 'confirm does not loop forever' '
834 CONFIRM=$(git config --get sendemail.confirm) &&
835 git config sendemail.confirm auto &&
836 GIT_SEND_EMAIL_NOTTY=1 &&
837 export GIT_SEND_EMAIL_NOTTY &&
838 yes "bogus" | test_must_fail git send-email \
839 --from="Example <nobody@example.com>" \
840 --to=nobody@example.com \
841 --smtp-server="$(pwd)/fake.sendmail" \
842 $patches
843 ret="$?"
844 git config sendemail.confirm ${CONFIRM:-never}
845 test $ret = "0"
848 test_expect_success $PREREQ 'utf8 Cc is rfc2047 encoded' '
849 clean_fake_sendmail &&
850 rm -fr outdir &&
851 git format-patch -1 -o outdir --cc="àéìöú <utf8@example.com>" &&
852 git send-email \
853 --from="Example <nobody@example.com>" \
854 --to=nobody@example.com \
855 --smtp-server="$(pwd)/fake.sendmail" \
856 outdir/*.patch &&
857 grep "^ " msgtxt1 |
858 grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>"
861 test_expect_success $PREREQ '--compose adds MIME for utf8 body' '
862 clean_fake_sendmail &&
863 (echo "#!$SHELL_PATH" &&
864 echo "echo utf8 body: àéìöú >>\"\$1\""
865 ) >fake-editor-utf8 &&
866 chmod +x fake-editor-utf8 &&
867 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
868 git send-email \
869 --compose --subject foo \
870 --from="Example <nobody@example.com>" \
871 --to=nobody@example.com \
872 --smtp-server="$(pwd)/fake.sendmail" \
873 $patches &&
874 grep "^utf8 body" msgtxt1 &&
875 grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
878 test_expect_success $PREREQ '--compose respects user mime type' '
879 clean_fake_sendmail &&
880 (echo "#!$SHELL_PATH" &&
881 echo "(echo MIME-Version: 1.0"
882 echo " echo Content-Type: text/plain\\; charset=iso-8859-1"
883 echo " echo Content-Transfer-Encoding: 8bit"
884 echo " echo Subject: foo"
885 echo " echo "
886 echo " echo utf8 body: àéìöú) >\"\$1\""
887 ) >fake-editor-utf8-mime &&
888 chmod +x fake-editor-utf8-mime &&
889 GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \
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=iso-8859-1" msgtxt1 &&
898 ! grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
901 test_expect_success $PREREQ '--compose adds MIME for utf8 subject' '
902 clean_fake_sendmail &&
903 GIT_EDITOR="\"$(pwd)/fake-editor\"" \
904 git send-email \
905 --compose --subject utf8-sübjëct \
906 --from="Example <nobody@example.com>" \
907 --to=nobody@example.com \
908 --smtp-server="$(pwd)/fake.sendmail" \
909 $patches &&
910 grep "^fake edit" msgtxt1 &&
911 grep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
914 test_expect_success $PREREQ 'utf8 author is correctly passed on' '
915 clean_fake_sendmail &&
916 test_commit weird_author &&
917 test_when_finished "git reset --hard HEAD^" &&
918 git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" &&
919 git format-patch --stdout -1 >funny_name.patch &&
920 git send-email --from="Example <nobody@example.com>" \
921 --to=nobody@example.com \
922 --smtp-server="$(pwd)/fake.sendmail" \
923 funny_name.patch &&
924 grep "^From: Füñný Nâmé <odd_?=mail@example.com>" msgtxt1
927 test_expect_success $PREREQ 'sendemail.composeencoding works' '
928 clean_fake_sendmail &&
929 git config sendemail.composeencoding iso-8859-1 &&
930 (echo "#!$SHELL_PATH" &&
931 echo "echo utf8 body: àéìöú >>\"\$1\""
932 ) >fake-editor-utf8 &&
933 chmod +x fake-editor-utf8 &&
934 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
935 git send-email \
936 --compose --subject foo \
937 --from="Example <nobody@example.com>" \
938 --to=nobody@example.com \
939 --smtp-server="$(pwd)/fake.sendmail" \
940 $patches &&
941 grep "^utf8 body" msgtxt1 &&
942 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1
945 test_expect_success $PREREQ '--compose-encoding works' '
946 clean_fake_sendmail &&
947 (echo "#!$SHELL_PATH" &&
948 echo "echo utf8 body: àéìöú >>\"\$1\""
949 ) >fake-editor-utf8 &&
950 chmod +x fake-editor-utf8 &&
951 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
952 git send-email \
953 --compose-encoding iso-8859-1 \
954 --compose --subject foo \
955 --from="Example <nobody@example.com>" \
956 --to=nobody@example.com \
957 --smtp-server="$(pwd)/fake.sendmail" \
958 $patches &&
959 grep "^utf8 body" msgtxt1 &&
960 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1
963 test_expect_success $PREREQ '--compose-encoding overrides sendemail.composeencoding' '
964 clean_fake_sendmail &&
965 git config sendemail.composeencoding iso-8859-1 &&
966 (echo "#!$SHELL_PATH" &&
967 echo "echo utf8 body: àéìöú >>\"\$1\""
968 ) >fake-editor-utf8 &&
969 chmod +x fake-editor-utf8 &&
970 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
971 git send-email \
972 --compose-encoding iso-8859-2 \
973 --compose --subject foo \
974 --from="Example <nobody@example.com>" \
975 --to=nobody@example.com \
976 --smtp-server="$(pwd)/fake.sendmail" \
977 $patches &&
978 grep "^utf8 body" msgtxt1 &&
979 grep "^Content-Type: text/plain; charset=iso-8859-2" msgtxt1
982 test_expect_success $PREREQ '--compose-encoding adds correct MIME for subject' '
983 clean_fake_sendmail &&
984 GIT_EDITOR="\"$(pwd)/fake-editor\"" \
985 git send-email \
986 --compose-encoding iso-8859-2 \
987 --compose --subject utf8-sübjëct \
988 --from="Example <nobody@example.com>" \
989 --to=nobody@example.com \
990 --smtp-server="$(pwd)/fake.sendmail" \
991 $patches &&
992 grep "^fake edit" msgtxt1 &&
993 grep "^Subject: =?iso-8859-2?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
996 test_expect_success $PREREQ 'detects ambiguous reference/file conflict' '
997 echo master > master &&
998 git add master &&
999 git commit -m"add master" &&
1000 test_must_fail git send-email --dry-run master 2>errors &&
1001 grep disambiguate errors
1004 test_expect_success $PREREQ 'feed two files' '
1005 rm -fr outdir &&
1006 git format-patch -2 -o outdir &&
1007 git send-email \
1008 --dry-run \
1009 --from="Example <nobody@example.com>" \
1010 --to=nobody@example.com \
1011 outdir/000?-*.patch 2>errors >out &&
1012 grep "^Subject: " out >subjects &&
1013 test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." &&
1014 test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add master"
1017 test_expect_success $PREREQ 'in-reply-to but no threading' '
1018 git send-email \
1019 --dry-run \
1020 --from="Example <nobody@example.com>" \
1021 --to=nobody@example.com \
1022 --in-reply-to="<in-reply-id@example.com>" \
1023 --nothread \
1024 $patches |
1025 grep "In-Reply-To: <in-reply-id@example.com>"
1028 test_expect_success $PREREQ 'no in-reply-to and no threading' '
1029 git send-email \
1030 --dry-run \
1031 --from="Example <nobody@example.com>" \
1032 --to=nobody@example.com \
1033 --nothread \
1034 $patches $patches >stdout &&
1035 ! grep "In-Reply-To: " stdout
1038 test_expect_success $PREREQ 'threading but no chain-reply-to' '
1039 git send-email \
1040 --dry-run \
1041 --from="Example <nobody@example.com>" \
1042 --to=nobody@example.com \
1043 --thread \
1044 --nochain-reply-to \
1045 $patches $patches >stdout &&
1046 grep "In-Reply-To: " stdout
1049 test_expect_success $PREREQ 'warning with an implicit --chain-reply-to' '
1050 git send-email \
1051 --dry-run \
1052 --from="Example <nobody@example.com>" \
1053 --to=nobody@example.com \
1054 outdir/000?-*.patch 2>errors >out &&
1055 grep "no-chain-reply-to" errors
1058 test_expect_success $PREREQ 'no warning with an explicit --chain-reply-to' '
1059 git send-email \
1060 --dry-run \
1061 --from="Example <nobody@example.com>" \
1062 --to=nobody@example.com \
1063 --chain-reply-to \
1064 outdir/000?-*.patch 2>errors >out &&
1065 ! grep "no-chain-reply-to" errors
1068 test_expect_success $PREREQ 'no warning with an explicit --no-chain-reply-to' '
1069 git send-email \
1070 --dry-run \
1071 --from="Example <nobody@example.com>" \
1072 --to=nobody@example.com \
1073 --nochain-reply-to \
1074 outdir/000?-*.patch 2>errors >out &&
1075 ! grep "no-chain-reply-to" errors
1078 test_expect_success $PREREQ 'no warning with sendemail.chainreplyto = false' '
1079 git config sendemail.chainreplyto false &&
1080 git send-email \
1081 --dry-run \
1082 --from="Example <nobody@example.com>" \
1083 --to=nobody@example.com \
1084 outdir/000?-*.patch 2>errors >out &&
1085 ! grep "no-chain-reply-to" errors
1088 test_expect_success $PREREQ 'no warning with sendemail.chainreplyto = true' '
1089 git config sendemail.chainreplyto true &&
1090 git send-email \
1091 --dry-run \
1092 --from="Example <nobody@example.com>" \
1093 --to=nobody@example.com \
1094 outdir/000?-*.patch 2>errors >out &&
1095 ! grep "no-chain-reply-to" errors
1098 test_expect_success $PREREQ 'sendemail.to works' '
1099 git config --replace-all sendemail.to "Somebody <somebody@ex.com>" &&
1100 git send-email \
1101 --dry-run \
1102 --from="Example <nobody@example.com>" \
1103 $patches $patches >stdout &&
1104 grep "To: Somebody <somebody@ex.com>" stdout
1107 test_expect_success $PREREQ '--no-to overrides sendemail.to' '
1108 git send-email \
1109 --dry-run \
1110 --from="Example <nobody@example.com>" \
1111 --no-to \
1112 --to=nobody@example.com \
1113 $patches $patches >stdout &&
1114 grep "To: nobody@example.com" stdout &&
1115 ! grep "To: Somebody <somebody@ex.com>" stdout
1118 test_expect_success $PREREQ 'sendemail.cc works' '
1119 git config --replace-all sendemail.cc "Somebody <somebody@ex.com>" &&
1120 git send-email \
1121 --dry-run \
1122 --from="Example <nobody@example.com>" \
1123 --to=nobody@example.com \
1124 $patches $patches >stdout &&
1125 grep "Cc: Somebody <somebody@ex.com>" stdout
1128 test_expect_success $PREREQ '--no-cc overrides sendemail.cc' '
1129 git send-email \
1130 --dry-run \
1131 --from="Example <nobody@example.com>" \
1132 --no-cc \
1133 --cc=bodies@example.com \
1134 --to=nobody@example.com \
1135 $patches $patches >stdout &&
1136 grep "Cc: bodies@example.com" stdout &&
1137 ! grep "Cc: Somebody <somebody@ex.com>" stdout
1140 test_expect_success $PREREQ 'sendemail.bcc works' '
1141 git config --replace-all sendemail.bcc "Other <other@ex.com>" &&
1142 git send-email \
1143 --dry-run \
1144 --from="Example <nobody@example.com>" \
1145 --to=nobody@example.com \
1146 --smtp-server relay.example.com \
1147 $patches $patches >stdout &&
1148 grep "RCPT TO:<other@ex.com>" stdout
1151 test_expect_success $PREREQ '--no-bcc overrides sendemail.bcc' '
1152 git send-email \
1153 --dry-run \
1154 --from="Example <nobody@example.com>" \
1155 --no-bcc \
1156 --bcc=bodies@example.com \
1157 --to=nobody@example.com \
1158 --smtp-server relay.example.com \
1159 $patches $patches >stdout &&
1160 grep "RCPT TO:<bodies@example.com>" stdout &&
1161 ! grep "RCPT TO:<other@ex.com>" stdout
1164 test_expect_success $PREREQ 'patches To headers are used by default' '
1165 patch=`git format-patch -1 --to="bodies@example.com"` &&
1166 test_when_finished "rm $patch" &&
1167 git send-email \
1168 --dry-run \
1169 --from="Example <nobody@example.com>" \
1170 --smtp-server relay.example.com \
1171 $patch >stdout &&
1172 grep "RCPT TO:<bodies@example.com>" stdout
1175 test_expect_success $PREREQ 'patches To headers are appended to' '
1176 patch=`git format-patch -1 --to="bodies@example.com"` &&
1177 test_when_finished "rm $patch" &&
1178 git send-email \
1179 --dry-run \
1180 --from="Example <nobody@example.com>" \
1181 --to=nobody@example.com \
1182 --smtp-server relay.example.com \
1183 $patch >stdout &&
1184 grep "RCPT TO:<bodies@example.com>" stdout &&
1185 grep "RCPT TO:<nobody@example.com>" stdout
1188 test_expect_success $PREREQ 'To headers from files reset each patch' '
1189 patch1=`git format-patch -1 --to="bodies@example.com"` &&
1190 patch2=`git format-patch -1 --to="other@example.com" HEAD~` &&
1191 test_when_finished "rm $patch1 && rm $patch2" &&
1192 git send-email \
1193 --dry-run \
1194 --from="Example <nobody@example.com>" \
1195 --to="nobody@example.com" \
1196 --smtp-server relay.example.com \
1197 $patch1 $patch2 >stdout &&
1198 test $(grep -c "RCPT TO:<bodies@example.com>" stdout) = 1 &&
1199 test $(grep -c "RCPT TO:<nobody@example.com>" stdout) = 2 &&
1200 test $(grep -c "RCPT TO:<other@example.com>" stdout) = 1
1203 test_expect_success $PREREQ 'setup expect' '
1204 cat >email-using-8bit <<EOF
1205 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1206 Message-Id: <bogus-message-id@example.com>
1207 From: author@example.com
1208 Date: Sat, 12 Jun 2010 15:53:58 +0200
1209 Subject: subject goes here
1211 Dieser deutsche Text enthält einen Umlaut!
1215 test_expect_success $PREREQ 'setup expect' '
1216 cat >expected <<EOF
1217 Subject: subject goes here
1221 test_expect_success $PREREQ 'ASCII subject is not RFC2047 quoted' '
1222 clean_fake_sendmail &&
1223 echo bogus |
1224 git send-email --from=author@example.com --to=nobody@example.com \
1225 --smtp-server="$(pwd)/fake.sendmail" \
1226 --8bit-encoding=UTF-8 \
1227 email-using-8bit >stdout &&
1228 grep "Subject" msgtxt1 >actual &&
1229 test_cmp expected actual
1232 test_expect_success $PREREQ 'setup expect' '
1233 cat >content-type-decl <<EOF
1234 MIME-Version: 1.0
1235 Content-Type: text/plain; charset=UTF-8
1236 Content-Transfer-Encoding: 8bit
1240 test_expect_success $PREREQ 'asks about and fixes 8bit encodings' '
1241 clean_fake_sendmail &&
1242 echo |
1243 git send-email --from=author@example.com --to=nobody@example.com \
1244 --smtp-server="$(pwd)/fake.sendmail" \
1245 email-using-8bit >stdout &&
1246 grep "do not declare a Content-Transfer-Encoding" stdout &&
1247 grep email-using-8bit stdout &&
1248 grep "Which 8bit encoding" stdout &&
1249 egrep "Content|MIME" msgtxt1 >actual &&
1250 test_cmp actual content-type-decl
1253 test_expect_success $PREREQ 'sendemail.8bitEncoding works' '
1254 clean_fake_sendmail &&
1255 git config sendemail.assume8bitEncoding UTF-8 &&
1256 echo bogus |
1257 git send-email --from=author@example.com --to=nobody@example.com \
1258 --smtp-server="$(pwd)/fake.sendmail" \
1259 email-using-8bit >stdout &&
1260 egrep "Content|MIME" msgtxt1 >actual &&
1261 test_cmp actual content-type-decl
1264 test_expect_success $PREREQ '--8bit-encoding overrides sendemail.8bitEncoding' '
1265 clean_fake_sendmail &&
1266 git config sendemail.assume8bitEncoding "bogus too" &&
1267 echo bogus |
1268 git send-email --from=author@example.com --to=nobody@example.com \
1269 --smtp-server="$(pwd)/fake.sendmail" \
1270 --8bit-encoding=UTF-8 \
1271 email-using-8bit >stdout &&
1272 egrep "Content|MIME" msgtxt1 >actual &&
1273 test_cmp actual content-type-decl
1276 test_expect_success $PREREQ 'setup expect' '
1277 cat >email-using-8bit <<EOF
1278 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1279 Message-Id: <bogus-message-id@example.com>
1280 From: author@example.com
1281 Date: Sat, 12 Jun 2010 15:53:58 +0200
1282 Subject: Dieser Betreff enthält auch einen Umlaut!
1284 Nothing to see here.
1288 test_expect_success $PREREQ 'setup expect' '
1289 cat >expected <<EOF
1290 Subject: =?UTF-8?q?Dieser=20Betreff=20enth=C3=A4lt=20auch=20einen=20Umlaut!?=
1294 test_expect_success $PREREQ '--8bit-encoding also treats subject' '
1295 clean_fake_sendmail &&
1296 echo bogus |
1297 git send-email --from=author@example.com --to=nobody@example.com \
1298 --smtp-server="$(pwd)/fake.sendmail" \
1299 --8bit-encoding=UTF-8 \
1300 email-using-8bit >stdout &&
1301 grep "Subject" msgtxt1 >actual &&
1302 test_cmp expected actual
1305 # Note that the patches in this test are deliberately out of order; we
1306 # want to make sure it works even if the cover-letter is not in the
1307 # first mail.
1308 test_expect_success $PREREQ 'refusing to send cover letter template' '
1309 clean_fake_sendmail &&
1310 rm -fr outdir &&
1311 git format-patch --cover-letter -2 -o outdir &&
1312 test_must_fail git send-email \
1313 --from="Example <nobody@example.com>" \
1314 --to=nobody@example.com \
1315 --smtp-server="$(pwd)/fake.sendmail" \
1316 outdir/0002-*.patch \
1317 outdir/0000-*.patch \
1318 outdir/0001-*.patch \
1319 2>errors >out &&
1320 grep "SUBJECT HERE" errors &&
1321 test -z "$(ls msgtxt*)"
1324 test_expect_success $PREREQ '--force sends cover letter template anyway' '
1325 clean_fake_sendmail &&
1326 rm -fr outdir &&
1327 git format-patch --cover-letter -2 -o outdir &&
1328 git send-email \
1329 --force \
1330 --from="Example <nobody@example.com>" \
1331 --to=nobody@example.com \
1332 --smtp-server="$(pwd)/fake.sendmail" \
1333 outdir/0002-*.patch \
1334 outdir/0000-*.patch \
1335 outdir/0001-*.patch \
1336 2>errors >out &&
1337 ! grep "SUBJECT HERE" errors &&
1338 test -n "$(ls msgtxt*)"
1341 test_expect_success $PREREQ 'sendemail.aliasfiletype=mailrc' '
1342 clean_fake_sendmail &&
1343 echo "alias sbd somebody@example.org" >.mailrc &&
1344 git config --replace-all sendemail.aliasesfile "$(pwd)/.mailrc" &&
1345 git config sendemail.aliasfiletype mailrc &&
1346 git send-email \
1347 --from="Example <nobody@example.com>" \
1348 --to=sbd \
1349 --smtp-server="$(pwd)/fake.sendmail" \
1350 outdir/0001-*.patch \
1351 2>errors >out &&
1352 grep "^!somebody@example\.org!$" commandline1
1355 test_expect_success $PREREQ 'sendemail.aliasfile=~/.mailrc' '
1356 clean_fake_sendmail &&
1357 echo "alias sbd someone@example.org" >~/.mailrc &&
1358 git config --replace-all sendemail.aliasesfile "~/.mailrc" &&
1359 git config sendemail.aliasfiletype mailrc &&
1360 git send-email \
1361 --from="Example <nobody@example.com>" \
1362 --to=sbd \
1363 --smtp-server="$(pwd)/fake.sendmail" \
1364 outdir/0001-*.patch \
1365 2>errors >out &&
1366 grep "^!someone@example\.org!$" commandline1
1369 test_done