1#!/bin/sh
2
3test_description='git send-email'
4. ./test-lib.sh
5
6if ! test_have_prereq PERL; then
7 say 'skipping git send-email tests, perl not available'
8 test_done
9fi
10
11PROG='git send-email'
12test_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."'
18
19test_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."'
34
35clean_fake_sendmail() {
36 rm -f commandline* msgtxt*
37}
38
39test_expect_success 'Extract patches' '
40 patches=`git format-patch -s --cc="One <one@example.com>" --cc=two@example.com -n HEAD^1`
41'
42
43# Test no confirm early to ensure remaining tests will not hang
44test_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}
57
58# Exit immediately to prevent hang if a no-confirm test fails
59check_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}
65
66test_expect_success 'No confirm with --suppress-cc' '
67 test_no_confirm --suppress-cc=sob
68'
69check_no_confirm
70
71test_expect_success 'No confirm with --confirm=never' '
72 test_no_confirm --confirm=never
73'
74check_no_confirm
75
76# leave sendemail.confirm set to never after this so that none of the
77# remaining tests prompt unintentionally.
78test_expect_success 'No confirm with sendemail.confirm=never' '
79 git config sendemail.confirm never &&
80 test_no_confirm --compose --subject=foo
81'
82check_no_confirm
83
84test_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'
87
88cat >expected <<\EOF
89!nobody@example.com!
90!author@example.com!
91!one@example.com!
92!two@example.com!
93EOF
94test_expect_success \
95 'Verify commandline' \
96 'test_cmp expected commandline1'
97
98cat >expected-show-all-headers <<\EOF
990001-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'
103Dry-OK. Log says:
104Server: relay.example.com
105MAIL FROM:<from@example.com>
106RCPT TO:<to@example.com>,<cc@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<bcc@example.com>
107From: Example <from@example.com>
108To: to@example.com
109Cc: cc@example.com, A <author@example.com>, One <one@example.com>, two@example.com
110Subject: [PATCH 1/1] Second.
111Date: DATE-STRING
112Message-Id: MESSAGE-ID-STRING
113X-Mailer: X-MAILER-STRING
114In-Reply-To: <unique-message-id@example.com>
115References: <unique-message-id@example.com>
116
117Result: OK
118EOF
119
120test_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
136'
137
138test_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
149'
150
151test_expect_success 'cccmd works' '
152 clean_fake_sendmail &&
153 cp $patches cccmd.patch &&
154 echo cccmd--cccmd@example.com >>cccmd.patch &&
155 echo sed -n s/^cccmd--//p \"\$1\" > cccmd-sed &&
156 chmod +x cccmd-sed &&
157 git send-email \
158 --from="Example <nobody@example.com>" \
159 --to=nobody@example.com \
160 --cc-cmd=./cccmd-sed \
161 --smtp-server="$(pwd)/fake.sendmail" \
162 cccmd.patch \
163 &&
164 grep ^Cc:.*cccmd@example.com msgtxt1
165'
166
167z8=zzzzzzzz
168z64=$z8$z8$z8$z8$z8$z8$z8$z8
169z512=$z64$z64$z64$z64$z64$z64$z64$z64
170test_expect_success 'reject long lines' '
171 clean_fake_sendmail &&
172 cp $patches longline.patch &&
173 echo $z512$z512 >>longline.patch &&
174 test_must_fail git send-email \
175 --from="Example <nobody@example.com>" \
176 --to=nobody@example.com \
177 --smtp-server="$(pwd)/fake.sendmail" \
178 $patches longline.patch \
179 2>errors &&
180 grep longline.patch errors
181'
182
183test_expect_success 'no patch was sent' '
184 ! test -e commandline1
185'
186
187test_expect_success 'Author From: in message body' '
188 clean_fake_sendmail &&
189 git send-email \
190 --from="Example <nobody@example.com>" \
191 --to=nobody@example.com \
192 --smtp-server="$(pwd)/fake.sendmail" \
193 $patches &&
194 sed "1,/^$/d" < msgtxt1 > msgbody1
195 grep "From: A <author@example.com>" msgbody1
196'
197
198test_expect_success 'Author From: not in message body' '
199 clean_fake_sendmail &&
200 git send-email \
201 --from="A <author@example.com>" \
202 --to=nobody@example.com \
203 --smtp-server="$(pwd)/fake.sendmail" \
204 $patches &&
205 sed "1,/^$/d" < msgtxt1 > msgbody1
206 ! grep "From: A <author@example.com>" msgbody1
207'
208
209test_expect_success 'allow long lines with --no-validate' '
210 git send-email \
211 --from="Example <nobody@example.com>" \
212 --to=nobody@example.com \
213 --smtp-server="$(pwd)/fake.sendmail" \
214 --novalidate \
215 $patches longline.patch \
216 2>errors
217'
218
219test_expect_success 'Invalid In-Reply-To' '
220 clean_fake_sendmail &&
221 git send-email \
222 --from="Example <nobody@example.com>" \
223 --to=nobody@example.com \
224 --in-reply-to=" " \
225 --smtp-server="$(pwd)/fake.sendmail" \
226 $patches
227 2>errors
228 ! grep "^In-Reply-To: < *>" msgtxt1
229'
230
231test_expect_success 'Valid In-Reply-To when prompting' '
232 clean_fake_sendmail &&
233 (echo "From Example <from@example.com>"
234 echo "To Example <to@example.com>"
235 echo ""
236 ) | env GIT_SEND_EMAIL_NOTTY=1 git send-email \
237 --smtp-server="$(pwd)/fake.sendmail" \
238 $patches 2>errors &&
239 ! grep "^In-Reply-To: < *>" msgtxt1
240'
241
242test_expect_success 'setup fake editor' '
243 (echo "#!$SHELL_PATH" &&
244 echo "echo fake edit >>\"\$1\""
245 ) >fake-editor &&
246 chmod +x fake-editor
247'
248
249test_set_editor "$(pwd)/fake-editor"
250
251test_expect_success '--compose works' '
252 clean_fake_sendmail &&
253 git send-email \
254 --compose --subject foo \
255 --from="Example <nobody@example.com>" \
256 --to=nobody@example.com \
257 --smtp-server="$(pwd)/fake.sendmail" \
258 $patches \
259 2>errors
260'
261
262test_expect_success 'first message is compose text' '
263 grep "^fake edit" msgtxt1
264'
265
266test_expect_success 'second message is patch' '
267 grep "Subject:.*Second" msgtxt2
268'
269
270cat >expected-suppress-sob <<\EOF
2710001-Second.patch
272(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
273(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
274(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
275Dry-OK. Log says:
276Server: relay.example.com
277MAIL FROM:<from@example.com>
278RCPT TO:<to@example.com>,<cc@example.com>,<author@example.com>,<one@example.com>,<two@example.com>
279From: Example <from@example.com>
280To: to@example.com
281Cc: cc@example.com, A <author@example.com>, One <one@example.com>, two@example.com
282Subject: [PATCH 1/1] Second.
283Date: DATE-STRING
284Message-Id: MESSAGE-ID-STRING
285X-Mailer: X-MAILER-STRING
286
287Result: OK
288EOF
289
290test_suppression () {
291 git send-email \
292 --dry-run \
293 --suppress-cc=$1 ${2+"--suppress-cc=$2"} \
294 --from="Example <from@example.com>" \
295 --to=to@example.com \
296 --smtp-server relay.example.com \
297 $patches |
298 sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
299 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
300 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
301 >actual-suppress-$1${2+"-$2"} &&
302 test_cmp expected-suppress-$1${2+"-$2"} actual-suppress-$1${2+"-$2"}
303}
304
305test_expect_success 'sendemail.cc set' '
306 git config sendemail.cc cc@example.com &&
307 test_suppression sob
308'
309
310cat >expected-suppress-sob <<\EOF
3110001-Second.patch
312(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
313(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
314(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
315Dry-OK. Log says:
316Server: relay.example.com
317MAIL FROM:<from@example.com>
318RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>
319From: Example <from@example.com>
320To: to@example.com
321Cc: A <author@example.com>, One <one@example.com>, two@example.com
322Subject: [PATCH 1/1] Second.
323Date: DATE-STRING
324Message-Id: MESSAGE-ID-STRING
325X-Mailer: X-MAILER-STRING
326
327Result: OK
328EOF
329
330test_expect_success 'sendemail.cc unset' '
331 git config --unset sendemail.cc &&
332 test_suppression sob
333'
334
335cat >expected-suppress-cccmd <<\EOF
3360001-Second.patch
337(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
338(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
339(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
340(body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
341Dry-OK. Log says:
342Server: relay.example.com
343MAIL FROM:<from@example.com>
344RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<committer@example.com>
345From: Example <from@example.com>
346To: to@example.com
347Cc: A <author@example.com>, One <one@example.com>, two@example.com, C O Mitter <committer@example.com>
348Subject: [PATCH 1/1] Second.
349Date: DATE-STRING
350Message-Id: MESSAGE-ID-STRING
351X-Mailer: X-MAILER-STRING
352
353Result: OK
354EOF
355
356test_expect_success 'sendemail.cccmd' '
357 echo echo cc-cmd@example.com > cccmd &&
358 chmod +x cccmd &&
359 git config sendemail.cccmd ./cccmd &&
360 test_suppression cccmd
361'
362
363cat >expected-suppress-all <<\EOF
3640001-Second.patch
365Dry-OK. Log says:
366Server: relay.example.com
367MAIL FROM:<from@example.com>
368RCPT TO:<to@example.com>
369From: Example <from@example.com>
370To: to@example.com
371Subject: [PATCH 1/1] Second.
372Date: DATE-STRING
373Message-Id: MESSAGE-ID-STRING
374X-Mailer: X-MAILER-STRING
375
376Result: OK
377EOF
378
379test_expect_success '--suppress-cc=all' '
380 test_suppression all
381'
382
383cat >expected-suppress-body <<\EOF
3840001-Second.patch
385(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
386(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
387(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
388(cc-cmd) Adding cc: cc-cmd@example.com from: './cccmd'
389Dry-OK. Log says:
390Server: relay.example.com
391MAIL FROM:<from@example.com>
392RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<cc-cmd@example.com>
393From: Example <from@example.com>
394To: to@example.com
395Cc: A <author@example.com>, One <one@example.com>, two@example.com, cc-cmd@example.com
396Subject: [PATCH 1/1] Second.
397Date: DATE-STRING
398Message-Id: MESSAGE-ID-STRING
399X-Mailer: X-MAILER-STRING
400
401Result: OK
402EOF
403
404test_expect_success '--suppress-cc=body' '
405 test_suppression body
406'
407
408cat >expected-suppress-body-cccmd <<\EOF
4090001-Second.patch
410(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
411(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
412(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
413Dry-OK. Log says:
414Server: relay.example.com
415MAIL FROM:<from@example.com>
416RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>
417From: Example <from@example.com>
418To: to@example.com
419Cc: A <author@example.com>, One <one@example.com>, two@example.com
420Subject: [PATCH 1/1] Second.
421Date: DATE-STRING
422Message-Id: MESSAGE-ID-STRING
423X-Mailer: X-MAILER-STRING
424
425Result: OK
426EOF
427
428test_expect_success '--suppress-cc=body --suppress-cc=cccmd' '
429 test_suppression body cccmd
430'
431
432cat >expected-suppress-sob <<\EOF
4330001-Second.patch
434(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
435(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
436(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
437Dry-OK. Log says:
438Server: relay.example.com
439MAIL FROM:<from@example.com>
440RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>
441From: Example <from@example.com>
442To: to@example.com
443Cc: A <author@example.com>, One <one@example.com>, two@example.com
444Subject: [PATCH 1/1] Second.
445Date: DATE-STRING
446Message-Id: MESSAGE-ID-STRING
447X-Mailer: X-MAILER-STRING
448
449Result: OK
450EOF
451
452test_expect_success '--suppress-cc=sob' '
453 git config --unset sendemail.cccmd
454 test_suppression sob
455'
456
457cat >expected-suppress-bodycc <<\EOF
4580001-Second.patch
459(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
460(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
461(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
462(body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
463Dry-OK. Log says:
464Server: relay.example.com
465MAIL FROM:<from@example.com>
466RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<committer@example.com>
467From: Example <from@example.com>
468To: to@example.com
469Cc: A <author@example.com>, One <one@example.com>, two@example.com, C O Mitter <committer@example.com>
470Subject: [PATCH 1/1] Second.
471Date: DATE-STRING
472Message-Id: MESSAGE-ID-STRING
473X-Mailer: X-MAILER-STRING
474
475Result: OK
476EOF
477
478test_expect_success '--suppress-cc=bodycc' '
479 test_suppression bodycc
480'
481
482cat >expected-suppress-cc <<\EOF
4830001-Second.patch
484(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
485(body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
486Dry-OK. Log says:
487Server: relay.example.com
488MAIL FROM:<from@example.com>
489RCPT TO:<to@example.com>,<author@example.com>,<committer@example.com>
490From: Example <from@example.com>
491To: to@example.com
492Cc: A <author@example.com>, C O Mitter <committer@example.com>
493Subject: [PATCH 1/1] Second.
494Date: DATE-STRING
495Message-Id: MESSAGE-ID-STRING
496X-Mailer: X-MAILER-STRING
497
498Result: OK
499EOF
500
501test_expect_success '--suppress-cc=cc' '
502 test_suppression cc
503'
504
505test_confirm () {
506 echo y | \
507 GIT_SEND_EMAIL_NOTTY=1 \
508 git send-email \
509 --from="Example <nobody@example.com>" \
510 --to=nobody@example.com \
511 --smtp-server="$(pwd)/fake.sendmail" \
512 $@ $patches > stdout &&
513 grep "Send this email" stdout
514}
515
516test_expect_success '--confirm=always' '
517 test_confirm --confirm=always --suppress-cc=all
518'
519
520test_expect_success '--confirm=auto' '
521 test_confirm --confirm=auto
522'
523
524test_expect_success '--confirm=cc' '
525 test_confirm --confirm=cc
526'
527
528test_expect_success '--confirm=compose' '
529 test_confirm --confirm=compose --compose
530'
531
532test_expect_success 'confirm by default (due to cc)' '
533 CONFIRM=$(git config --get sendemail.confirm) &&
534 git config --unset sendemail.confirm &&
535 test_confirm
536 ret="$?"
537 git config sendemail.confirm ${CONFIRM:-never}
538 test $ret = "0"
539'
540
541test_expect_success 'confirm by default (due to --compose)' '
542 CONFIRM=$(git config --get sendemail.confirm) &&
543 git config --unset sendemail.confirm &&
544 test_confirm --suppress-cc=all --compose
545 ret="$?"
546 git config sendemail.confirm ${CONFIRM:-never}
547 test $ret = "0"
548'
549
550test_expect_success 'confirm detects EOF (inform assumes y)' '
551 CONFIRM=$(git config --get sendemail.confirm) &&
552 git config --unset sendemail.confirm &&
553 rm -fr outdir &&
554 git format-patch -2 -o outdir &&
555 GIT_SEND_EMAIL_NOTTY=1 \
556 git send-email \
557 --from="Example <nobody@example.com>" \
558 --to=nobody@example.com \
559 --smtp-server="$(pwd)/fake.sendmail" \
560 outdir/*.patch < /dev/null
561 ret="$?"
562 git config sendemail.confirm ${CONFIRM:-never}
563 test $ret = "0"
564'
565
566test_expect_success 'confirm detects EOF (auto causes failure)' '
567 CONFIRM=$(git config --get sendemail.confirm) &&
568 git config sendemail.confirm auto &&
569 GIT_SEND_EMAIL_NOTTY=1 &&
570 export GIT_SEND_EMAIL_NOTTY &&
571 test_must_fail git send-email \
572 --from="Example <nobody@example.com>" \
573 --to=nobody@example.com \
574 --smtp-server="$(pwd)/fake.sendmail" \
575 $patches < /dev/null
576 ret="$?"
577 git config sendemail.confirm ${CONFIRM:-never}
578 test $ret = "0"
579'
580
581test_expect_success 'confirm doesnt loop forever' '
582 CONFIRM=$(git config --get sendemail.confirm) &&
583 git config sendemail.confirm auto &&
584 GIT_SEND_EMAIL_NOTTY=1 &&
585 export GIT_SEND_EMAIL_NOTTY &&
586 yes "bogus" | test_must_fail git send-email \
587 --from="Example <nobody@example.com>" \
588 --to=nobody@example.com \
589 --smtp-server="$(pwd)/fake.sendmail" \
590 $patches
591 ret="$?"
592 git config sendemail.confirm ${CONFIRM:-never}
593 test $ret = "0"
594'
595
596test_expect_success 'utf8 Cc is rfc2047 encoded' '
597 clean_fake_sendmail &&
598 rm -fr outdir &&
599 git format-patch -1 -o outdir --cc="àéìöú <utf8@example.com>" &&
600 git send-email \
601 --from="Example <nobody@example.com>" \
602 --to=nobody@example.com \
603 --smtp-server="$(pwd)/fake.sendmail" \
604 outdir/*.patch &&
605 grep "^Cc:" msgtxt1 |
606 grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>"
607'
608
609test_expect_success '--compose adds MIME for utf8 body' '
610 clean_fake_sendmail &&
611 (echo "#!$SHELL_PATH" &&
612 echo "echo utf8 body: àéìöú >>\"\$1\""
613 ) >fake-editor-utf8 &&
614 chmod +x fake-editor-utf8 &&
615 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
616 git send-email \
617 --compose --subject foo \
618 --from="Example <nobody@example.com>" \
619 --to=nobody@example.com \
620 --smtp-server="$(pwd)/fake.sendmail" \
621 $patches &&
622 grep "^utf8 body" msgtxt1 &&
623 grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
624'
625
626test_expect_success '--compose respects user mime type' '
627 clean_fake_sendmail &&
628 (echo "#!$SHELL_PATH" &&
629 echo "(echo MIME-Version: 1.0"
630 echo " echo Content-Type: text/plain\\; charset=iso-8859-1"
631 echo " echo Content-Transfer-Encoding: 8bit"
632 echo " echo Subject: foo"
633 echo " echo "
634 echo " echo utf8 body: àéìöú) >\"\$1\""
635 ) >fake-editor-utf8-mime &&
636 chmod +x fake-editor-utf8-mime &&
637 GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \
638 git send-email \
639 --compose --subject foo \
640 --from="Example <nobody@example.com>" \
641 --to=nobody@example.com \
642 --smtp-server="$(pwd)/fake.sendmail" \
643 $patches &&
644 grep "^utf8 body" msgtxt1 &&
645 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 &&
646 ! grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
647'
648
649test_expect_success '--compose adds MIME for utf8 subject' '
650 clean_fake_sendmail &&
651 GIT_EDITOR="\"$(pwd)/fake-editor\"" \
652 git send-email \
653 --compose --subject utf8-sübjëct \
654 --from="Example <nobody@example.com>" \
655 --to=nobody@example.com \
656 --smtp-server="$(pwd)/fake.sendmail" \
657 $patches &&
658 grep "^fake edit" msgtxt1 &&
659 grep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
660'
661
662test_expect_success 'detects ambiguous reference/file conflict' '
663 echo master > master &&
664 git add master &&
665 git commit -m"add master" &&
666 test_must_fail git send-email --dry-run master 2>errors &&
667 grep disambiguate errors
668'
669
670test_expect_success 'feed two files' '
671 rm -fr outdir &&
672 git format-patch -2 -o outdir &&
673 git send-email \
674 --dry-run \
675 --from="Example <nobody@example.com>" \
676 --to=nobody@example.com \
677 outdir/000?-*.patch 2>errors >out &&
678 grep "^Subject: " out >subjects &&
679 test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." &&
680 test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add master"
681'
682
683test_expect_success 'in-reply-to but no threading' '
684 git send-email \
685 --dry-run \
686 --from="Example <nobody@example.com>" \
687 --to=nobody@example.com \
688 --in-reply-to="<in-reply-id@example.com>" \
689 --nothread \
690 $patches |
691 grep "In-Reply-To: <in-reply-id@example.com>"
692'
693
694test_expect_success 'no in-reply-to and no threading' '
695 git send-email \
696 --dry-run \
697 --from="Example <nobody@example.com>" \
698 --to=nobody@example.com \
699 --nothread \
700 $patches $patches >stdout &&
701 ! grep "In-Reply-To: " stdout
702'
703
704test_expect_success 'threading but no chain-reply-to' '
705 git send-email \
706 --dry-run \
707 --from="Example <nobody@example.com>" \
708 --to=nobody@example.com \
709 --thread \
710 --nochain-reply-to \
711 $patches $patches >stdout &&
712 grep "In-Reply-To: " stdout
713'
714
715test_done