Merge branch 'mg/push-repo-option-doc'
[git/git-svn.git] / t / t9001-send-email.sh
blobaf6a3e8904ab1d953b359707de1e0c9a09b3ce1f
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 'prepare reference tree' '
10 echo "1A quick brown fox jumps over the" >file &&
11 echo "lazy dog" >>file &&
12 git add file &&
13 GIT_AUTHOR_NAME="A" git commit -a -m "Initial."
16 test_expect_success $PREREQ 'Setup helper tool' '
17 write_script fake.sendmail <<-\EOF &&
18 shift
19 output=1
20 while test -f commandline$output
22 output=$(($output+1))
23 done
24 for a
26 echo "!$a!"
27 done >commandline$output
28 cat >"msgtxt$output"
29 EOF
30 git add fake.sendmail &&
31 GIT_AUTHOR_NAME="A" git commit -a -m "Second."
34 clean_fake_sendmail () {
35 rm -f commandline* msgtxt*
38 test_expect_success $PREREQ 'Extract patches' '
39 patches=`git format-patch -s --cc="One <one@example.com>" --cc=two@example.com -n HEAD^1`
42 # Test no confirm early to ensure remaining tests will not hang
43 test_no_confirm () {
44 rm -f no_confirm_okay
45 echo n | \
46 GIT_SEND_EMAIL_NOTTY=1 \
47 git send-email \
48 --from="Example <from@example.com>" \
49 --to=nobody@example.com \
50 --smtp-server="$(pwd)/fake.sendmail" \
51 $@ \
52 $patches >stdout &&
53 test_must_fail grep "Send this email" stdout &&
54 >no_confirm_okay
57 # Exit immediately to prevent hang if a no-confirm test fails
58 check_no_confirm () {
59 if ! test -f no_confirm_okay
60 then
61 say 'confirm test failed; skipping remaining tests to prevent hanging'
62 PREREQ="$PREREQ,CHECK_NO_CONFIRM"
64 return 0
67 test_expect_success $PREREQ 'No confirm with --suppress-cc' '
68 test_no_confirm --suppress-cc=sob &&
69 check_no_confirm
73 test_expect_success $PREREQ 'No confirm with --confirm=never' '
74 test_no_confirm --confirm=never &&
75 check_no_confirm
78 # leave sendemail.confirm set to never after this so that none of the
79 # remaining tests prompt unintentionally.
80 test_expect_success $PREREQ 'No confirm with sendemail.confirm=never' '
81 git config sendemail.confirm never &&
82 test_no_confirm --compose --subject=foo &&
83 check_no_confirm
86 test_expect_success $PREREQ 'Send patches' '
87 git send-email --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors
90 test_expect_success $PREREQ 'setup expect' '
91 cat >expected <<-\EOF
92 !nobody@example.com!
93 !author@example.com!
94 !one@example.com!
95 !two@example.com!
96 EOF
99 test_expect_success $PREREQ 'Verify commandline' '
100 test_cmp expected commandline1
103 test_expect_success $PREREQ 'Send patches with --envelope-sender' '
104 clean_fake_sendmail &&
105 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
108 test_expect_success $PREREQ 'setup expect' '
109 cat >expected <<-\EOF
110 !patch@example.com!
111 !-i!
112 !nobody@example.com!
113 !author@example.com!
114 !one@example.com!
115 !two@example.com!
119 test_expect_success $PREREQ 'Verify commandline' '
120 test_cmp expected commandline1
123 test_expect_success $PREREQ 'Send patches with --envelope-sender=auto' '
124 clean_fake_sendmail &&
125 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
128 test_expect_success $PREREQ 'setup expect' '
129 cat >expected <<-\EOF
130 !nobody@example.com!
131 !-i!
132 !nobody@example.com!
133 !author@example.com!
134 !one@example.com!
135 !two@example.com!
139 test_expect_success $PREREQ 'Verify commandline' '
140 test_cmp expected commandline1
143 test_expect_success $PREREQ 'setup expect' "
144 cat >expected-show-all-headers <<\EOF
145 0001-Second.patch
146 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
147 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
148 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
149 Dry-OK. Log says:
150 Server: relay.example.com
151 MAIL FROM:<from@example.com>
152 RCPT TO:<to@example.com>
153 RCPT TO:<cc@example.com>
154 RCPT TO:<author@example.com>
155 RCPT TO:<one@example.com>
156 RCPT TO:<two@example.com>
157 RCPT TO:<bcc@example.com>
158 From: Example <from@example.com>
159 To: to@example.com
160 Cc: cc@example.com,
161 A <author@example.com>,
162 One <one@example.com>,
163 two@example.com
164 Subject: [PATCH 1/1] Second.
165 Date: DATE-STRING
166 Message-Id: MESSAGE-ID-STRING
167 X-Mailer: X-MAILER-STRING
168 In-Reply-To: <unique-message-id@example.com>
169 References: <unique-message-id@example.com>
171 Result: OK
175 test_suppress_self () {
176 test_commit $3 &&
177 test_when_finished "git reset --hard HEAD^" &&
179 write_script cccmd-sed <<-EOF &&
180 sed -n -e s/^cccmd--//p "\$1"
183 git commit --amend --author="$1 <$2>" -F - &&
184 clean_fake_sendmail &&
185 git format-patch --stdout -1 >"suppress-self-$3.patch" &&
187 git send-email --from="$1 <$2>" \
188 --to=nobody@example.com \
189 --cc-cmd=./cccmd-sed \
190 --suppress-cc=self \
191 --smtp-server="$(pwd)/fake.sendmail" \
192 suppress-self-$3.patch &&
194 mv msgtxt1 msgtxt1-$3 &&
195 sed -e '/^$/q' msgtxt1-$3 >"msghdr1-$3" &&
196 >"expected-no-cc-$3" &&
198 (grep '^Cc:' msghdr1-$3 >"actual-no-cc-$3";
199 test_cmp expected-no-cc-$3 actual-no-cc-$3)
202 test_suppress_self_unquoted () {
203 test_suppress_self "$1" "$2" "unquoted-$3" <<-EOF
204 test suppress-cc.self unquoted-$3 with name $1 email $2
206 unquoted-$3
208 cccmd--$1 <$2>
210 Cc: $1 <$2>
211 Signed-off-by: $1 <$2>
215 test_suppress_self_quoted () {
216 test_suppress_self "$1" "$2" "quoted-$3" <<-EOF
217 test suppress-cc.self quoted-$3 with name $1 email $2
219 quoted-$3
221 cccmd--"$1" <$2>
223 Cc: $1 <$2>
224 Cc: "$1" <$2>
225 Signed-off-by: $1 <$2>
226 Signed-off-by: "$1" <$2>
230 test_expect_success $PREREQ 'self name is suppressed' "
231 test_suppress_self_unquoted 'A U Thor' 'author@example.com' \
232 'self_name_suppressed'
235 test_expect_success $PREREQ 'self name with dot is suppressed' "
236 test_suppress_self_quoted 'A U. Thor' 'author@example.com' \
237 'self_name_dot_suppressed'
240 test_expect_success $PREREQ 'non-ascii self name is suppressed' "
241 test_suppress_self_quoted 'Füñný Nâmé' 'odd_?=mail@example.com' \
242 'non_ascii_self_suppressed'
245 # This name is long enough to force format-patch to split it into multiple
246 # encoded-words, assuming it uses UTF-8 with the "Q" encoding.
247 test_expect_success $PREREQ 'long non-ascii self name is suppressed' "
248 test_suppress_self_quoted 'Ƒüñníęř €. Nâṁé' 'odd_?=mail@example.com' \
249 'long_non_ascii_self_suppressed'
252 test_expect_success $PREREQ 'sanitized self name is suppressed' "
253 test_suppress_self_unquoted '\"A U. Thor\"' 'author@example.com' \
254 'self_name_sanitized_suppressed'
257 test_expect_success $PREREQ 'Show all headers' '
258 git send-email \
259 --dry-run \
260 --suppress-cc=sob \
261 --from="Example <from@example.com>" \
262 --to=to@example.com \
263 --cc=cc@example.com \
264 --bcc=bcc@example.com \
265 --in-reply-to="<unique-message-id@example.com>" \
266 --smtp-server relay.example.com \
267 $patches |
268 sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
269 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
270 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
271 >actual-show-all-headers &&
272 test_cmp expected-show-all-headers actual-show-all-headers
275 test_expect_success $PREREQ 'Prompting works' '
276 clean_fake_sendmail &&
277 (echo "to@example.com"
278 echo ""
279 ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
280 --smtp-server="$(pwd)/fake.sendmail" \
281 $patches \
282 2>errors &&
283 grep "^From: A U Thor <author@example.com>\$" msgtxt1 &&
284 grep "^To: to@example.com\$" msgtxt1
287 test_expect_success $PREREQ,AUTOIDENT 'implicit ident is allowed' '
288 clean_fake_sendmail &&
289 (sane_unset GIT_AUTHOR_NAME &&
290 sane_unset GIT_AUTHOR_EMAIL &&
291 sane_unset GIT_COMMITTER_NAME &&
292 sane_unset GIT_COMMITTER_EMAIL &&
293 GIT_SEND_EMAIL_NOTTY=1 git send-email \
294 --smtp-server="$(pwd)/fake.sendmail" \
295 --to=to@example.com \
296 $patches </dev/null 2>errors
300 test_expect_success $PREREQ,!AUTOIDENT 'broken implicit ident aborts send-email' '
301 clean_fake_sendmail &&
302 (sane_unset GIT_AUTHOR_NAME &&
303 sane_unset GIT_AUTHOR_EMAIL &&
304 sane_unset GIT_COMMITTER_NAME &&
305 sane_unset GIT_COMMITTER_EMAIL &&
306 GIT_SEND_EMAIL_NOTTY=1 && export GIT_SEND_EMAIL_NOTTY &&
307 test_must_fail git send-email \
308 --smtp-server="$(pwd)/fake.sendmail" \
309 --to=to@example.com \
310 $patches </dev/null 2>errors &&
311 test_i18ngrep "tell me who you are" errors
315 test_expect_success $PREREQ 'tocmd works' '
316 clean_fake_sendmail &&
317 cp $patches tocmd.patch &&
318 echo tocmd--tocmd@example.com >>tocmd.patch &&
319 write_script tocmd-sed <<-\EOF &&
320 sed -n -e "s/^tocmd--//p" "$1"
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 &&
335 write_script cccmd-sed <<-\EOF &&
336 sed -n -e "s/^cccmd--//p" "$1"
338 git send-email \
339 --from="Example <nobody@example.com>" \
340 --to=nobody@example.com \
341 --cc-cmd=./cccmd-sed \
342 --smtp-server="$(pwd)/fake.sendmail" \
343 cccmd.patch \
345 grep "^ cccmd@example.com" msgtxt1
348 test_expect_success $PREREQ 'reject long lines' '
349 z8=zzzzzzzz &&
350 z64=$z8$z8$z8$z8$z8$z8$z8$z8 &&
351 z512=$z64$z64$z64$z64$z64$z64$z64$z64 &&
352 clean_fake_sendmail &&
353 cp $patches longline.patch &&
354 echo $z512$z512 >>longline.patch &&
355 test_must_fail git send-email \
356 --from="Example <nobody@example.com>" \
357 --to=nobody@example.com \
358 --smtp-server="$(pwd)/fake.sendmail" \
359 $patches longline.patch \
360 2>errors &&
361 grep longline.patch errors
364 test_expect_success $PREREQ 'no patch was sent' '
365 ! test -e commandline1
368 test_expect_success $PREREQ 'Author From: in message body' '
369 clean_fake_sendmail &&
370 git send-email \
371 --from="Example <nobody@example.com>" \
372 --to=nobody@example.com \
373 --smtp-server="$(pwd)/fake.sendmail" \
374 $patches &&
375 sed "1,/^\$/d" <msgtxt1 >msgbody1 &&
376 grep "From: A <author@example.com>" msgbody1
379 test_expect_success $PREREQ 'Author From: not in message body' '
380 clean_fake_sendmail &&
381 git send-email \
382 --from="A <author@example.com>" \
383 --to=nobody@example.com \
384 --smtp-server="$(pwd)/fake.sendmail" \
385 $patches &&
386 sed "1,/^\$/d" <msgtxt1 >msgbody1 &&
387 ! grep "From: A <author@example.com>" msgbody1
390 test_expect_success $PREREQ 'allow long lines with --no-validate' '
391 git send-email \
392 --from="Example <nobody@example.com>" \
393 --to=nobody@example.com \
394 --smtp-server="$(pwd)/fake.sendmail" \
395 --novalidate \
396 $patches longline.patch \
397 2>errors
400 test_expect_success $PREREQ 'Invalid In-Reply-To' '
401 clean_fake_sendmail &&
402 git send-email \
403 --from="Example <nobody@example.com>" \
404 --to=nobody@example.com \
405 --in-reply-to=" " \
406 --smtp-server="$(pwd)/fake.sendmail" \
407 $patches \
408 2>errors &&
409 ! grep "^In-Reply-To: < *>" msgtxt1
412 test_expect_success $PREREQ 'Valid In-Reply-To when prompting' '
413 clean_fake_sendmail &&
414 (echo "From Example <from@example.com>"
415 echo "To Example <to@example.com>"
416 echo ""
417 ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
418 --smtp-server="$(pwd)/fake.sendmail" \
419 $patches 2>errors &&
420 ! grep "^In-Reply-To: < *>" msgtxt1
423 test_expect_success $PREREQ 'In-Reply-To without --chain-reply-to' '
424 clean_fake_sendmail &&
425 echo "<unique-message-id@example.com>" >expect &&
426 git send-email \
427 --from="Example <nobody@example.com>" \
428 --to=nobody@example.com \
429 --nochain-reply-to \
430 --in-reply-to="$(cat expect)" \
431 --smtp-server="$(pwd)/fake.sendmail" \
432 $patches $patches $patches \
433 2>errors &&
434 # The first message is a reply to --in-reply-to
435 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual &&
436 test_cmp expect actual &&
437 # Second and subsequent messages are replies to the first one
438 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect &&
439 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual &&
440 test_cmp expect actual &&
441 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual &&
442 test_cmp expect actual
445 test_expect_success $PREREQ 'In-Reply-To with --chain-reply-to' '
446 clean_fake_sendmail &&
447 echo "<unique-message-id@example.com>" >expect &&
448 git send-email \
449 --from="Example <nobody@example.com>" \
450 --to=nobody@example.com \
451 --chain-reply-to \
452 --in-reply-to="$(cat expect)" \
453 --smtp-server="$(pwd)/fake.sendmail" \
454 $patches $patches $patches \
455 2>errors &&
456 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual &&
457 test_cmp expect actual &&
458 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect &&
459 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual &&
460 test_cmp expect actual &&
461 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt2 >expect &&
462 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual &&
463 test_cmp expect actual
466 test_expect_success $PREREQ 'setup fake editor' '
467 write_script fake-editor <<-\EOF
468 echo fake edit >>"$1"
472 test_set_editor "$(pwd)/fake-editor"
474 test_expect_success $PREREQ '--compose works' '
475 clean_fake_sendmail &&
476 git send-email \
477 --compose --subject foo \
478 --from="Example <nobody@example.com>" \
479 --to=nobody@example.com \
480 --smtp-server="$(pwd)/fake.sendmail" \
481 $patches \
482 2>errors
485 test_expect_success $PREREQ 'first message is compose text' '
486 grep "^fake edit" msgtxt1
489 test_expect_success $PREREQ 'second message is patch' '
490 grep "Subject:.*Second" msgtxt2
493 test_expect_success $PREREQ 'setup expect' "
494 cat >expected-suppress-sob <<\EOF
495 0001-Second.patch
496 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
497 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
498 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
499 Dry-OK. Log says:
500 Server: relay.example.com
501 MAIL FROM:<from@example.com>
502 RCPT TO:<to@example.com>
503 RCPT TO:<cc@example.com>
504 RCPT TO:<author@example.com>
505 RCPT TO:<one@example.com>
506 RCPT TO:<two@example.com>
507 From: Example <from@example.com>
508 To: to@example.com
509 Cc: cc@example.com,
510 A <author@example.com>,
511 One <one@example.com>,
512 two@example.com
513 Subject: [PATCH 1/1] Second.
514 Date: DATE-STRING
515 Message-Id: MESSAGE-ID-STRING
516 X-Mailer: X-MAILER-STRING
518 Result: OK
522 test_suppression () {
523 git send-email \
524 --dry-run \
525 --suppress-cc=$1 ${2+"--suppress-cc=$2"} \
526 --from="Example <from@example.com>" \
527 --to=to@example.com \
528 --smtp-server relay.example.com \
529 $patches |
530 sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
531 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
532 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
533 >actual-suppress-$1${2+"-$2"} &&
534 test_cmp expected-suppress-$1${2+"-$2"} actual-suppress-$1${2+"-$2"}
537 test_expect_success $PREREQ 'sendemail.cc set' '
538 git config sendemail.cc cc@example.com &&
539 test_suppression sob
542 test_expect_success $PREREQ 'setup expect' "
543 cat >expected-suppress-sob <<\EOF
544 0001-Second.patch
545 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
546 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
547 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
548 Dry-OK. Log says:
549 Server: relay.example.com
550 MAIL FROM:<from@example.com>
551 RCPT TO:<to@example.com>
552 RCPT TO:<author@example.com>
553 RCPT TO:<one@example.com>
554 RCPT TO:<two@example.com>
555 From: Example <from@example.com>
556 To: to@example.com
557 Cc: A <author@example.com>,
558 One <one@example.com>,
559 two@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.cc unset' '
570 git config --unset sendemail.cc &&
571 test_suppression sob
574 test_expect_success $PREREQ 'setup expect' "
575 cat >expected-suppress-cccmd <<\EOF
576 0001-Second.patch
577 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
578 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
579 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
580 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
581 Dry-OK. Log says:
582 Server: relay.example.com
583 MAIL FROM:<from@example.com>
584 RCPT TO:<to@example.com>
585 RCPT TO:<author@example.com>
586 RCPT TO:<one@example.com>
587 RCPT TO:<two@example.com>
588 RCPT TO:<committer@example.com>
589 From: Example <from@example.com>
590 To: to@example.com
591 Cc: A <author@example.com>,
592 One <one@example.com>,
593 two@example.com,
594 C O Mitter <committer@example.com>
595 Subject: [PATCH 1/1] Second.
596 Date: DATE-STRING
597 Message-Id: MESSAGE-ID-STRING
598 X-Mailer: X-MAILER-STRING
600 Result: OK
604 test_expect_success $PREREQ 'sendemail.cccmd' '
605 write_script cccmd <<-\EOF &&
606 echo cc-cmd@example.com
608 git config sendemail.cccmd ./cccmd &&
609 test_suppression cccmd
612 test_expect_success $PREREQ 'setup expect' '
613 cat >expected-suppress-all <<\EOF
614 0001-Second.patch
615 Dry-OK. Log says:
616 Server: relay.example.com
617 MAIL FROM:<from@example.com>
618 RCPT TO:<to@example.com>
619 From: Example <from@example.com>
620 To: to@example.com
621 Subject: [PATCH 1/1] Second.
622 Date: DATE-STRING
623 Message-Id: MESSAGE-ID-STRING
624 X-Mailer: X-MAILER-STRING
626 Result: OK
630 test_expect_success $PREREQ '--suppress-cc=all' '
631 test_suppression all
634 test_expect_success $PREREQ 'setup expect' "
635 cat >expected-suppress-body <<\EOF
636 0001-Second.patch
637 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
638 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
639 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
640 (cc-cmd) Adding cc: cc-cmd@example.com from: './cccmd'
641 Dry-OK. Log says:
642 Server: relay.example.com
643 MAIL FROM:<from@example.com>
644 RCPT TO:<to@example.com>
645 RCPT TO:<author@example.com>
646 RCPT TO:<one@example.com>
647 RCPT TO:<two@example.com>
648 RCPT TO:<cc-cmd@example.com>
649 From: Example <from@example.com>
650 To: to@example.com
651 Cc: A <author@example.com>,
652 One <one@example.com>,
653 two@example.com,
654 cc-cmd@example.com
655 Subject: [PATCH 1/1] Second.
656 Date: DATE-STRING
657 Message-Id: MESSAGE-ID-STRING
658 X-Mailer: X-MAILER-STRING
660 Result: OK
664 test_expect_success $PREREQ '--suppress-cc=body' '
665 test_suppression body
668 test_expect_success $PREREQ 'setup expect' "
669 cat >expected-suppress-body-cccmd <<\EOF
670 0001-Second.patch
671 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
672 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
673 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
674 Dry-OK. Log says:
675 Server: relay.example.com
676 MAIL FROM:<from@example.com>
677 RCPT TO:<to@example.com>
678 RCPT TO:<author@example.com>
679 RCPT TO:<one@example.com>
680 RCPT TO:<two@example.com>
681 From: Example <from@example.com>
682 To: to@example.com
683 Cc: A <author@example.com>,
684 One <one@example.com>,
685 two@example.com
686 Subject: [PATCH 1/1] Second.
687 Date: DATE-STRING
688 Message-Id: MESSAGE-ID-STRING
689 X-Mailer: X-MAILER-STRING
691 Result: OK
695 test_expect_success $PREREQ '--suppress-cc=body --suppress-cc=cccmd' '
696 test_suppression body cccmd
699 test_expect_success $PREREQ 'setup expect' "
700 cat >expected-suppress-sob <<\EOF
701 0001-Second.patch
702 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
703 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
704 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
705 Dry-OK. Log says:
706 Server: relay.example.com
707 MAIL FROM:<from@example.com>
708 RCPT TO:<to@example.com>
709 RCPT TO:<author@example.com>
710 RCPT TO:<one@example.com>
711 RCPT TO:<two@example.com>
712 From: Example <from@example.com>
713 To: to@example.com
714 Cc: A <author@example.com>,
715 One <one@example.com>,
716 two@example.com
717 Subject: [PATCH 1/1] Second.
718 Date: DATE-STRING
719 Message-Id: MESSAGE-ID-STRING
720 X-Mailer: X-MAILER-STRING
722 Result: OK
726 test_expect_success $PREREQ '--suppress-cc=sob' '
727 test_might_fail git config --unset sendemail.cccmd &&
728 test_suppression sob
731 test_expect_success $PREREQ 'setup expect' "
732 cat >expected-suppress-bodycc <<\EOF
733 0001-Second.patch
734 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
735 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
736 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
737 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
738 Dry-OK. Log says:
739 Server: relay.example.com
740 MAIL FROM:<from@example.com>
741 RCPT TO:<to@example.com>
742 RCPT TO:<author@example.com>
743 RCPT TO:<one@example.com>
744 RCPT TO:<two@example.com>
745 RCPT TO:<committer@example.com>
746 From: Example <from@example.com>
747 To: to@example.com
748 Cc: A <author@example.com>,
749 One <one@example.com>,
750 two@example.com,
751 C O Mitter <committer@example.com>
752 Subject: [PATCH 1/1] Second.
753 Date: DATE-STRING
754 Message-Id: MESSAGE-ID-STRING
755 X-Mailer: X-MAILER-STRING
757 Result: OK
761 test_expect_success $PREREQ '--suppress-cc=bodycc' '
762 test_suppression bodycc
765 test_expect_success $PREREQ 'setup expect' "
766 cat >expected-suppress-cc <<\EOF
767 0001-Second.patch
768 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
769 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
770 Dry-OK. Log says:
771 Server: relay.example.com
772 MAIL FROM:<from@example.com>
773 RCPT TO:<to@example.com>
774 RCPT TO:<author@example.com>
775 RCPT TO:<committer@example.com>
776 From: Example <from@example.com>
777 To: to@example.com
778 Cc: A <author@example.com>,
779 C O Mitter <committer@example.com>
780 Subject: [PATCH 1/1] Second.
781 Date: DATE-STRING
782 Message-Id: MESSAGE-ID-STRING
783 X-Mailer: X-MAILER-STRING
785 Result: OK
789 test_expect_success $PREREQ '--suppress-cc=cc' '
790 test_suppression cc
793 test_confirm () {
794 echo y | \
795 GIT_SEND_EMAIL_NOTTY=1 \
796 git send-email \
797 --from="Example <nobody@example.com>" \
798 --to=nobody@example.com \
799 --smtp-server="$(pwd)/fake.sendmail" \
800 $@ $patches >stdout &&
801 grep "Send this email" stdout
804 test_expect_success $PREREQ '--confirm=always' '
805 test_confirm --confirm=always --suppress-cc=all
808 test_expect_success $PREREQ '--confirm=auto' '
809 test_confirm --confirm=auto
812 test_expect_success $PREREQ '--confirm=cc' '
813 test_confirm --confirm=cc
816 test_expect_success $PREREQ '--confirm=compose' '
817 test_confirm --confirm=compose --compose
820 test_expect_success $PREREQ 'confirm by default (due to cc)' '
821 CONFIRM=$(git config --get sendemail.confirm) &&
822 git config --unset sendemail.confirm &&
823 test_confirm
824 ret="$?"
825 git config sendemail.confirm ${CONFIRM:-never}
826 test $ret = "0"
829 test_expect_success $PREREQ 'confirm by default (due to --compose)' '
830 CONFIRM=$(git config --get sendemail.confirm) &&
831 git config --unset sendemail.confirm &&
832 test_confirm --suppress-cc=all --compose
833 ret="$?"
834 git config sendemail.confirm ${CONFIRM:-never}
835 test $ret = "0"
838 test_expect_success $PREREQ 'confirm detects EOF (inform assumes y)' '
839 CONFIRM=$(git config --get sendemail.confirm) &&
840 git config --unset sendemail.confirm &&
841 rm -fr outdir &&
842 git format-patch -2 -o outdir &&
843 GIT_SEND_EMAIL_NOTTY=1 \
844 git send-email \
845 --from="Example <nobody@example.com>" \
846 --to=nobody@example.com \
847 --smtp-server="$(pwd)/fake.sendmail" \
848 outdir/*.patch </dev/null
849 ret="$?"
850 git config sendemail.confirm ${CONFIRM:-never}
851 test $ret = "0"
854 test_expect_success $PREREQ 'confirm detects EOF (auto causes failure)' '
855 CONFIRM=$(git config --get sendemail.confirm) &&
856 git config sendemail.confirm auto &&
857 GIT_SEND_EMAIL_NOTTY=1 &&
858 export GIT_SEND_EMAIL_NOTTY &&
859 test_must_fail git send-email \
860 --from="Example <nobody@example.com>" \
861 --to=nobody@example.com \
862 --smtp-server="$(pwd)/fake.sendmail" \
863 $patches </dev/null
864 ret="$?"
865 git config sendemail.confirm ${CONFIRM:-never}
866 test $ret = "0"
869 test_expect_success $PREREQ 'confirm does not loop forever' '
870 CONFIRM=$(git config --get sendemail.confirm) &&
871 git config sendemail.confirm auto &&
872 GIT_SEND_EMAIL_NOTTY=1 &&
873 export GIT_SEND_EMAIL_NOTTY &&
874 yes "bogus" | test_must_fail git send-email \
875 --from="Example <nobody@example.com>" \
876 --to=nobody@example.com \
877 --smtp-server="$(pwd)/fake.sendmail" \
878 $patches
879 ret="$?"
880 git config sendemail.confirm ${CONFIRM:-never}
881 test $ret = "0"
884 test_expect_success $PREREQ 'utf8 Cc is rfc2047 encoded' '
885 clean_fake_sendmail &&
886 rm -fr outdir &&
887 git format-patch -1 -o outdir --cc="àéìöú <utf8@example.com>" &&
888 git send-email \
889 --from="Example <nobody@example.com>" \
890 --to=nobody@example.com \
891 --smtp-server="$(pwd)/fake.sendmail" \
892 outdir/*.patch &&
893 grep "^ " msgtxt1 |
894 grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>"
897 test_expect_success $PREREQ '--compose adds MIME for utf8 body' '
898 clean_fake_sendmail &&
899 write_script fake-editor-utf8 <<-\EOF &&
900 echo "utf8 body: àéìöú" >>"$1"
902 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
903 git send-email \
904 --compose --subject foo \
905 --from="Example <nobody@example.com>" \
906 --to=nobody@example.com \
907 --smtp-server="$(pwd)/fake.sendmail" \
908 $patches &&
909 grep "^utf8 body" msgtxt1 &&
910 grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
913 test_expect_success $PREREQ '--compose respects user mime type' '
914 clean_fake_sendmail &&
915 write_script fake-editor-utf8-mime <<-\EOF &&
916 cat >"$1" <<-\EOM
917 MIME-Version: 1.0
918 Content-Type: text/plain; charset=iso-8859-1
919 Content-Transfer-Encoding: 8bit
920 Subject: foo
922 utf8 body: àéìöú
925 GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \
926 git send-email \
927 --compose --subject foo \
928 --from="Example <nobody@example.com>" \
929 --to=nobody@example.com \
930 --smtp-server="$(pwd)/fake.sendmail" \
931 $patches &&
932 grep "^utf8 body" msgtxt1 &&
933 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 &&
934 ! grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
937 test_expect_success $PREREQ '--compose adds MIME for utf8 subject' '
938 clean_fake_sendmail &&
939 GIT_EDITOR="\"$(pwd)/fake-editor\"" \
940 git send-email \
941 --compose --subject utf8-sübjëct \
942 --from="Example <nobody@example.com>" \
943 --to=nobody@example.com \
944 --smtp-server="$(pwd)/fake.sendmail" \
945 $patches &&
946 grep "^fake edit" msgtxt1 &&
947 grep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
950 test_expect_success $PREREQ 'utf8 author is correctly passed on' '
951 clean_fake_sendmail &&
952 test_commit weird_author &&
953 test_when_finished "git reset --hard HEAD^" &&
954 git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" &&
955 git format-patch --stdout -1 >funny_name.patch &&
956 git send-email --from="Example <nobody@example.com>" \
957 --to=nobody@example.com \
958 --smtp-server="$(pwd)/fake.sendmail" \
959 funny_name.patch &&
960 grep "^From: Füñný Nâmé <odd_?=mail@example.com>" msgtxt1
963 test_expect_success $PREREQ 'utf8 sender is not duplicated' '
964 clean_fake_sendmail &&
965 test_commit weird_sender &&
966 test_when_finished "git reset --hard HEAD^" &&
967 git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" &&
968 git format-patch --stdout -1 >funny_name.patch &&
969 git send-email --from="Füñný Nâmé <odd_?=mail@example.com>" \
970 --to=nobody@example.com \
971 --smtp-server="$(pwd)/fake.sendmail" \
972 funny_name.patch &&
973 grep "^From: " msgtxt1 >msgfrom &&
974 test_line_count = 1 msgfrom
977 test_expect_success $PREREQ 'sendemail.composeencoding works' '
978 clean_fake_sendmail &&
979 git config sendemail.composeencoding iso-8859-1 &&
980 write_script fake-editor-utf8 <<-\EOF &&
981 echo "utf8 body: àéìöú" >>"$1"
983 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
984 git send-email \
985 --compose --subject foo \
986 --from="Example <nobody@example.com>" \
987 --to=nobody@example.com \
988 --smtp-server="$(pwd)/fake.sendmail" \
989 $patches &&
990 grep "^utf8 body" msgtxt1 &&
991 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1
994 test_expect_success $PREREQ '--compose-encoding works' '
995 clean_fake_sendmail &&
996 write_script fake-editor-utf8 <<-\EOF &&
997 echo "utf8 body: àéìöú" >>"$1"
999 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
1000 git send-email \
1001 --compose-encoding iso-8859-1 \
1002 --compose --subject foo \
1003 --from="Example <nobody@example.com>" \
1004 --to=nobody@example.com \
1005 --smtp-server="$(pwd)/fake.sendmail" \
1006 $patches &&
1007 grep "^utf8 body" msgtxt1 &&
1008 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1
1011 test_expect_success $PREREQ '--compose-encoding overrides sendemail.composeencoding' '
1012 clean_fake_sendmail &&
1013 git config sendemail.composeencoding iso-8859-1 &&
1014 write_script fake-editor-utf8 <<-\EOF &&
1015 echo "utf8 body: àéìöú" >>"$1"
1017 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
1018 git send-email \
1019 --compose-encoding iso-8859-2 \
1020 --compose --subject foo \
1021 --from="Example <nobody@example.com>" \
1022 --to=nobody@example.com \
1023 --smtp-server="$(pwd)/fake.sendmail" \
1024 $patches &&
1025 grep "^utf8 body" msgtxt1 &&
1026 grep "^Content-Type: text/plain; charset=iso-8859-2" msgtxt1
1029 test_expect_success $PREREQ '--compose-encoding adds correct MIME for subject' '
1030 clean_fake_sendmail &&
1031 GIT_EDITOR="\"$(pwd)/fake-editor\"" \
1032 git send-email \
1033 --compose-encoding iso-8859-2 \
1034 --compose --subject utf8-sübjëct \
1035 --from="Example <nobody@example.com>" \
1036 --to=nobody@example.com \
1037 --smtp-server="$(pwd)/fake.sendmail" \
1038 $patches &&
1039 grep "^fake edit" msgtxt1 &&
1040 grep "^Subject: =?iso-8859-2?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
1043 test_expect_success $PREREQ 'detects ambiguous reference/file conflict' '
1044 echo master >master &&
1045 git add master &&
1046 git commit -m"add master" &&
1047 test_must_fail git send-email --dry-run master 2>errors &&
1048 grep disambiguate errors
1051 test_expect_success $PREREQ 'feed two files' '
1052 rm -fr outdir &&
1053 git format-patch -2 -o outdir &&
1054 git send-email \
1055 --dry-run \
1056 --from="Example <nobody@example.com>" \
1057 --to=nobody@example.com \
1058 outdir/000?-*.patch 2>errors >out &&
1059 grep "^Subject: " out >subjects &&
1060 test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." &&
1061 test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add master"
1064 test_expect_success $PREREQ 'in-reply-to but no threading' '
1065 git send-email \
1066 --dry-run \
1067 --from="Example <nobody@example.com>" \
1068 --to=nobody@example.com \
1069 --in-reply-to="<in-reply-id@example.com>" \
1070 --nothread \
1071 $patches |
1072 grep "In-Reply-To: <in-reply-id@example.com>"
1075 test_expect_success $PREREQ 'no in-reply-to and no threading' '
1076 git send-email \
1077 --dry-run \
1078 --from="Example <nobody@example.com>" \
1079 --to=nobody@example.com \
1080 --nothread \
1081 $patches $patches >stdout &&
1082 ! grep "In-Reply-To: " stdout
1085 test_expect_success $PREREQ 'threading but no chain-reply-to' '
1086 git send-email \
1087 --dry-run \
1088 --from="Example <nobody@example.com>" \
1089 --to=nobody@example.com \
1090 --thread \
1091 --nochain-reply-to \
1092 $patches $patches >stdout &&
1093 grep "In-Reply-To: " stdout
1096 test_expect_success $PREREQ 'sendemail.to works' '
1097 git config --replace-all sendemail.to "Somebody <somebody@ex.com>" &&
1098 git send-email \
1099 --dry-run \
1100 --from="Example <nobody@example.com>" \
1101 $patches $patches >stdout &&
1102 grep "To: Somebody <somebody@ex.com>" stdout
1105 test_expect_success $PREREQ '--no-to overrides sendemail.to' '
1106 git send-email \
1107 --dry-run \
1108 --from="Example <nobody@example.com>" \
1109 --no-to \
1110 --to=nobody@example.com \
1111 $patches $patches >stdout &&
1112 grep "To: nobody@example.com" stdout &&
1113 ! grep "To: Somebody <somebody@ex.com>" stdout
1116 test_expect_success $PREREQ 'sendemail.cc works' '
1117 git config --replace-all sendemail.cc "Somebody <somebody@ex.com>" &&
1118 git send-email \
1119 --dry-run \
1120 --from="Example <nobody@example.com>" \
1121 --to=nobody@example.com \
1122 $patches $patches >stdout &&
1123 grep "Cc: Somebody <somebody@ex.com>" stdout
1126 test_expect_success $PREREQ '--no-cc overrides sendemail.cc' '
1127 git send-email \
1128 --dry-run \
1129 --from="Example <nobody@example.com>" \
1130 --no-cc \
1131 --cc=bodies@example.com \
1132 --to=nobody@example.com \
1133 $patches $patches >stdout &&
1134 grep "Cc: bodies@example.com" stdout &&
1135 ! grep "Cc: Somebody <somebody@ex.com>" stdout
1138 test_expect_success $PREREQ 'sendemail.bcc works' '
1139 git config --replace-all sendemail.bcc "Other <other@ex.com>" &&
1140 git send-email \
1141 --dry-run \
1142 --from="Example <nobody@example.com>" \
1143 --to=nobody@example.com \
1144 --smtp-server relay.example.com \
1145 $patches $patches >stdout &&
1146 grep "RCPT TO:<other@ex.com>" stdout
1149 test_expect_success $PREREQ '--no-bcc overrides sendemail.bcc' '
1150 git send-email \
1151 --dry-run \
1152 --from="Example <nobody@example.com>" \
1153 --no-bcc \
1154 --bcc=bodies@example.com \
1155 --to=nobody@example.com \
1156 --smtp-server relay.example.com \
1157 $patches $patches >stdout &&
1158 grep "RCPT TO:<bodies@example.com>" stdout &&
1159 ! grep "RCPT TO:<other@ex.com>" stdout
1162 test_expect_success $PREREQ 'patches To headers are used by default' '
1163 patch=`git format-patch -1 --to="bodies@example.com"` &&
1164 test_when_finished "rm $patch" &&
1165 git send-email \
1166 --dry-run \
1167 --from="Example <nobody@example.com>" \
1168 --smtp-server relay.example.com \
1169 $patch >stdout &&
1170 grep "RCPT TO:<bodies@example.com>" stdout
1173 test_expect_success $PREREQ 'patches To headers are appended to' '
1174 patch=`git format-patch -1 --to="bodies@example.com"` &&
1175 test_when_finished "rm $patch" &&
1176 git send-email \
1177 --dry-run \
1178 --from="Example <nobody@example.com>" \
1179 --to=nobody@example.com \
1180 --smtp-server relay.example.com \
1181 $patch >stdout &&
1182 grep "RCPT TO:<bodies@example.com>" stdout &&
1183 grep "RCPT TO:<nobody@example.com>" stdout
1186 test_expect_success $PREREQ 'To headers from files reset each patch' '
1187 patch1=`git format-patch -1 --to="bodies@example.com"` &&
1188 patch2=`git format-patch -1 --to="other@example.com" HEAD~` &&
1189 test_when_finished "rm $patch1 && rm $patch2" &&
1190 git send-email \
1191 --dry-run \
1192 --from="Example <nobody@example.com>" \
1193 --to="nobody@example.com" \
1194 --smtp-server relay.example.com \
1195 $patch1 $patch2 >stdout &&
1196 test $(grep -c "RCPT TO:<bodies@example.com>" stdout) = 1 &&
1197 test $(grep -c "RCPT TO:<nobody@example.com>" stdout) = 2 &&
1198 test $(grep -c "RCPT TO:<other@example.com>" stdout) = 1
1201 test_expect_success $PREREQ 'setup expect' '
1202 cat >email-using-8bit <<\EOF
1203 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1204 Message-Id: <bogus-message-id@example.com>
1205 From: author@example.com
1206 Date: Sat, 12 Jun 2010 15:53:58 +0200
1207 Subject: subject goes here
1209 Dieser deutsche Text enthält einen Umlaut!
1213 test_expect_success $PREREQ 'setup expect' '
1214 echo "Subject: subject goes here" >expected
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 test_expect_success $PREREQ 'setup expect' '
1302 cat >email-using-8bit <<-\EOF
1303 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1304 Message-Id: <bogus-message-id@example.com>
1305 From: A U Thor <author@example.com>
1306 Date: Sat, 12 Jun 2010 15:53:58 +0200
1307 Content-Type: text/plain; charset=UTF-8
1308 Subject: Nothing to see here.
1310 Dieser Betreff enthält auch einen Umlaut!
1314 test_expect_success $PREREQ 'sendemail.transferencoding=7bit fails on 8bit data' '
1315 clean_fake_sendmail &&
1316 git config sendemail.transferEncoding 7bit &&
1317 test_must_fail git send-email \
1318 --transfer-encoding=7bit \
1319 --smtp-server="$(pwd)/fake.sendmail" \
1320 email-using-8bit \
1321 2>errors >out &&
1322 grep "cannot send message as 7bit" errors &&
1323 test -z "$(ls msgtxt*)"
1326 test_expect_success $PREREQ '--transfer-encoding overrides sendemail.transferEncoding' '
1327 clean_fake_sendmail &&
1328 git config sendemail.transferEncoding 8bit
1329 test_must_fail git send-email \
1330 --transfer-encoding=7bit \
1331 --smtp-server="$(pwd)/fake.sendmail" \
1332 email-using-8bit \
1333 2>errors >out &&
1334 grep "cannot send message as 7bit" errors &&
1335 test -z "$(ls msgtxt*)"
1338 test_expect_success $PREREQ 'sendemail.transferencoding=8bit' '
1339 clean_fake_sendmail &&
1340 git send-email \
1341 --transfer-encoding=8bit \
1342 --smtp-server="$(pwd)/fake.sendmail" \
1343 email-using-8bit \
1344 2>errors >out &&
1345 sed '1,/^$/d' msgtxt1 >actual &&
1346 sed '1,/^$/d' email-using-8bit >expected &&
1347 test_cmp expected actual
1350 test_expect_success $PREREQ 'setup expect' '
1351 cat >expected <<-\EOF
1352 Dieser Betreff enth=C3=A4lt auch einen Umlaut!
1356 test_expect_success $PREREQ '8-bit and sendemail.transferencoding=quoted-printable' '
1357 clean_fake_sendmail &&
1358 git send-email \
1359 --transfer-encoding=quoted-printable \
1360 --smtp-server="$(pwd)/fake.sendmail" \
1361 email-using-8bit \
1362 2>errors >out &&
1363 sed '1,/^$/d' msgtxt1 >actual &&
1364 test_cmp expected actual
1367 test_expect_success $PREREQ 'setup expect' '
1368 cat >expected <<-\EOF
1369 RGllc2VyIEJldHJlZmYgZW50aMOkbHQgYXVjaCBlaW5lbiBVbWxhdXQhCg==
1373 test_expect_success $PREREQ '8-bit and sendemail.transferencoding=base64' '
1374 clean_fake_sendmail &&
1375 git send-email \
1376 --transfer-encoding=base64 \
1377 --smtp-server="$(pwd)/fake.sendmail" \
1378 email-using-8bit \
1379 2>errors >out &&
1380 sed '1,/^$/d' msgtxt1 >actual &&
1381 test_cmp expected actual
1384 test_expect_success $PREREQ 'setup expect' '
1385 cat >email-using-qp <<-\EOF
1386 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1387 Message-Id: <bogus-message-id@example.com>
1388 From: A U Thor <author@example.com>
1389 Date: Sat, 12 Jun 2010 15:53:58 +0200
1390 MIME-Version: 1.0
1391 Content-Transfer-Encoding: quoted-printable
1392 Content-Type: text/plain; charset=UTF-8
1393 Subject: Nothing to see here.
1395 Dieser Betreff enth=C3=A4lt auch einen Umlaut!
1399 test_expect_success $PREREQ 'convert from quoted-printable to base64' '
1400 clean_fake_sendmail &&
1401 git send-email \
1402 --transfer-encoding=base64 \
1403 --smtp-server="$(pwd)/fake.sendmail" \
1404 email-using-qp \
1405 2>errors >out &&
1406 sed '1,/^$/d' msgtxt1 >actual &&
1407 test_cmp expected actual
1410 test_expect_success $PREREQ 'setup expect' "
1411 tr -d '\\015' | tr '%' '\\015' >email-using-crlf <<EOF
1412 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1413 Message-Id: <bogus-message-id@example.com>
1414 From: A U Thor <author@example.com>
1415 Date: Sat, 12 Jun 2010 15:53:58 +0200
1416 Content-Type: text/plain; charset=UTF-8
1417 Subject: Nothing to see here.
1419 Look, I have a CRLF and an = sign!%
1423 test_expect_success $PREREQ 'setup expect' '
1424 cat >expected <<-\EOF
1425 Look, I have a CRLF and an =3D sign!=0D
1429 test_expect_success $PREREQ 'CRLF and sendemail.transferencoding=quoted-printable' '
1430 clean_fake_sendmail &&
1431 git send-email \
1432 --transfer-encoding=quoted-printable \
1433 --smtp-server="$(pwd)/fake.sendmail" \
1434 email-using-crlf \
1435 2>errors >out &&
1436 sed '1,/^$/d' msgtxt1 >actual &&
1437 test_cmp expected actual
1440 test_expect_success $PREREQ 'setup expect' '
1441 cat >expected <<-\EOF
1442 TG9vaywgSSBoYXZlIGEgQ1JMRiBhbmQgYW4gPSBzaWduIQ0K
1446 test_expect_success $PREREQ 'CRLF and sendemail.transferencoding=base64' '
1447 clean_fake_sendmail &&
1448 git send-email \
1449 --transfer-encoding=base64 \
1450 --smtp-server="$(pwd)/fake.sendmail" \
1451 email-using-crlf \
1452 2>errors >out &&
1453 sed '1,/^$/d' msgtxt1 >actual &&
1454 test_cmp expected actual
1458 # Note that the patches in this test are deliberately out of order; we
1459 # want to make sure it works even if the cover-letter is not in the
1460 # first mail.
1461 test_expect_success $PREREQ 'refusing to send cover letter template' '
1462 clean_fake_sendmail &&
1463 rm -fr outdir &&
1464 git format-patch --cover-letter -2 -o outdir &&
1465 test_must_fail git send-email \
1466 --from="Example <nobody@example.com>" \
1467 --to=nobody@example.com \
1468 --smtp-server="$(pwd)/fake.sendmail" \
1469 outdir/0002-*.patch \
1470 outdir/0000-*.patch \
1471 outdir/0001-*.patch \
1472 2>errors >out &&
1473 grep "SUBJECT HERE" errors &&
1474 test -z "$(ls msgtxt*)"
1477 test_expect_success $PREREQ '--force sends cover letter template anyway' '
1478 clean_fake_sendmail &&
1479 rm -fr outdir &&
1480 git format-patch --cover-letter -2 -o outdir &&
1481 git send-email \
1482 --force \
1483 --from="Example <nobody@example.com>" \
1484 --to=nobody@example.com \
1485 --smtp-server="$(pwd)/fake.sendmail" \
1486 outdir/0002-*.patch \
1487 outdir/0000-*.patch \
1488 outdir/0001-*.patch \
1489 2>errors >out &&
1490 ! grep "SUBJECT HERE" errors &&
1491 test -n "$(ls msgtxt*)"
1494 test_cover_addresses () {
1495 header="$1"
1496 shift
1497 clean_fake_sendmail &&
1498 rm -fr outdir &&
1499 git format-patch --cover-letter -2 -o outdir &&
1500 cover=`echo outdir/0000-*.patch` &&
1501 mv $cover cover-to-edit.patch &&
1502 perl -pe "s/^From:/$header: extra\@address.com\nFrom:/" cover-to-edit.patch >"$cover" &&
1503 git send-email \
1504 --force \
1505 --from="Example <nobody@example.com>" \
1506 --no-to --no-cc \
1507 "$@" \
1508 --smtp-server="$(pwd)/fake.sendmail" \
1509 outdir/0000-*.patch \
1510 outdir/0001-*.patch \
1511 outdir/0002-*.patch \
1512 2>errors >out &&
1513 grep "^$header: extra@address.com" msgtxt1 >to1 &&
1514 grep "^$header: extra@address.com" msgtxt2 >to2 &&
1515 grep "^$header: extra@address.com" msgtxt3 >to3 &&
1516 test_line_count = 1 to1 &&
1517 test_line_count = 1 to2 &&
1518 test_line_count = 1 to3
1521 test_expect_success $PREREQ 'to-cover adds To to all mail' '
1522 test_cover_addresses "To" --to-cover
1525 test_expect_success $PREREQ 'cc-cover adds Cc to all mail' '
1526 test_cover_addresses "Cc" --cc-cover
1529 test_expect_success $PREREQ 'tocover adds To to all mail' '
1530 test_config sendemail.tocover true &&
1531 test_cover_addresses "To"
1534 test_expect_success $PREREQ 'cccover adds Cc to all mail' '
1535 test_config sendemail.cccover true &&
1536 test_cover_addresses "Cc"
1539 test_expect_success $PREREQ 'sendemail.aliasfiletype=mailrc' '
1540 clean_fake_sendmail &&
1541 echo "alias sbd somebody@example.org" >.mailrc &&
1542 git config --replace-all sendemail.aliasesfile "$(pwd)/.mailrc" &&
1543 git config sendemail.aliasfiletype mailrc &&
1544 git send-email \
1545 --from="Example <nobody@example.com>" \
1546 --to=sbd \
1547 --smtp-server="$(pwd)/fake.sendmail" \
1548 outdir/0001-*.patch \
1549 2>errors >out &&
1550 grep "^!somebody@example\.org!$" commandline1
1553 test_expect_success $PREREQ 'sendemail.aliasfile=~/.mailrc' '
1554 clean_fake_sendmail &&
1555 echo "alias sbd someone@example.org" >~/.mailrc &&
1556 git config --replace-all sendemail.aliasesfile "~/.mailrc" &&
1557 git config sendemail.aliasfiletype mailrc &&
1558 git send-email \
1559 --from="Example <nobody@example.com>" \
1560 --to=sbd \
1561 --smtp-server="$(pwd)/fake.sendmail" \
1562 outdir/0001-*.patch \
1563 2>errors >out &&
1564 grep "^!someone@example\.org!$" commandline1
1567 do_xmailer_test () {
1568 expected=$1 params=$2 &&
1569 git format-patch -1 &&
1570 git send-email \
1571 --from="Example <nobody@example.com>" \
1572 --to=someone@example.com \
1573 --smtp-server="$(pwd)/fake.sendmail" \
1574 $params \
1575 0001-*.patch \
1576 2>errors >out &&
1577 { grep '^X-Mailer:' out || :; } >mailer &&
1578 test_line_count = $expected mailer
1581 test_expect_success $PREREQ '--[no-]xmailer without any configuration' '
1582 do_xmailer_test 1 "--xmailer" &&
1583 do_xmailer_test 0 "--no-xmailer"
1586 test_expect_success $PREREQ '--[no-]xmailer with sendemail.xmailer=true' '
1587 test_config sendemail.xmailer true &&
1588 do_xmailer_test 1 "" &&
1589 do_xmailer_test 0 "--no-xmailer" &&
1590 do_xmailer_test 1 "--xmailer"
1593 test_expect_success $PREREQ '--[no-]xmailer with sendemail.xmailer=false' '
1594 test_config sendemail.xmailer false &&
1595 do_xmailer_test 0 "" &&
1596 do_xmailer_test 0 "--no-xmailer" &&
1597 do_xmailer_test 1 "--xmailer"
1600 test_done