Merge branch 'maint'
[git/mingw.git] / t / t9001-send-email.sh
blob752adaac850862caf50e3573338b9cb742781147
1 #!/bin/sh
3 test_description='git send-email'
4 . ./test-lib.sh
6 if ! test_have_prereq PERL; then
7 say 'skipping git send-email tests, perl not available'
8 test_done
9 fi
11 PROG='git send-email'
12 test_expect_success \
13 'prepare reference tree' \
14 'echo "1A quick brown fox jumps over the" >file &&
15 echo "lazy dog" >>file &&
16 git add file &&
17 GIT_AUTHOR_NAME="A" git commit -a -m "Initial."'
19 test_expect_success \
20 'Setup helper tool' \
21 '(echo "#!$SHELL_PATH"
22 echo shift
23 echo output=1
24 echo "while test -f commandline\$output; do output=\$((\$output+1)); done"
25 echo for a
26 echo do
27 echo " echo \"!\$a!\""
28 echo "done >commandline\$output"
29 echo "cat > msgtxt\$output"
30 ) >fake.sendmail &&
31 chmod +x ./fake.sendmail &&
32 git add fake.sendmail &&
33 GIT_AUTHOR_NAME="A" git commit -a -m "Second."'
35 clean_fake_sendmail() {
36 rm -f commandline* msgtxt*
39 test_expect_success 'Extract patches' '
40 patches=`git format-patch -s --cc="One <one@example.com>" --cc=two@example.com -n HEAD^1`
43 # Test no confirm early to ensure remaining tests will not hang
44 test_no_confirm () {
45 rm -f no_confirm_okay
46 echo n | \
47 GIT_SEND_EMAIL_NOTTY=1 \
48 git send-email \
49 --from="Example <from@example.com>" \
50 --to=nobody@example.com \
51 --smtp-server="$(pwd)/fake.sendmail" \
52 $@ \
53 $patches > stdout &&
54 test_must_fail grep "Send this email" stdout &&
55 > no_confirm_okay
58 # Exit immediately to prevent hang if a no-confirm test fails
59 check_no_confirm () {
60 test -f no_confirm_okay || {
61 say 'No confirm test failed; skipping remaining tests to prevent hanging'
62 test_done
66 test_expect_success 'No confirm with --suppress-cc' '
67 test_no_confirm --suppress-cc=sob
69 check_no_confirm
71 test_expect_success 'No confirm with --confirm=never' '
72 test_no_confirm --confirm=never
74 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 'No confirm with sendemail.confirm=never' '
79 git config sendemail.confirm never &&
80 test_no_confirm --compose --subject=foo
82 check_no_confirm
84 test_expect_success '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 cat >expected <<\EOF
89 !nobody@example.com!
90 !author@example.com!
91 !one@example.com!
92 !two@example.com!
93 EOF
94 test_expect_success \
95 'Verify commandline' \
96 'test_cmp expected commandline1'
98 test_expect_success 'Send patches with --envelope-sender' '
99 clean_fake_sendmail &&
100 git send-email --envelope-sender="Patch Contributer <patch@example.com>" --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors
103 cat >expected <<\EOF
104 !patch@example.com!
105 !-i!
106 !nobody@example.com!
107 !author@example.com!
108 !one@example.com!
109 !two@example.com!
111 test_expect_success \
112 'Verify commandline' \
113 'test_cmp expected commandline1'
115 test_expect_success 'Send patches with --envelope-sender=auto' '
116 clean_fake_sendmail &&
117 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
120 cat >expected <<\EOF
121 !nobody@example.com!
122 !-i!
123 !nobody@example.com!
124 !author@example.com!
125 !one@example.com!
126 !two@example.com!
128 test_expect_success \
129 'Verify commandline' \
130 'test_cmp expected commandline1'
132 cat >expected-show-all-headers <<\EOF
133 0001-Second.patch
134 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
135 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
136 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
137 Dry-OK. Log says:
138 Server: relay.example.com
139 MAIL FROM:<from@example.com>
140 RCPT TO:<to@example.com>
141 RCPT TO:<cc@example.com>
142 RCPT TO:<author@example.com>
143 RCPT TO:<one@example.com>
144 RCPT TO:<two@example.com>
145 RCPT TO:<bcc@example.com>
146 From: Example <from@example.com>
147 To: to@example.com
148 Cc: cc@example.com,
149 A <author@example.com>,
150 One <one@example.com>,
151 two@example.com
152 Subject: [PATCH 1/1] Second.
153 Date: DATE-STRING
154 Message-Id: MESSAGE-ID-STRING
155 X-Mailer: X-MAILER-STRING
156 In-Reply-To: <unique-message-id@example.com>
157 References: <unique-message-id@example.com>
159 Result: OK
162 test_expect_success 'Show all headers' '
163 git send-email \
164 --dry-run \
165 --suppress-cc=sob \
166 --from="Example <from@example.com>" \
167 --to=to@example.com \
168 --cc=cc@example.com \
169 --bcc=bcc@example.com \
170 --in-reply-to="<unique-message-id@example.com>" \
171 --smtp-server relay.example.com \
172 $patches |
173 sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
174 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
175 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
176 >actual-show-all-headers &&
177 test_cmp expected-show-all-headers actual-show-all-headers
180 test_expect_success 'Prompting works' '
181 clean_fake_sendmail &&
182 (echo "Example <from@example.com>"
183 echo "to@example.com"
184 echo ""
185 ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
186 --smtp-server="$(pwd)/fake.sendmail" \
187 $patches \
188 2>errors &&
189 grep "^From: Example <from@example.com>$" msgtxt1 &&
190 grep "^To: to@example.com$" msgtxt1
193 test_expect_success 'cccmd works' '
194 clean_fake_sendmail &&
195 cp $patches cccmd.patch &&
196 echo cccmd--cccmd@example.com >>cccmd.patch &&
198 echo "#!$SHELL_PATH"
199 echo sed -n -e s/^cccmd--//p \"\$1\"
200 } > cccmd-sed &&
201 chmod +x cccmd-sed &&
202 git send-email \
203 --from="Example <nobody@example.com>" \
204 --to=nobody@example.com \
205 --cc-cmd=./cccmd-sed \
206 --smtp-server="$(pwd)/fake.sendmail" \
207 cccmd.patch \
209 grep "^ cccmd@example.com" msgtxt1
212 z8=zzzzzzzz
213 z64=$z8$z8$z8$z8$z8$z8$z8$z8
214 z512=$z64$z64$z64$z64$z64$z64$z64$z64
215 test_expect_success 'reject long lines' '
216 clean_fake_sendmail &&
217 cp $patches longline.patch &&
218 echo $z512$z512 >>longline.patch &&
219 test_must_fail git send-email \
220 --from="Example <nobody@example.com>" \
221 --to=nobody@example.com \
222 --smtp-server="$(pwd)/fake.sendmail" \
223 $patches longline.patch \
224 2>errors &&
225 grep longline.patch errors
228 test_expect_success 'no patch was sent' '
229 ! test -e commandline1
232 test_expect_success 'Author From: in message body' '
233 clean_fake_sendmail &&
234 git send-email \
235 --from="Example <nobody@example.com>" \
236 --to=nobody@example.com \
237 --smtp-server="$(pwd)/fake.sendmail" \
238 $patches &&
239 sed "1,/^$/d" < msgtxt1 > msgbody1
240 grep "From: A <author@example.com>" msgbody1
243 test_expect_success 'Author From: not in message body' '
244 clean_fake_sendmail &&
245 git send-email \
246 --from="A <author@example.com>" \
247 --to=nobody@example.com \
248 --smtp-server="$(pwd)/fake.sendmail" \
249 $patches &&
250 sed "1,/^$/d" < msgtxt1 > msgbody1
251 ! grep "From: A <author@example.com>" msgbody1
254 test_expect_success 'allow long lines with --no-validate' '
255 git send-email \
256 --from="Example <nobody@example.com>" \
257 --to=nobody@example.com \
258 --smtp-server="$(pwd)/fake.sendmail" \
259 --novalidate \
260 $patches longline.patch \
261 2>errors
264 test_expect_success 'Invalid In-Reply-To' '
265 clean_fake_sendmail &&
266 git send-email \
267 --from="Example <nobody@example.com>" \
268 --to=nobody@example.com \
269 --in-reply-to=" " \
270 --smtp-server="$(pwd)/fake.sendmail" \
271 $patches
272 2>errors
273 ! grep "^In-Reply-To: < *>" msgtxt1
276 test_expect_success 'Valid In-Reply-To when prompting' '
277 clean_fake_sendmail &&
278 (echo "From Example <from@example.com>"
279 echo "To Example <to@example.com>"
280 echo ""
281 ) | env GIT_SEND_EMAIL_NOTTY=1 git send-email \
282 --smtp-server="$(pwd)/fake.sendmail" \
283 $patches 2>errors &&
284 ! grep "^In-Reply-To: < *>" msgtxt1
287 test_expect_success 'setup fake editor' '
288 (echo "#!$SHELL_PATH" &&
289 echo "echo fake edit >>\"\$1\""
290 ) >fake-editor &&
291 chmod +x fake-editor
294 test_set_editor "$(pwd)/fake-editor"
296 test_expect_success '--compose works' '
297 clean_fake_sendmail &&
298 git send-email \
299 --compose --subject foo \
300 --from="Example <nobody@example.com>" \
301 --to=nobody@example.com \
302 --smtp-server="$(pwd)/fake.sendmail" \
303 $patches \
304 2>errors
307 test_expect_success 'first message is compose text' '
308 grep "^fake edit" msgtxt1
311 test_expect_success 'second message is patch' '
312 grep "Subject:.*Second" msgtxt2
315 cat >expected-suppress-sob <<\EOF
316 0001-Second.patch
317 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
318 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
319 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
320 Dry-OK. Log says:
321 Server: relay.example.com
322 MAIL FROM:<from@example.com>
323 RCPT TO:<to@example.com>
324 RCPT TO:<cc@example.com>
325 RCPT TO:<author@example.com>
326 RCPT TO:<one@example.com>
327 RCPT TO:<two@example.com>
328 From: Example <from@example.com>
329 To: to@example.com
330 Cc: cc@example.com,
331 A <author@example.com>,
332 One <one@example.com>,
333 two@example.com
334 Subject: [PATCH 1/1] Second.
335 Date: DATE-STRING
336 Message-Id: MESSAGE-ID-STRING
337 X-Mailer: X-MAILER-STRING
339 Result: OK
342 test_suppression () {
343 git send-email \
344 --dry-run \
345 --suppress-cc=$1 ${2+"--suppress-cc=$2"} \
346 --from="Example <from@example.com>" \
347 --to=to@example.com \
348 --smtp-server relay.example.com \
349 $patches |
350 sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
351 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
352 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
353 >actual-suppress-$1${2+"-$2"} &&
354 test_cmp expected-suppress-$1${2+"-$2"} actual-suppress-$1${2+"-$2"}
357 test_expect_success 'sendemail.cc set' '
358 git config sendemail.cc cc@example.com &&
359 test_suppression sob
362 cat >expected-suppress-sob <<\EOF
363 0001-Second.patch
364 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
365 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
366 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
367 Dry-OK. Log says:
368 Server: relay.example.com
369 MAIL FROM:<from@example.com>
370 RCPT TO:<to@example.com>
371 RCPT TO:<author@example.com>
372 RCPT TO:<one@example.com>
373 RCPT TO:<two@example.com>
374 From: Example <from@example.com>
375 To: to@example.com
376 Cc: A <author@example.com>,
377 One <one@example.com>,
378 two@example.com
379 Subject: [PATCH 1/1] Second.
380 Date: DATE-STRING
381 Message-Id: MESSAGE-ID-STRING
382 X-Mailer: X-MAILER-STRING
384 Result: OK
387 test_expect_success 'sendemail.cc unset' '
388 git config --unset sendemail.cc &&
389 test_suppression sob
392 cat >expected-suppress-cccmd <<\EOF
393 0001-Second.patch
394 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
395 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
396 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
397 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
398 Dry-OK. Log says:
399 Server: relay.example.com
400 MAIL FROM:<from@example.com>
401 RCPT TO:<to@example.com>
402 RCPT TO:<author@example.com>
403 RCPT TO:<one@example.com>
404 RCPT TO:<two@example.com>
405 RCPT TO:<committer@example.com>
406 From: Example <from@example.com>
407 To: to@example.com
408 Cc: A <author@example.com>,
409 One <one@example.com>,
410 two@example.com,
411 C O Mitter <committer@example.com>
412 Subject: [PATCH 1/1] Second.
413 Date: DATE-STRING
414 Message-Id: MESSAGE-ID-STRING
415 X-Mailer: X-MAILER-STRING
417 Result: OK
420 test_expect_success 'sendemail.cccmd' '
421 echo echo cc-cmd@example.com > cccmd &&
422 chmod +x cccmd &&
423 git config sendemail.cccmd ./cccmd &&
424 test_suppression cccmd
427 cat >expected-suppress-all <<\EOF
428 0001-Second.patch
429 Dry-OK. Log says:
430 Server: relay.example.com
431 MAIL FROM:<from@example.com>
432 RCPT TO:<to@example.com>
433 From: Example <from@example.com>
434 To: to@example.com
435 Subject: [PATCH 1/1] Second.
436 Date: DATE-STRING
437 Message-Id: MESSAGE-ID-STRING
438 X-Mailer: X-MAILER-STRING
440 Result: OK
443 test_expect_success '--suppress-cc=all' '
444 test_suppression all
447 cat >expected-suppress-body <<\EOF
448 0001-Second.patch
449 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
450 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
451 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
452 (cc-cmd) Adding cc: cc-cmd@example.com from: './cccmd'
453 Dry-OK. Log says:
454 Server: relay.example.com
455 MAIL FROM:<from@example.com>
456 RCPT TO:<to@example.com>
457 RCPT TO:<author@example.com>
458 RCPT TO:<one@example.com>
459 RCPT TO:<two@example.com>
460 RCPT TO:<cc-cmd@example.com>
461 From: Example <from@example.com>
462 To: to@example.com
463 Cc: A <author@example.com>,
464 One <one@example.com>,
465 two@example.com,
466 cc-cmd@example.com
467 Subject: [PATCH 1/1] Second.
468 Date: DATE-STRING
469 Message-Id: MESSAGE-ID-STRING
470 X-Mailer: X-MAILER-STRING
472 Result: OK
475 test_expect_success '--suppress-cc=body' '
476 test_suppression body
479 cat >expected-suppress-body-cccmd <<\EOF
480 0001-Second.patch
481 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
482 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
483 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
484 Dry-OK. Log says:
485 Server: relay.example.com
486 MAIL FROM:<from@example.com>
487 RCPT TO:<to@example.com>
488 RCPT TO:<author@example.com>
489 RCPT TO:<one@example.com>
490 RCPT TO:<two@example.com>
491 From: Example <from@example.com>
492 To: to@example.com
493 Cc: A <author@example.com>,
494 One <one@example.com>,
495 two@example.com
496 Subject: [PATCH 1/1] Second.
497 Date: DATE-STRING
498 Message-Id: MESSAGE-ID-STRING
499 X-Mailer: X-MAILER-STRING
501 Result: OK
504 test_expect_success '--suppress-cc=body --suppress-cc=cccmd' '
505 test_suppression body cccmd
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
533 test_expect_success '--suppress-cc=sob' '
534 git config --unset sendemail.cccmd
535 test_suppression sob
538 cat >expected-suppress-bodycc <<\EOF
539 0001-Second.patch
540 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
541 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
542 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
543 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@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 RCPT TO:<committer@example.com>
552 From: Example <from@example.com>
553 To: to@example.com
554 Cc: A <author@example.com>,
555 One <one@example.com>,
556 two@example.com,
557 C O Mitter <committer@example.com>
558 Subject: [PATCH 1/1] Second.
559 Date: DATE-STRING
560 Message-Id: MESSAGE-ID-STRING
561 X-Mailer: X-MAILER-STRING
563 Result: OK
566 test_expect_success '--suppress-cc=bodycc' '
567 test_suppression bodycc
570 cat >expected-suppress-cc <<\EOF
571 0001-Second.patch
572 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
573 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
574 Dry-OK. Log says:
575 Server: relay.example.com
576 MAIL FROM:<from@example.com>
577 RCPT TO:<to@example.com>
578 RCPT TO:<author@example.com>
579 RCPT TO:<committer@example.com>
580 From: Example <from@example.com>
581 To: to@example.com
582 Cc: A <author@example.com>,
583 C O Mitter <committer@example.com>
584 Subject: [PATCH 1/1] Second.
585 Date: DATE-STRING
586 Message-Id: MESSAGE-ID-STRING
587 X-Mailer: X-MAILER-STRING
589 Result: OK
592 test_expect_success '--suppress-cc=cc' '
593 test_suppression cc
596 test_confirm () {
597 echo y | \
598 GIT_SEND_EMAIL_NOTTY=1 \
599 git send-email \
600 --from="Example <nobody@example.com>" \
601 --to=nobody@example.com \
602 --smtp-server="$(pwd)/fake.sendmail" \
603 $@ $patches > stdout &&
604 grep "Send this email" stdout
607 test_expect_success '--confirm=always' '
608 test_confirm --confirm=always --suppress-cc=all
611 test_expect_success '--confirm=auto' '
612 test_confirm --confirm=auto
615 test_expect_success '--confirm=cc' '
616 test_confirm --confirm=cc
619 test_expect_success '--confirm=compose' '
620 test_confirm --confirm=compose --compose
623 test_expect_success 'confirm by default (due to cc)' '
624 CONFIRM=$(git config --get sendemail.confirm) &&
625 git config --unset sendemail.confirm &&
626 test_confirm
627 ret="$?"
628 git config sendemail.confirm ${CONFIRM:-never}
629 test $ret = "0"
632 test_expect_success 'confirm by default (due to --compose)' '
633 CONFIRM=$(git config --get sendemail.confirm) &&
634 git config --unset sendemail.confirm &&
635 test_confirm --suppress-cc=all --compose
636 ret="$?"
637 git config sendemail.confirm ${CONFIRM:-never}
638 test $ret = "0"
641 test_expect_success 'confirm detects EOF (inform assumes y)' '
642 CONFIRM=$(git config --get sendemail.confirm) &&
643 git config --unset sendemail.confirm &&
644 rm -fr outdir &&
645 git format-patch -2 -o outdir &&
646 GIT_SEND_EMAIL_NOTTY=1 \
647 git send-email \
648 --from="Example <nobody@example.com>" \
649 --to=nobody@example.com \
650 --smtp-server="$(pwd)/fake.sendmail" \
651 outdir/*.patch < /dev/null
652 ret="$?"
653 git config sendemail.confirm ${CONFIRM:-never}
654 test $ret = "0"
657 test_expect_success 'confirm detects EOF (auto causes failure)' '
658 CONFIRM=$(git config --get sendemail.confirm) &&
659 git config sendemail.confirm auto &&
660 GIT_SEND_EMAIL_NOTTY=1 &&
661 export GIT_SEND_EMAIL_NOTTY &&
662 test_must_fail git send-email \
663 --from="Example <nobody@example.com>" \
664 --to=nobody@example.com \
665 --smtp-server="$(pwd)/fake.sendmail" \
666 $patches < /dev/null
667 ret="$?"
668 git config sendemail.confirm ${CONFIRM:-never}
669 test $ret = "0"
672 test_expect_success 'confirm doesnt loop forever' '
673 CONFIRM=$(git config --get sendemail.confirm) &&
674 git config sendemail.confirm auto &&
675 GIT_SEND_EMAIL_NOTTY=1 &&
676 export GIT_SEND_EMAIL_NOTTY &&
677 yes "bogus" | test_must_fail git send-email \
678 --from="Example <nobody@example.com>" \
679 --to=nobody@example.com \
680 --smtp-server="$(pwd)/fake.sendmail" \
681 $patches
682 ret="$?"
683 git config sendemail.confirm ${CONFIRM:-never}
684 test $ret = "0"
687 test_expect_success 'utf8 Cc is rfc2047 encoded' '
688 clean_fake_sendmail &&
689 rm -fr outdir &&
690 git format-patch -1 -o outdir --cc="àéìöú <utf8@example.com>" &&
691 git send-email \
692 --from="Example <nobody@example.com>" \
693 --to=nobody@example.com \
694 --smtp-server="$(pwd)/fake.sendmail" \
695 outdir/*.patch &&
696 grep "^ " msgtxt1 |
697 grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>"
700 test_expect_success '--compose adds MIME for utf8 body' '
701 clean_fake_sendmail &&
702 (echo "#!$SHELL_PATH" &&
703 echo "echo utf8 body: àéìöú >>\"\$1\""
704 ) >fake-editor-utf8 &&
705 chmod +x fake-editor-utf8 &&
706 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
707 git send-email \
708 --compose --subject foo \
709 --from="Example <nobody@example.com>" \
710 --to=nobody@example.com \
711 --smtp-server="$(pwd)/fake.sendmail" \
712 $patches &&
713 grep "^utf8 body" msgtxt1 &&
714 grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
717 test_expect_success '--compose respects user mime type' '
718 clean_fake_sendmail &&
719 (echo "#!$SHELL_PATH" &&
720 echo "(echo MIME-Version: 1.0"
721 echo " echo Content-Type: text/plain\\; charset=iso-8859-1"
722 echo " echo Content-Transfer-Encoding: 8bit"
723 echo " echo Subject: foo"
724 echo " echo "
725 echo " echo utf8 body: àéìöú) >\"\$1\""
726 ) >fake-editor-utf8-mime &&
727 chmod +x fake-editor-utf8-mime &&
728 GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \
729 git send-email \
730 --compose --subject foo \
731 --from="Example <nobody@example.com>" \
732 --to=nobody@example.com \
733 --smtp-server="$(pwd)/fake.sendmail" \
734 $patches &&
735 grep "^utf8 body" msgtxt1 &&
736 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 &&
737 ! grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
740 test_expect_success '--compose adds MIME for utf8 subject' '
741 clean_fake_sendmail &&
742 GIT_EDITOR="\"$(pwd)/fake-editor\"" \
743 git send-email \
744 --compose --subject utf8-sübjëct \
745 --from="Example <nobody@example.com>" \
746 --to=nobody@example.com \
747 --smtp-server="$(pwd)/fake.sendmail" \
748 $patches &&
749 grep "^fake edit" msgtxt1 &&
750 grep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
753 test_expect_success 'detects ambiguous reference/file conflict' '
754 echo master > master &&
755 git add master &&
756 git commit -m"add master" &&
757 test_must_fail git send-email --dry-run master 2>errors &&
758 grep disambiguate errors
761 test_expect_success 'feed two files' '
762 rm -fr outdir &&
763 git format-patch -2 -o outdir &&
764 git send-email \
765 --dry-run \
766 --from="Example <nobody@example.com>" \
767 --to=nobody@example.com \
768 outdir/000?-*.patch 2>errors >out &&
769 grep "^Subject: " out >subjects &&
770 test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." &&
771 test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add master"
774 test_expect_success 'in-reply-to but no threading' '
775 git send-email \
776 --dry-run \
777 --from="Example <nobody@example.com>" \
778 --to=nobody@example.com \
779 --in-reply-to="<in-reply-id@example.com>" \
780 --nothread \
781 $patches |
782 grep "In-Reply-To: <in-reply-id@example.com>"
785 test_expect_success 'no in-reply-to and no threading' '
786 git send-email \
787 --dry-run \
788 --from="Example <nobody@example.com>" \
789 --to=nobody@example.com \
790 --nothread \
791 $patches $patches >stdout &&
792 ! grep "In-Reply-To: " stdout
795 test_expect_success 'threading but no chain-reply-to' '
796 git send-email \
797 --dry-run \
798 --from="Example <nobody@example.com>" \
799 --to=nobody@example.com \
800 --thread \
801 --nochain-reply-to \
802 $patches $patches >stdout &&
803 grep "In-Reply-To: " stdout
806 test_expect_success 'warning with an implicit --chain-reply-to' '
807 git send-email \
808 --dry-run \
809 --from="Example <nobody@example.com>" \
810 --to=nobody@example.com \
811 outdir/000?-*.patch 2>errors >out &&
812 grep "no-chain-reply-to" errors
815 test_expect_success 'no warning with an explicit --chain-reply-to' '
816 git send-email \
817 --dry-run \
818 --from="Example <nobody@example.com>" \
819 --to=nobody@example.com \
820 --chain-reply-to \
821 outdir/000?-*.patch 2>errors >out &&
822 ! grep "no-chain-reply-to" errors
825 test_expect_success 'no warning with an explicit --no-chain-reply-to' '
826 git send-email \
827 --dry-run \
828 --from="Example <nobody@example.com>" \
829 --to=nobody@example.com \
830 --nochain-reply-to \
831 outdir/000?-*.patch 2>errors >out &&
832 ! grep "no-chain-reply-to" errors
835 test_expect_success 'no warning with sendemail.chainreplyto = false' '
836 git config sendemail.chainreplyto false &&
837 git send-email \
838 --dry-run \
839 --from="Example <nobody@example.com>" \
840 --to=nobody@example.com \
841 outdir/000?-*.patch 2>errors >out &&
842 ! grep "no-chain-reply-to" errors
845 test_expect_success 'no warning with sendemail.chainreplyto = true' '
846 git config sendemail.chainreplyto true &&
847 git send-email \
848 --dry-run \
849 --from="Example <nobody@example.com>" \
850 --to=nobody@example.com \
851 outdir/000?-*.patch 2>errors >out &&
852 ! grep "no-chain-reply-to" errors
855 test_done