Code

Merge branch 'rs/maint-archive-prefix'
[git.git] / t / t9001-send-email.sh
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*
37 }
39 test_expect_success 'Extract patches' '
40     patches=`git format-patch -s --cc="One <one@example.com>" --cc=two@example.com -n HEAD^1`
41 '
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
56 }
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
63         }
64 }
66 test_expect_success 'No confirm with --suppress-cc' '
67         test_no_confirm --suppress-cc=sob
68 '
69 check_no_confirm
71 test_expect_success 'No confirm with --confirm=never' '
72         test_no_confirm --confirm=never
73 '
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
81 '
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
86 '
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 cat >expected-show-all-headers <<\EOF
99 0001-Second.patch
100 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
101 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
102 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
103 Dry-OK. Log says:
104 Server: relay.example.com
105 MAIL FROM:<from@example.com>
106 RCPT TO:<to@example.com>,<cc@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<bcc@example.com>
107 From: Example <from@example.com>
108 To: to@example.com
109 Cc: cc@example.com, A <author@example.com>, One <one@example.com>, two@example.com
110 Subject: [PATCH 1/1] Second.
111 Date: DATE-STRING
112 Message-Id: MESSAGE-ID-STRING
113 X-Mailer: X-MAILER-STRING
114 In-Reply-To: <unique-message-id@example.com>
115 References: <unique-message-id@example.com>
117 Result: OK
118 EOF
120 test_expect_success 'Show all headers' '
121         git send-email \
122                 --dry-run \
123                 --suppress-cc=sob \
124                 --from="Example <from@example.com>" \
125                 --to=to@example.com \
126                 --cc=cc@example.com \
127                 --bcc=bcc@example.com \
128                 --in-reply-to="<unique-message-id@example.com>" \
129                 --smtp-server relay.example.com \
130                 $patches |
131         sed     -e "s/^\(Date:\).*/\1 DATE-STRING/" \
132                 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
133                 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
134                 >actual-show-all-headers &&
135         test_cmp expected-show-all-headers actual-show-all-headers
138 test_expect_success 'Prompting works' '
139         clean_fake_sendmail &&
140         (echo "Example <from@example.com>"
141          echo "to@example.com"
142          echo ""
143         ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
144                 --smtp-server="$(pwd)/fake.sendmail" \
145                 $patches \
146                 2>errors &&
147                 grep "^From: Example <from@example.com>$" msgtxt1 &&
148                 grep "^To: to@example.com$" msgtxt1
151 test_expect_success 'cccmd works' '
152         clean_fake_sendmail &&
153         cp $patches cccmd.patch &&
154         echo cccmd--cccmd@example.com >>cccmd.patch &&
155         {
156           echo "#!$SHELL_PATH"
157           echo sed -n -e s/^cccmd--//p \"\$1\"
158         } > cccmd-sed &&
159         chmod +x cccmd-sed &&
160         git send-email \
161                 --from="Example <nobody@example.com>" \
162                 --to=nobody@example.com \
163                 --cc-cmd=./cccmd-sed \
164                 --smtp-server="$(pwd)/fake.sendmail" \
165                 cccmd.patch \
166                 &&
167         grep ^Cc:.*cccmd@example.com msgtxt1
170 z8=zzzzzzzz
171 z64=$z8$z8$z8$z8$z8$z8$z8$z8
172 z512=$z64$z64$z64$z64$z64$z64$z64$z64
173 test_expect_success 'reject long lines' '
174         clean_fake_sendmail &&
175         cp $patches longline.patch &&
176         echo $z512$z512 >>longline.patch &&
177         test_must_fail git send-email \
178                 --from="Example <nobody@example.com>" \
179                 --to=nobody@example.com \
180                 --smtp-server="$(pwd)/fake.sendmail" \
181                 $patches longline.patch \
182                 2>errors &&
183         grep longline.patch errors
186 test_expect_success 'no patch was sent' '
187         ! test -e commandline1
190 test_expect_success 'Author From: in message body' '
191         clean_fake_sendmail &&
192         git send-email \
193                 --from="Example <nobody@example.com>" \
194                 --to=nobody@example.com \
195                 --smtp-server="$(pwd)/fake.sendmail" \
196                 $patches &&
197         sed "1,/^$/d" < msgtxt1 > msgbody1
198         grep "From: A <author@example.com>" msgbody1
201 test_expect_success 'Author From: not in message body' '
202         clean_fake_sendmail &&
203         git send-email \
204                 --from="A <author@example.com>" \
205                 --to=nobody@example.com \
206                 --smtp-server="$(pwd)/fake.sendmail" \
207                 $patches &&
208         sed "1,/^$/d" < msgtxt1 > msgbody1
209         ! grep "From: A <author@example.com>" msgbody1
212 test_expect_success 'allow long lines with --no-validate' '
213         git send-email \
214                 --from="Example <nobody@example.com>" \
215                 --to=nobody@example.com \
216                 --smtp-server="$(pwd)/fake.sendmail" \
217                 --novalidate \
218                 $patches longline.patch \
219                 2>errors
222 test_expect_success 'Invalid In-Reply-To' '
223         clean_fake_sendmail &&
224         git send-email \
225                 --from="Example <nobody@example.com>" \
226                 --to=nobody@example.com \
227                 --in-reply-to=" " \
228                 --smtp-server="$(pwd)/fake.sendmail" \
229                 $patches
230                 2>errors
231         ! grep "^In-Reply-To: < *>" msgtxt1
234 test_expect_success 'Valid In-Reply-To when prompting' '
235         clean_fake_sendmail &&
236         (echo "From Example <from@example.com>"
237          echo "To Example <to@example.com>"
238          echo ""
239         ) | env GIT_SEND_EMAIL_NOTTY=1 git send-email \
240                 --smtp-server="$(pwd)/fake.sendmail" \
241                 $patches 2>errors &&
242         ! grep "^In-Reply-To: < *>" msgtxt1
245 test_expect_success 'setup fake editor' '
246         (echo "#!$SHELL_PATH" &&
247          echo "echo fake edit >>\"\$1\""
248         ) >fake-editor &&
249         chmod +x fake-editor
252 test_set_editor "$(pwd)/fake-editor"
254 test_expect_success '--compose works' '
255         clean_fake_sendmail &&
256         git send-email \
257         --compose --subject foo \
258         --from="Example <nobody@example.com>" \
259         --to=nobody@example.com \
260         --smtp-server="$(pwd)/fake.sendmail" \
261         $patches \
262         2>errors
265 test_expect_success 'first message is compose text' '
266         grep "^fake edit" msgtxt1
269 test_expect_success 'second message is patch' '
270         grep "Subject:.*Second" msgtxt2
273 cat >expected-suppress-sob <<\EOF
274 0001-Second.patch
275 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
276 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
277 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
278 Dry-OK. Log says:
279 Server: relay.example.com
280 MAIL FROM:<from@example.com>
281 RCPT TO:<to@example.com>,<cc@example.com>,<author@example.com>,<one@example.com>,<two@example.com>
282 From: Example <from@example.com>
283 To: to@example.com
284 Cc: cc@example.com, A <author@example.com>, One <one@example.com>, two@example.com
285 Subject: [PATCH 1/1] Second.
286 Date: DATE-STRING
287 Message-Id: MESSAGE-ID-STRING
288 X-Mailer: X-MAILER-STRING
290 Result: OK
291 EOF
293 test_suppression () {
294         git send-email \
295                 --dry-run \
296                 --suppress-cc=$1 ${2+"--suppress-cc=$2"} \
297                 --from="Example <from@example.com>" \
298                 --to=to@example.com \
299                 --smtp-server relay.example.com \
300                 $patches |
301         sed     -e "s/^\(Date:\).*/\1 DATE-STRING/" \
302                 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
303                 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
304                 >actual-suppress-$1${2+"-$2"} &&
305         test_cmp expected-suppress-$1${2+"-$2"} actual-suppress-$1${2+"-$2"}
308 test_expect_success 'sendemail.cc set' '
309         git config sendemail.cc cc@example.com &&
310         test_suppression sob
313 cat >expected-suppress-sob <<\EOF
314 0001-Second.patch
315 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
316 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
317 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
318 Dry-OK. Log says:
319 Server: relay.example.com
320 MAIL FROM:<from@example.com>
321 RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>
322 From: Example <from@example.com>
323 To: to@example.com
324 Cc: A <author@example.com>, One <one@example.com>, two@example.com
325 Subject: [PATCH 1/1] Second.
326 Date: DATE-STRING
327 Message-Id: MESSAGE-ID-STRING
328 X-Mailer: X-MAILER-STRING
330 Result: OK
331 EOF
333 test_expect_success 'sendemail.cc unset' '
334         git config --unset sendemail.cc &&
335         test_suppression sob
338 cat >expected-suppress-cccmd <<\EOF
339 0001-Second.patch
340 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
341 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
342 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
343 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
344 Dry-OK. Log says:
345 Server: relay.example.com
346 MAIL FROM:<from@example.com>
347 RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<committer@example.com>
348 From: Example <from@example.com>
349 To: to@example.com
350 Cc: A <author@example.com>, One <one@example.com>, two@example.com, C O Mitter <committer@example.com>
351 Subject: [PATCH 1/1] Second.
352 Date: DATE-STRING
353 Message-Id: MESSAGE-ID-STRING
354 X-Mailer: X-MAILER-STRING
356 Result: OK
357 EOF
359 test_expect_success 'sendemail.cccmd' '
360         echo echo cc-cmd@example.com > cccmd &&
361         chmod +x cccmd &&
362         git config sendemail.cccmd ./cccmd &&
363         test_suppression cccmd
366 cat >expected-suppress-all <<\EOF
367 0001-Second.patch
368 Dry-OK. Log says:
369 Server: relay.example.com
370 MAIL FROM:<from@example.com>
371 RCPT TO:<to@example.com>
372 From: Example <from@example.com>
373 To: to@example.com
374 Subject: [PATCH 1/1] Second.
375 Date: DATE-STRING
376 Message-Id: MESSAGE-ID-STRING
377 X-Mailer: X-MAILER-STRING
379 Result: OK
380 EOF
382 test_expect_success '--suppress-cc=all' '
383         test_suppression all
386 cat >expected-suppress-body <<\EOF
387 0001-Second.patch
388 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
389 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
390 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
391 (cc-cmd) Adding cc: cc-cmd@example.com from: './cccmd'
392 Dry-OK. Log says:
393 Server: relay.example.com
394 MAIL FROM:<from@example.com>
395 RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<cc-cmd@example.com>
396 From: Example <from@example.com>
397 To: to@example.com
398 Cc: A <author@example.com>, One <one@example.com>, two@example.com, cc-cmd@example.com
399 Subject: [PATCH 1/1] Second.
400 Date: DATE-STRING
401 Message-Id: MESSAGE-ID-STRING
402 X-Mailer: X-MAILER-STRING
404 Result: OK
405 EOF
407 test_expect_success '--suppress-cc=body' '
408         test_suppression body
411 cat >expected-suppress-body-cccmd <<\EOF
412 0001-Second.patch
413 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
414 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
415 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
416 Dry-OK. Log says:
417 Server: relay.example.com
418 MAIL FROM:<from@example.com>
419 RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>
420 From: Example <from@example.com>
421 To: to@example.com
422 Cc: A <author@example.com>, One <one@example.com>, two@example.com
423 Subject: [PATCH 1/1] Second.
424 Date: DATE-STRING
425 Message-Id: MESSAGE-ID-STRING
426 X-Mailer: X-MAILER-STRING
428 Result: OK
429 EOF
431 test_expect_success '--suppress-cc=body --suppress-cc=cccmd' '
432         test_suppression body cccmd
435 cat >expected-suppress-sob <<\EOF
436 0001-Second.patch
437 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
438 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
439 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
440 Dry-OK. Log says:
441 Server: relay.example.com
442 MAIL FROM:<from@example.com>
443 RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>
444 From: Example <from@example.com>
445 To: to@example.com
446 Cc: A <author@example.com>, One <one@example.com>, two@example.com
447 Subject: [PATCH 1/1] Second.
448 Date: DATE-STRING
449 Message-Id: MESSAGE-ID-STRING
450 X-Mailer: X-MAILER-STRING
452 Result: OK
453 EOF
455 test_expect_success '--suppress-cc=sob' '
456         git config --unset sendemail.cccmd
457         test_suppression sob
460 cat >expected-suppress-bodycc <<\EOF
461 0001-Second.patch
462 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
463 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
464 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
465 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
466 Dry-OK. Log says:
467 Server: relay.example.com
468 MAIL FROM:<from@example.com>
469 RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<committer@example.com>
470 From: Example <from@example.com>
471 To: to@example.com
472 Cc: A <author@example.com>, One <one@example.com>, two@example.com, C O Mitter <committer@example.com>
473 Subject: [PATCH 1/1] Second.
474 Date: DATE-STRING
475 Message-Id: MESSAGE-ID-STRING
476 X-Mailer: X-MAILER-STRING
478 Result: OK
479 EOF
481 test_expect_success '--suppress-cc=bodycc' '
482         test_suppression bodycc
485 cat >expected-suppress-cc <<\EOF
486 0001-Second.patch
487 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
488 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
489 Dry-OK. Log says:
490 Server: relay.example.com
491 MAIL FROM:<from@example.com>
492 RCPT TO:<to@example.com>,<author@example.com>,<committer@example.com>
493 From: Example <from@example.com>
494 To: to@example.com
495 Cc: A <author@example.com>, C O Mitter <committer@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
502 EOF
504 test_expect_success '--suppress-cc=cc' '
505         test_suppression cc
508 test_confirm () {
509         echo y | \
510                 GIT_SEND_EMAIL_NOTTY=1 \
511                 git send-email \
512                 --from="Example <nobody@example.com>" \
513                 --to=nobody@example.com \
514                 --smtp-server="$(pwd)/fake.sendmail" \
515                 $@ $patches > stdout &&
516         grep "Send this email" stdout
519 test_expect_success '--confirm=always' '
520         test_confirm --confirm=always --suppress-cc=all
523 test_expect_success '--confirm=auto' '
524         test_confirm --confirm=auto
527 test_expect_success '--confirm=cc' '
528         test_confirm --confirm=cc
531 test_expect_success '--confirm=compose' '
532         test_confirm --confirm=compose --compose
535 test_expect_success 'confirm by default (due to cc)' '
536         CONFIRM=$(git config --get sendemail.confirm) &&
537         git config --unset sendemail.confirm &&
538         test_confirm
539         ret="$?"
540         git config sendemail.confirm ${CONFIRM:-never}
541         test $ret = "0"
544 test_expect_success 'confirm by default (due to --compose)' '
545         CONFIRM=$(git config --get sendemail.confirm) &&
546         git config --unset sendemail.confirm &&
547         test_confirm --suppress-cc=all --compose
548         ret="$?"
549         git config sendemail.confirm ${CONFIRM:-never}
550         test $ret = "0"
553 test_expect_success 'confirm detects EOF (inform assumes y)' '
554         CONFIRM=$(git config --get sendemail.confirm) &&
555         git config --unset sendemail.confirm &&
556         rm -fr outdir &&
557         git format-patch -2 -o outdir &&
558         GIT_SEND_EMAIL_NOTTY=1 \
559                 git send-email \
560                         --from="Example <nobody@example.com>" \
561                         --to=nobody@example.com \
562                         --smtp-server="$(pwd)/fake.sendmail" \
563                         outdir/*.patch < /dev/null
564         ret="$?"
565         git config sendemail.confirm ${CONFIRM:-never}
566         test $ret = "0"
569 test_expect_success 'confirm detects EOF (auto causes failure)' '
570         CONFIRM=$(git config --get sendemail.confirm) &&
571         git config sendemail.confirm auto &&
572         GIT_SEND_EMAIL_NOTTY=1 &&
573         export GIT_SEND_EMAIL_NOTTY &&
574                 test_must_fail git send-email \
575                         --from="Example <nobody@example.com>" \
576                         --to=nobody@example.com \
577                         --smtp-server="$(pwd)/fake.sendmail" \
578                         $patches < /dev/null
579         ret="$?"
580         git config sendemail.confirm ${CONFIRM:-never}
581         test $ret = "0"
584 test_expect_success 'confirm doesnt loop forever' '
585         CONFIRM=$(git config --get sendemail.confirm) &&
586         git config sendemail.confirm auto &&
587         GIT_SEND_EMAIL_NOTTY=1 &&
588         export GIT_SEND_EMAIL_NOTTY &&
589                 yes "bogus" | test_must_fail git send-email \
590                         --from="Example <nobody@example.com>" \
591                         --to=nobody@example.com \
592                         --smtp-server="$(pwd)/fake.sendmail" \
593                         $patches
594         ret="$?"
595         git config sendemail.confirm ${CONFIRM:-never}
596         test $ret = "0"
599 test_expect_success 'utf8 Cc is rfc2047 encoded' '
600         clean_fake_sendmail &&
601         rm -fr outdir &&
602         git format-patch -1 -o outdir --cc="àéìöú <utf8@example.com>" &&
603         git send-email \
604         --from="Example <nobody@example.com>" \
605         --to=nobody@example.com \
606         --smtp-server="$(pwd)/fake.sendmail" \
607         outdir/*.patch &&
608         grep "^Cc:" msgtxt1 |
609         grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>"
612 test_expect_success '--compose adds MIME for utf8 body' '
613         clean_fake_sendmail &&
614         (echo "#!$SHELL_PATH" &&
615          echo "echo utf8 body: àéìöú >>\"\$1\""
616         ) >fake-editor-utf8 &&
617         chmod +x fake-editor-utf8 &&
618           GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
619           git send-email \
620           --compose --subject foo \
621           --from="Example <nobody@example.com>" \
622           --to=nobody@example.com \
623           --smtp-server="$(pwd)/fake.sendmail" \
624           $patches &&
625         grep "^utf8 body" msgtxt1 &&
626         grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
629 test_expect_success '--compose respects user mime type' '
630         clean_fake_sendmail &&
631         (echo "#!$SHELL_PATH" &&
632          echo "(echo MIME-Version: 1.0"
633          echo " echo Content-Type: text/plain\\; charset=iso-8859-1"
634          echo " echo Content-Transfer-Encoding: 8bit"
635          echo " echo Subject: foo"
636          echo " echo "
637          echo " echo utf8 body: àéìöú) >\"\$1\""
638         ) >fake-editor-utf8-mime &&
639         chmod +x fake-editor-utf8-mime &&
640           GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \
641           git send-email \
642           --compose --subject foo \
643           --from="Example <nobody@example.com>" \
644           --to=nobody@example.com \
645           --smtp-server="$(pwd)/fake.sendmail" \
646           $patches &&
647         grep "^utf8 body" msgtxt1 &&
648         grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 &&
649         ! grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
652 test_expect_success '--compose adds MIME for utf8 subject' '
653         clean_fake_sendmail &&
654           GIT_EDITOR="\"$(pwd)/fake-editor\"" \
655           git send-email \
656           --compose --subject utf8-sübjëct \
657           --from="Example <nobody@example.com>" \
658           --to=nobody@example.com \
659           --smtp-server="$(pwd)/fake.sendmail" \
660           $patches &&
661         grep "^fake edit" msgtxt1 &&
662         grep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
665 test_expect_success 'detects ambiguous reference/file conflict' '
666         echo master > master &&
667         git add master &&
668         git commit -m"add master" &&
669         test_must_fail git send-email --dry-run master 2>errors &&
670         grep disambiguate errors
673 test_expect_success 'feed two files' '
674         rm -fr outdir &&
675         git format-patch -2 -o outdir &&
676         git send-email \
677         --dry-run \
678         --from="Example <nobody@example.com>" \
679         --to=nobody@example.com \
680         outdir/000?-*.patch 2>errors >out &&
681         grep "^Subject: " out >subjects &&
682         test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." &&
683         test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add master"
686 test_expect_success 'in-reply-to but no threading' '
687         git send-email \
688                 --dry-run \
689                 --from="Example <nobody@example.com>" \
690                 --to=nobody@example.com \
691                 --in-reply-to="<in-reply-id@example.com>" \
692                 --nothread \
693                 $patches |
694         grep "In-Reply-To: <in-reply-id@example.com>"
697 test_expect_success 'no in-reply-to and no threading' '
698         git send-email \
699                 --dry-run \
700                 --from="Example <nobody@example.com>" \
701                 --to=nobody@example.com \
702                 --nothread \
703                 $patches $patches >stdout &&
704         ! grep "In-Reply-To: " stdout
707 test_expect_success 'threading but no chain-reply-to' '
708         git send-email \
709                 --dry-run \
710                 --from="Example <nobody@example.com>" \
711                 --to=nobody@example.com \
712                 --thread \
713                 --nochain-reply-to \
714                 $patches $patches >stdout &&
715         grep "In-Reply-To: " stdout
718 test_done