Code

t9001: test --envelope-sender option of send-email
[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 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!
110 EOF
111 test_expect_success \
112     'Verify commandline' \
113     'test_cmp expected commandline1'
115 cat >expected-show-all-headers <<\EOF
116 0001-Second.patch
117 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
118 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
119 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
120 Dry-OK. Log says:
121 Server: relay.example.com
122 MAIL FROM:<from@example.com>
123 RCPT TO:<to@example.com>,<cc@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<bcc@example.com>
124 From: Example <from@example.com>
125 To: to@example.com
126 Cc: cc@example.com, A <author@example.com>, One <one@example.com>, two@example.com
127 Subject: [PATCH 1/1] Second.
128 Date: DATE-STRING
129 Message-Id: MESSAGE-ID-STRING
130 X-Mailer: X-MAILER-STRING
131 In-Reply-To: <unique-message-id@example.com>
132 References: <unique-message-id@example.com>
134 Result: OK
135 EOF
137 test_expect_success 'Show all headers' '
138         git send-email \
139                 --dry-run \
140                 --suppress-cc=sob \
141                 --from="Example <from@example.com>" \
142                 --to=to@example.com \
143                 --cc=cc@example.com \
144                 --bcc=bcc@example.com \
145                 --in-reply-to="<unique-message-id@example.com>" \
146                 --smtp-server relay.example.com \
147                 $patches |
148         sed     -e "s/^\(Date:\).*/\1 DATE-STRING/" \
149                 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
150                 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
151                 >actual-show-all-headers &&
152         test_cmp expected-show-all-headers actual-show-all-headers
155 test_expect_success 'Prompting works' '
156         clean_fake_sendmail &&
157         (echo "Example <from@example.com>"
158          echo "to@example.com"
159          echo ""
160         ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
161                 --smtp-server="$(pwd)/fake.sendmail" \
162                 $patches \
163                 2>errors &&
164                 grep "^From: Example <from@example.com>$" msgtxt1 &&
165                 grep "^To: to@example.com$" msgtxt1
168 test_expect_success 'cccmd works' '
169         clean_fake_sendmail &&
170         cp $patches cccmd.patch &&
171         echo cccmd--cccmd@example.com >>cccmd.patch &&
172         {
173           echo "#!$SHELL_PATH"
174           echo sed -n -e s/^cccmd--//p \"\$1\"
175         } > cccmd-sed &&
176         chmod +x cccmd-sed &&
177         git send-email \
178                 --from="Example <nobody@example.com>" \
179                 --to=nobody@example.com \
180                 --cc-cmd=./cccmd-sed \
181                 --smtp-server="$(pwd)/fake.sendmail" \
182                 cccmd.patch \
183                 &&
184         grep ^Cc:.*cccmd@example.com msgtxt1
187 z8=zzzzzzzz
188 z64=$z8$z8$z8$z8$z8$z8$z8$z8
189 z512=$z64$z64$z64$z64$z64$z64$z64$z64
190 test_expect_success 'reject long lines' '
191         clean_fake_sendmail &&
192         cp $patches longline.patch &&
193         echo $z512$z512 >>longline.patch &&
194         test_must_fail git send-email \
195                 --from="Example <nobody@example.com>" \
196                 --to=nobody@example.com \
197                 --smtp-server="$(pwd)/fake.sendmail" \
198                 $patches longline.patch \
199                 2>errors &&
200         grep longline.patch errors
203 test_expect_success 'no patch was sent' '
204         ! test -e commandline1
207 test_expect_success 'Author From: in message body' '
208         clean_fake_sendmail &&
209         git send-email \
210                 --from="Example <nobody@example.com>" \
211                 --to=nobody@example.com \
212                 --smtp-server="$(pwd)/fake.sendmail" \
213                 $patches &&
214         sed "1,/^$/d" < msgtxt1 > msgbody1
215         grep "From: A <author@example.com>" msgbody1
218 test_expect_success 'Author From: not in message body' '
219         clean_fake_sendmail &&
220         git send-email \
221                 --from="A <author@example.com>" \
222                 --to=nobody@example.com \
223                 --smtp-server="$(pwd)/fake.sendmail" \
224                 $patches &&
225         sed "1,/^$/d" < msgtxt1 > msgbody1
226         ! grep "From: A <author@example.com>" msgbody1
229 test_expect_success 'allow long lines with --no-validate' '
230         git send-email \
231                 --from="Example <nobody@example.com>" \
232                 --to=nobody@example.com \
233                 --smtp-server="$(pwd)/fake.sendmail" \
234                 --novalidate \
235                 $patches longline.patch \
236                 2>errors
239 test_expect_success 'Invalid In-Reply-To' '
240         clean_fake_sendmail &&
241         git send-email \
242                 --from="Example <nobody@example.com>" \
243                 --to=nobody@example.com \
244                 --in-reply-to=" " \
245                 --smtp-server="$(pwd)/fake.sendmail" \
246                 $patches
247                 2>errors
248         ! grep "^In-Reply-To: < *>" msgtxt1
251 test_expect_success 'Valid In-Reply-To when prompting' '
252         clean_fake_sendmail &&
253         (echo "From Example <from@example.com>"
254          echo "To Example <to@example.com>"
255          echo ""
256         ) | env GIT_SEND_EMAIL_NOTTY=1 git send-email \
257                 --smtp-server="$(pwd)/fake.sendmail" \
258                 $patches 2>errors &&
259         ! grep "^In-Reply-To: < *>" msgtxt1
262 test_expect_success 'setup fake editor' '
263         (echo "#!$SHELL_PATH" &&
264          echo "echo fake edit >>\"\$1\""
265         ) >fake-editor &&
266         chmod +x fake-editor
269 test_set_editor "$(pwd)/fake-editor"
271 test_expect_success '--compose works' '
272         clean_fake_sendmail &&
273         git send-email \
274         --compose --subject foo \
275         --from="Example <nobody@example.com>" \
276         --to=nobody@example.com \
277         --smtp-server="$(pwd)/fake.sendmail" \
278         $patches \
279         2>errors
282 test_expect_success 'first message is compose text' '
283         grep "^fake edit" msgtxt1
286 test_expect_success 'second message is patch' '
287         grep "Subject:.*Second" msgtxt2
290 cat >expected-suppress-sob <<\EOF
291 0001-Second.patch
292 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
293 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
294 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
295 Dry-OK. Log says:
296 Server: relay.example.com
297 MAIL FROM:<from@example.com>
298 RCPT TO:<to@example.com>,<cc@example.com>,<author@example.com>,<one@example.com>,<two@example.com>
299 From: Example <from@example.com>
300 To: to@example.com
301 Cc: cc@example.com, A <author@example.com>, One <one@example.com>, two@example.com
302 Subject: [PATCH 1/1] Second.
303 Date: DATE-STRING
304 Message-Id: MESSAGE-ID-STRING
305 X-Mailer: X-MAILER-STRING
307 Result: OK
308 EOF
310 test_suppression () {
311         git send-email \
312                 --dry-run \
313                 --suppress-cc=$1 ${2+"--suppress-cc=$2"} \
314                 --from="Example <from@example.com>" \
315                 --to=to@example.com \
316                 --smtp-server relay.example.com \
317                 $patches |
318         sed     -e "s/^\(Date:\).*/\1 DATE-STRING/" \
319                 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
320                 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
321                 >actual-suppress-$1${2+"-$2"} &&
322         test_cmp expected-suppress-$1${2+"-$2"} actual-suppress-$1${2+"-$2"}
325 test_expect_success 'sendemail.cc set' '
326         git config sendemail.cc cc@example.com &&
327         test_suppression sob
330 cat >expected-suppress-sob <<\EOF
331 0001-Second.patch
332 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
333 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
334 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
335 Dry-OK. Log says:
336 Server: relay.example.com
337 MAIL FROM:<from@example.com>
338 RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>
339 From: Example <from@example.com>
340 To: to@example.com
341 Cc: A <author@example.com>, One <one@example.com>, two@example.com
342 Subject: [PATCH 1/1] Second.
343 Date: DATE-STRING
344 Message-Id: MESSAGE-ID-STRING
345 X-Mailer: X-MAILER-STRING
347 Result: OK
348 EOF
350 test_expect_success 'sendemail.cc unset' '
351         git config --unset sendemail.cc &&
352         test_suppression sob
355 cat >expected-suppress-cccmd <<\EOF
356 0001-Second.patch
357 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
358 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
359 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
360 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
361 Dry-OK. Log says:
362 Server: relay.example.com
363 MAIL FROM:<from@example.com>
364 RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<committer@example.com>
365 From: Example <from@example.com>
366 To: to@example.com
367 Cc: A <author@example.com>, One <one@example.com>, two@example.com, C O Mitter <committer@example.com>
368 Subject: [PATCH 1/1] Second.
369 Date: DATE-STRING
370 Message-Id: MESSAGE-ID-STRING
371 X-Mailer: X-MAILER-STRING
373 Result: OK
374 EOF
376 test_expect_success 'sendemail.cccmd' '
377         echo echo cc-cmd@example.com > cccmd &&
378         chmod +x cccmd &&
379         git config sendemail.cccmd ./cccmd &&
380         test_suppression cccmd
383 cat >expected-suppress-all <<\EOF
384 0001-Second.patch
385 Dry-OK. Log says:
386 Server: relay.example.com
387 MAIL FROM:<from@example.com>
388 RCPT TO:<to@example.com>
389 From: Example <from@example.com>
390 To: to@example.com
391 Subject: [PATCH 1/1] Second.
392 Date: DATE-STRING
393 Message-Id: MESSAGE-ID-STRING
394 X-Mailer: X-MAILER-STRING
396 Result: OK
397 EOF
399 test_expect_success '--suppress-cc=all' '
400         test_suppression all
403 cat >expected-suppress-body <<\EOF
404 0001-Second.patch
405 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
406 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
407 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
408 (cc-cmd) Adding cc: cc-cmd@example.com from: './cccmd'
409 Dry-OK. Log says:
410 Server: relay.example.com
411 MAIL FROM:<from@example.com>
412 RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<cc-cmd@example.com>
413 From: Example <from@example.com>
414 To: to@example.com
415 Cc: A <author@example.com>, One <one@example.com>, two@example.com, cc-cmd@example.com
416 Subject: [PATCH 1/1] Second.
417 Date: DATE-STRING
418 Message-Id: MESSAGE-ID-STRING
419 X-Mailer: X-MAILER-STRING
421 Result: OK
422 EOF
424 test_expect_success '--suppress-cc=body' '
425         test_suppression body
428 cat >expected-suppress-body-cccmd <<\EOF
429 0001-Second.patch
430 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
431 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
432 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
433 Dry-OK. Log says:
434 Server: relay.example.com
435 MAIL FROM:<from@example.com>
436 RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>
437 From: Example <from@example.com>
438 To: to@example.com
439 Cc: A <author@example.com>, One <one@example.com>, two@example.com
440 Subject: [PATCH 1/1] Second.
441 Date: DATE-STRING
442 Message-Id: MESSAGE-ID-STRING
443 X-Mailer: X-MAILER-STRING
445 Result: OK
446 EOF
448 test_expect_success '--suppress-cc=body --suppress-cc=cccmd' '
449         test_suppression body cccmd
452 cat >expected-suppress-sob <<\EOF
453 0001-Second.patch
454 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
455 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
456 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
457 Dry-OK. Log says:
458 Server: relay.example.com
459 MAIL FROM:<from@example.com>
460 RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>
461 From: Example <from@example.com>
462 To: to@example.com
463 Cc: A <author@example.com>, One <one@example.com>, two@example.com
464 Subject: [PATCH 1/1] Second.
465 Date: DATE-STRING
466 Message-Id: MESSAGE-ID-STRING
467 X-Mailer: X-MAILER-STRING
469 Result: OK
470 EOF
472 test_expect_success '--suppress-cc=sob' '
473         git config --unset sendemail.cccmd
474         test_suppression sob
477 cat >expected-suppress-bodycc <<\EOF
478 0001-Second.patch
479 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
480 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
481 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
482 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
483 Dry-OK. Log says:
484 Server: relay.example.com
485 MAIL FROM:<from@example.com>
486 RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<committer@example.com>
487 From: Example <from@example.com>
488 To: to@example.com
489 Cc: A <author@example.com>, One <one@example.com>, two@example.com, C O Mitter <committer@example.com>
490 Subject: [PATCH 1/1] Second.
491 Date: DATE-STRING
492 Message-Id: MESSAGE-ID-STRING
493 X-Mailer: X-MAILER-STRING
495 Result: OK
496 EOF
498 test_expect_success '--suppress-cc=bodycc' '
499         test_suppression bodycc
502 cat >expected-suppress-cc <<\EOF
503 0001-Second.patch
504 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
505 (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
506 Dry-OK. Log says:
507 Server: relay.example.com
508 MAIL FROM:<from@example.com>
509 RCPT TO:<to@example.com>,<author@example.com>,<committer@example.com>
510 From: Example <from@example.com>
511 To: to@example.com
512 Cc: A <author@example.com>, C O Mitter <committer@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
519 EOF
521 test_expect_success '--suppress-cc=cc' '
522         test_suppression cc
525 test_confirm () {
526         echo y | \
527                 GIT_SEND_EMAIL_NOTTY=1 \
528                 git send-email \
529                 --from="Example <nobody@example.com>" \
530                 --to=nobody@example.com \
531                 --smtp-server="$(pwd)/fake.sendmail" \
532                 $@ $patches > stdout &&
533         grep "Send this email" stdout
536 test_expect_success '--confirm=always' '
537         test_confirm --confirm=always --suppress-cc=all
540 test_expect_success '--confirm=auto' '
541         test_confirm --confirm=auto
544 test_expect_success '--confirm=cc' '
545         test_confirm --confirm=cc
548 test_expect_success '--confirm=compose' '
549         test_confirm --confirm=compose --compose
552 test_expect_success 'confirm by default (due to cc)' '
553         CONFIRM=$(git config --get sendemail.confirm) &&
554         git config --unset sendemail.confirm &&
555         test_confirm
556         ret="$?"
557         git config sendemail.confirm ${CONFIRM:-never}
558         test $ret = "0"
561 test_expect_success 'confirm by default (due to --compose)' '
562         CONFIRM=$(git config --get sendemail.confirm) &&
563         git config --unset sendemail.confirm &&
564         test_confirm --suppress-cc=all --compose
565         ret="$?"
566         git config sendemail.confirm ${CONFIRM:-never}
567         test $ret = "0"
570 test_expect_success 'confirm detects EOF (inform assumes y)' '
571         CONFIRM=$(git config --get sendemail.confirm) &&
572         git config --unset sendemail.confirm &&
573         rm -fr outdir &&
574         git format-patch -2 -o outdir &&
575         GIT_SEND_EMAIL_NOTTY=1 \
576                 git send-email \
577                         --from="Example <nobody@example.com>" \
578                         --to=nobody@example.com \
579                         --smtp-server="$(pwd)/fake.sendmail" \
580                         outdir/*.patch < /dev/null
581         ret="$?"
582         git config sendemail.confirm ${CONFIRM:-never}
583         test $ret = "0"
586 test_expect_success 'confirm detects EOF (auto causes failure)' '
587         CONFIRM=$(git config --get sendemail.confirm) &&
588         git config sendemail.confirm auto &&
589         GIT_SEND_EMAIL_NOTTY=1 &&
590         export GIT_SEND_EMAIL_NOTTY &&
591                 test_must_fail git send-email \
592                         --from="Example <nobody@example.com>" \
593                         --to=nobody@example.com \
594                         --smtp-server="$(pwd)/fake.sendmail" \
595                         $patches < /dev/null
596         ret="$?"
597         git config sendemail.confirm ${CONFIRM:-never}
598         test $ret = "0"
601 test_expect_success 'confirm doesnt loop forever' '
602         CONFIRM=$(git config --get sendemail.confirm) &&
603         git config sendemail.confirm auto &&
604         GIT_SEND_EMAIL_NOTTY=1 &&
605         export GIT_SEND_EMAIL_NOTTY &&
606                 yes "bogus" | test_must_fail git send-email \
607                         --from="Example <nobody@example.com>" \
608                         --to=nobody@example.com \
609                         --smtp-server="$(pwd)/fake.sendmail" \
610                         $patches
611         ret="$?"
612         git config sendemail.confirm ${CONFIRM:-never}
613         test $ret = "0"
616 test_expect_success 'utf8 Cc is rfc2047 encoded' '
617         clean_fake_sendmail &&
618         rm -fr outdir &&
619         git format-patch -1 -o outdir --cc="àéìöú <utf8@example.com>" &&
620         git send-email \
621         --from="Example <nobody@example.com>" \
622         --to=nobody@example.com \
623         --smtp-server="$(pwd)/fake.sendmail" \
624         outdir/*.patch &&
625         grep "^Cc:" msgtxt1 |
626         grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>"
629 test_expect_success '--compose adds MIME for utf8 body' '
630         clean_fake_sendmail &&
631         (echo "#!$SHELL_PATH" &&
632          echo "echo utf8 body: àéìöú >>\"\$1\""
633         ) >fake-editor-utf8 &&
634         chmod +x fake-editor-utf8 &&
635           GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
636           git send-email \
637           --compose --subject foo \
638           --from="Example <nobody@example.com>" \
639           --to=nobody@example.com \
640           --smtp-server="$(pwd)/fake.sendmail" \
641           $patches &&
642         grep "^utf8 body" msgtxt1 &&
643         grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
646 test_expect_success '--compose respects user mime type' '
647         clean_fake_sendmail &&
648         (echo "#!$SHELL_PATH" &&
649          echo "(echo MIME-Version: 1.0"
650          echo " echo Content-Type: text/plain\\; charset=iso-8859-1"
651          echo " echo Content-Transfer-Encoding: 8bit"
652          echo " echo Subject: foo"
653          echo " echo "
654          echo " echo utf8 body: àéìöú) >\"\$1\""
655         ) >fake-editor-utf8-mime &&
656         chmod +x fake-editor-utf8-mime &&
657           GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \
658           git send-email \
659           --compose --subject foo \
660           --from="Example <nobody@example.com>" \
661           --to=nobody@example.com \
662           --smtp-server="$(pwd)/fake.sendmail" \
663           $patches &&
664         grep "^utf8 body" msgtxt1 &&
665         grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 &&
666         ! grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
669 test_expect_success '--compose adds MIME for utf8 subject' '
670         clean_fake_sendmail &&
671           GIT_EDITOR="\"$(pwd)/fake-editor\"" \
672           git send-email \
673           --compose --subject utf8-sübjëct \
674           --from="Example <nobody@example.com>" \
675           --to=nobody@example.com \
676           --smtp-server="$(pwd)/fake.sendmail" \
677           $patches &&
678         grep "^fake edit" msgtxt1 &&
679         grep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
682 test_expect_success 'detects ambiguous reference/file conflict' '
683         echo master > master &&
684         git add master &&
685         git commit -m"add master" &&
686         test_must_fail git send-email --dry-run master 2>errors &&
687         grep disambiguate errors
690 test_expect_success 'feed two files' '
691         rm -fr outdir &&
692         git format-patch -2 -o outdir &&
693         git send-email \
694         --dry-run \
695         --from="Example <nobody@example.com>" \
696         --to=nobody@example.com \
697         outdir/000?-*.patch 2>errors >out &&
698         grep "^Subject: " out >subjects &&
699         test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." &&
700         test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add master"
703 test_expect_success 'in-reply-to but no threading' '
704         git send-email \
705                 --dry-run \
706                 --from="Example <nobody@example.com>" \
707                 --to=nobody@example.com \
708                 --in-reply-to="<in-reply-id@example.com>" \
709                 --nothread \
710                 $patches |
711         grep "In-Reply-To: <in-reply-id@example.com>"
714 test_expect_success 'no in-reply-to and no threading' '
715         git send-email \
716                 --dry-run \
717                 --from="Example <nobody@example.com>" \
718                 --to=nobody@example.com \
719                 --nothread \
720                 $patches $patches >stdout &&
721         ! grep "In-Reply-To: " stdout
724 test_expect_success 'threading but no chain-reply-to' '
725         git send-email \
726                 --dry-run \
727                 --from="Example <nobody@example.com>" \
728                 --to=nobody@example.com \
729                 --thread \
730                 --nochain-reply-to \
731                 $patches $patches >stdout &&
732         grep "In-Reply-To: " stdout
735 test_done