c5d66cf3869384a60db876caab3ba1b06ee32ce2
1#!/bin/sh
2
3test_description='git send-email'
4. ./test-lib.sh
5
6# May be altered later in the test
7PREREQ="PERL"
8
9test_expect_success $PREREQ \
10 'prepare reference tree' \
11 'echo "1A quick brown fox jumps over the" >file &&
12 echo "lazy dog" >>file &&
13 git add file &&
14 GIT_AUTHOR_NAME="A" git commit -a -m "Initial."'
15
16test_expect_success $PREREQ \
17 'Setup helper tool' \
18 '(echo "#!$SHELL_PATH"
19 echo shift
20 echo output=1
21 echo "while test -f commandline\$output; do output=\$((\$output+1)); done"
22 echo for a
23 echo do
24 echo " echo \"!\$a!\""
25 echo "done >commandline\$output"
26 test_have_prereq MINGW && echo "dos2unix commandline\$output"
27 echo "cat > msgtxt\$output"
28 ) >fake.sendmail &&
29 chmod +x ./fake.sendmail &&
30 git add fake.sendmail &&
31 GIT_AUTHOR_NAME="A" git commit -a -m "Second."'
32
33clean_fake_sendmail() {
34 rm -f commandline* msgtxt*
35}
36
37test_expect_success $PREREQ 'Extract patches' '
38 patches=`git format-patch -s --cc="One <one@example.com>" --cc=two@example.com -n HEAD^1`
39'
40
41# Test no confirm early to ensure remaining tests will not hang
42test_no_confirm () {
43 rm -f no_confirm_okay
44 echo n | \
45 GIT_SEND_EMAIL_NOTTY=1 \
46 git send-email \
47 --from="Example <from@example.com>" \
48 --to=nobody@example.com \
49 --smtp-server="$(pwd)/fake.sendmail" \
50 $@ \
51 $patches > stdout &&
52 test_must_fail grep "Send this email" stdout &&
53 > no_confirm_okay
54}
55
56# Exit immediately to prevent hang if a no-confirm test fails
57check_no_confirm () {
58 if ! test -f no_confirm_okay
59 then
60 say 'confirm test failed; skipping remaining tests to prevent hanging'
61 PREREQ="$PREREQ,CHECK_NO_CONFIRM"
62 fi
63 return 0
64}
65
66test_expect_success $PREREQ 'No confirm with --suppress-cc' '
67 test_no_confirm --suppress-cc=sob &&
68 check_no_confirm
69'
70
71
72test_expect_success $PREREQ 'No confirm with --confirm=never' '
73 test_no_confirm --confirm=never &&
74 check_no_confirm
75'
76
77# leave sendemail.confirm set to never after this so that none of the
78# remaining tests prompt unintentionally.
79test_expect_success $PREREQ 'No confirm with sendemail.confirm=never' '
80 git config sendemail.confirm never &&
81 test_no_confirm --compose --subject=foo &&
82 check_no_confirm
83'
84
85test_expect_success $PREREQ 'Send patches' '
86 git send-email --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors
87'
88
89test_expect_success $PREREQ 'setup expect' '
90cat >expected <<\EOF
91!nobody@example.com!
92!author@example.com!
93!one@example.com!
94!two@example.com!
95EOF
96'
97
98test_expect_success $PREREQ \
99 'Verify commandline' \
100 'test_cmp expected commandline1'
101
102test_expect_success $PREREQ 'Send patches with --envelope-sender' '
103 clean_fake_sendmail &&
104 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
105'
106
107test_expect_success $PREREQ 'setup expect' '
108cat >expected <<\EOF
109!patch@example.com!
110!-i!
111!nobody@example.com!
112!author@example.com!
113!one@example.com!
114!two@example.com!
115EOF
116'
117
118test_expect_success $PREREQ \
119 'Verify commandline' \
120 'test_cmp expected commandline1'
121
122test_expect_success $PREREQ 'Send patches with --envelope-sender=auto' '
123 clean_fake_sendmail &&
124 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
125'
126
127test_expect_success $PREREQ 'setup expect' '
128cat >expected <<\EOF
129!nobody@example.com!
130!-i!
131!nobody@example.com!
132!author@example.com!
133!one@example.com!
134!two@example.com!
135EOF
136'
137
138test_expect_success $PREREQ \
139 'Verify commandline' \
140 'test_cmp expected commandline1'
141
142test_expect_success $PREREQ 'setup expect' "
143cat >expected-show-all-headers <<\EOF
1440001-Second.patch
145(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
146(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
147(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
148Dry-OK. Log says:
149Server: relay.example.com
150MAIL FROM:<from@example.com>
151RCPT TO:<to@example.com>
152RCPT TO:<cc@example.com>
153RCPT TO:<author@example.com>
154RCPT TO:<one@example.com>
155RCPT TO:<two@example.com>
156RCPT TO:<bcc@example.com>
157From: Example <from@example.com>
158To: to@example.com
159Cc: cc@example.com,
160 A <author@example.com>,
161 One <one@example.com>,
162 two@example.com
163Subject: [PATCH 1/1] Second.
164Date: DATE-STRING
165Message-Id: MESSAGE-ID-STRING
166X-Mailer: X-MAILER-STRING
167In-Reply-To: <unique-message-id@example.com>
168References: <unique-message-id@example.com>
169
170Result: OK
171EOF
172"
173
174test_expect_success $PREREQ 'Show all headers' '
175 git send-email \
176 --dry-run \
177 --suppress-cc=sob \
178 --from="Example <from@example.com>" \
179 --to=to@example.com \
180 --cc=cc@example.com \
181 --bcc=bcc@example.com \
182 --in-reply-to="<unique-message-id@example.com>" \
183 --smtp-server relay.example.com \
184 $patches |
185 sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
186 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
187 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
188 >actual-show-all-headers &&
189 test_cmp expected-show-all-headers actual-show-all-headers
190'
191
192test_expect_success $PREREQ 'Prompting works' '
193 clean_fake_sendmail &&
194 (echo "to@example.com"
195 echo ""
196 ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
197 --smtp-server="$(pwd)/fake.sendmail" \
198 $patches \
199 2>errors &&
200 grep "^From: A U Thor <author@example.com>\$" msgtxt1 &&
201 grep "^To: to@example.com\$" msgtxt1
202'
203
204test_expect_success $PREREQ 'tocmd works' '
205 clean_fake_sendmail &&
206 cp $patches tocmd.patch &&
207 echo tocmd--tocmd@example.com >>tocmd.patch &&
208 {
209 echo "#!$SHELL_PATH"
210 echo sed -n -e s/^tocmd--//p \"\$1\"
211 } > tocmd-sed &&
212 chmod +x tocmd-sed &&
213 git send-email \
214 --from="Example <nobody@example.com>" \
215 --to-cmd=./tocmd-sed \
216 --smtp-server="$(pwd)/fake.sendmail" \
217 tocmd.patch \
218 &&
219 grep "^To: tocmd@example.com" msgtxt1
220'
221
222test_expect_success $PREREQ 'cccmd works' '
223 clean_fake_sendmail &&
224 cp $patches cccmd.patch &&
225 echo "cccmd-- cccmd@example.com" >>cccmd.patch &&
226 {
227 echo "#!$SHELL_PATH"
228 echo sed -n -e s/^cccmd--//p \"\$1\"
229 } > cccmd-sed &&
230 chmod +x cccmd-sed &&
231 git send-email \
232 --from="Example <nobody@example.com>" \
233 --to=nobody@example.com \
234 --cc-cmd=./cccmd-sed \
235 --smtp-server="$(pwd)/fake.sendmail" \
236 cccmd.patch \
237 &&
238 grep "^ cccmd@example.com" msgtxt1
239'
240
241test_expect_success $PREREQ 'reject long lines' '
242 z8=zzzzzzzz &&
243 z64=$z8$z8$z8$z8$z8$z8$z8$z8 &&
244 z512=$z64$z64$z64$z64$z64$z64$z64$z64 &&
245 clean_fake_sendmail &&
246 cp $patches longline.patch &&
247 echo $z512$z512 >>longline.patch &&
248 test_must_fail git send-email \
249 --from="Example <nobody@example.com>" \
250 --to=nobody@example.com \
251 --smtp-server="$(pwd)/fake.sendmail" \
252 $patches longline.patch \
253 2>errors &&
254 grep longline.patch errors
255'
256
257test_expect_success $PREREQ 'no patch was sent' '
258 ! test -e commandline1
259'
260
261test_expect_success $PREREQ 'Author From: in message body' '
262 clean_fake_sendmail &&
263 git send-email \
264 --from="Example <nobody@example.com>" \
265 --to=nobody@example.com \
266 --smtp-server="$(pwd)/fake.sendmail" \
267 $patches &&
268 sed "1,/^\$/d" < msgtxt1 > msgbody1 &&
269 grep "From: A <author@example.com>" msgbody1
270'
271
272test_expect_success $PREREQ 'Author From: not in message body' '
273 clean_fake_sendmail &&
274 git send-email \
275 --from="A <author@example.com>" \
276 --to=nobody@example.com \
277 --smtp-server="$(pwd)/fake.sendmail" \
278 $patches &&
279 sed "1,/^\$/d" < msgtxt1 > msgbody1 &&
280 ! grep "From: A <author@example.com>" msgbody1
281'
282
283test_expect_success $PREREQ 'allow long lines with --no-validate' '
284 git send-email \
285 --from="Example <nobody@example.com>" \
286 --to=nobody@example.com \
287 --smtp-server="$(pwd)/fake.sendmail" \
288 --novalidate \
289 $patches longline.patch \
290 2>errors
291'
292
293test_expect_success $PREREQ 'Invalid In-Reply-To' '
294 clean_fake_sendmail &&
295 git send-email \
296 --from="Example <nobody@example.com>" \
297 --to=nobody@example.com \
298 --in-reply-to=" " \
299 --smtp-server="$(pwd)/fake.sendmail" \
300 $patches \
301 2>errors &&
302 ! grep "^In-Reply-To: < *>" msgtxt1
303'
304
305test_expect_success $PREREQ 'Valid In-Reply-To when prompting' '
306 clean_fake_sendmail &&
307 (echo "From Example <from@example.com>"
308 echo "To Example <to@example.com>"
309 echo ""
310 ) | env GIT_SEND_EMAIL_NOTTY=1 git send-email \
311 --smtp-server="$(pwd)/fake.sendmail" \
312 $patches 2>errors &&
313 ! grep "^In-Reply-To: < *>" msgtxt1
314'
315
316test_expect_success $PREREQ 'In-Reply-To without --chain-reply-to' '
317 clean_fake_sendmail &&
318 echo "<unique-message-id@example.com>" >expect &&
319 git send-email \
320 --from="Example <nobody@example.com>" \
321 --to=nobody@example.com \
322 --nochain-reply-to \
323 --in-reply-to="$(cat expect)" \
324 --smtp-server="$(pwd)/fake.sendmail" \
325 $patches $patches $patches \
326 2>errors &&
327 # The first message is a reply to --in-reply-to
328 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual &&
329 test_cmp expect actual &&
330 # Second and subsequent messages are replies to the first one
331 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect &&
332 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual &&
333 test_cmp expect actual &&
334 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual &&
335 test_cmp expect actual
336'
337
338test_expect_success $PREREQ 'In-Reply-To with --chain-reply-to' '
339 clean_fake_sendmail &&
340 echo "<unique-message-id@example.com>" >expect &&
341 git send-email \
342 --from="Example <nobody@example.com>" \
343 --to=nobody@example.com \
344 --chain-reply-to \
345 --in-reply-to="$(cat expect)" \
346 --smtp-server="$(pwd)/fake.sendmail" \
347 $patches $patches $patches \
348 2>errors &&
349 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual &&
350 test_cmp expect actual &&
351 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect &&
352 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual &&
353 test_cmp expect actual &&
354 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt2 >expect &&
355 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual &&
356 test_cmp expect actual
357'
358
359test_expect_success $PREREQ 'setup fake editor' '
360 (echo "#!$SHELL_PATH" &&
361 echo "echo fake edit >>\"\$1\""
362 ) >fake-editor &&
363 chmod +x fake-editor
364'
365
366test_set_editor "$(pwd)/fake-editor"
367
368test_expect_success $PREREQ '--compose works' '
369 clean_fake_sendmail &&
370 git send-email \
371 --compose --subject foo \
372 --from="Example <nobody@example.com>" \
373 --to=nobody@example.com \
374 --smtp-server="$(pwd)/fake.sendmail" \
375 $patches \
376 2>errors
377'
378
379test_expect_success $PREREQ 'first message is compose text' '
380 grep "^fake edit" msgtxt1
381'
382
383test_expect_success $PREREQ 'second message is patch' '
384 grep "Subject:.*Second" msgtxt2
385'
386
387test_expect_success $PREREQ 'setup expect' "
388cat >expected-suppress-sob <<\EOF
3890001-Second.patch
390(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
391(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
392(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
393Dry-OK. Log says:
394Server: relay.example.com
395MAIL FROM:<from@example.com>
396RCPT TO:<to@example.com>
397RCPT TO:<cc@example.com>
398RCPT TO:<author@example.com>
399RCPT TO:<one@example.com>
400RCPT TO:<two@example.com>
401From: Example <from@example.com>
402To: to@example.com
403Cc: cc@example.com,
404 A <author@example.com>,
405 One <one@example.com>,
406 two@example.com
407Subject: [PATCH 1/1] Second.
408Date: DATE-STRING
409Message-Id: MESSAGE-ID-STRING
410X-Mailer: X-MAILER-STRING
411
412Result: OK
413EOF
414"
415
416test_suppression () {
417 git send-email \
418 --dry-run \
419 --suppress-cc=$1 ${2+"--suppress-cc=$2"} \
420 --from="Example <from@example.com>" \
421 --to=to@example.com \
422 --smtp-server relay.example.com \
423 $patches |
424 sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
425 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
426 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
427 >actual-suppress-$1${2+"-$2"} &&
428 test_cmp expected-suppress-$1${2+"-$2"} actual-suppress-$1${2+"-$2"}
429}
430
431test_expect_success $PREREQ 'sendemail.cc set' '
432 git config sendemail.cc cc@example.com &&
433 test_suppression sob
434'
435
436test_expect_success $PREREQ 'setup expect' "
437cat >expected-suppress-sob <<\EOF
4380001-Second.patch
439(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
440(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
441(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
442Dry-OK. Log says:
443Server: relay.example.com
444MAIL FROM:<from@example.com>
445RCPT TO:<to@example.com>
446RCPT TO:<author@example.com>
447RCPT TO:<one@example.com>
448RCPT TO:<two@example.com>
449From: Example <from@example.com>
450To: to@example.com
451Cc: A <author@example.com>,
452 One <one@example.com>,
453 two@example.com
454Subject: [PATCH 1/1] Second.
455Date: DATE-STRING
456Message-Id: MESSAGE-ID-STRING
457X-Mailer: X-MAILER-STRING
458
459Result: OK
460EOF
461"
462
463test_expect_success $PREREQ 'sendemail.cc unset' '
464 git config --unset sendemail.cc &&
465 test_suppression sob
466'
467
468test_expect_success $PREREQ 'setup expect' "
469cat >expected-suppress-cccmd <<\EOF
4700001-Second.patch
471(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
472(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
473(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
474(body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
475Dry-OK. Log says:
476Server: relay.example.com
477MAIL FROM:<from@example.com>
478RCPT TO:<to@example.com>
479RCPT TO:<author@example.com>
480RCPT TO:<one@example.com>
481RCPT TO:<two@example.com>
482RCPT TO:<committer@example.com>
483From: Example <from@example.com>
484To: to@example.com
485Cc: A <author@example.com>,
486 One <one@example.com>,
487 two@example.com,
488 C O Mitter <committer@example.com>
489Subject: [PATCH 1/1] Second.
490Date: DATE-STRING
491Message-Id: MESSAGE-ID-STRING
492X-Mailer: X-MAILER-STRING
493
494Result: OK
495EOF
496"
497
498test_expect_success $PREREQ 'sendemail.cccmd' '
499 echo echo cc-cmd@example.com > cccmd &&
500 chmod +x cccmd &&
501 git config sendemail.cccmd ./cccmd &&
502 test_suppression cccmd
503'
504
505test_expect_success $PREREQ 'setup expect' '
506cat >expected-suppress-all <<\EOF
5070001-Second.patch
508Dry-OK. Log says:
509Server: relay.example.com
510MAIL FROM:<from@example.com>
511RCPT TO:<to@example.com>
512From: Example <from@example.com>
513To: to@example.com
514Subject: [PATCH 1/1] Second.
515Date: DATE-STRING
516Message-Id: MESSAGE-ID-STRING
517X-Mailer: X-MAILER-STRING
518
519Result: OK
520EOF
521'
522
523test_expect_success $PREREQ '--suppress-cc=all' '
524 test_suppression all
525'
526
527test_expect_success $PREREQ 'setup expect' "
528cat >expected-suppress-body <<\EOF
5290001-Second.patch
530(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
531(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
532(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
533(cc-cmd) Adding cc: cc-cmd@example.com from: './cccmd'
534Dry-OK. Log says:
535Server: relay.example.com
536MAIL FROM:<from@example.com>
537RCPT TO:<to@example.com>
538RCPT TO:<author@example.com>
539RCPT TO:<one@example.com>
540RCPT TO:<two@example.com>
541RCPT TO:<cc-cmd@example.com>
542From: Example <from@example.com>
543To: to@example.com
544Cc: A <author@example.com>,
545 One <one@example.com>,
546 two@example.com,
547 cc-cmd@example.com
548Subject: [PATCH 1/1] Second.
549Date: DATE-STRING
550Message-Id: MESSAGE-ID-STRING
551X-Mailer: X-MAILER-STRING
552
553Result: OK
554EOF
555"
556
557test_expect_success $PREREQ '--suppress-cc=body' '
558 test_suppression body
559'
560
561test_expect_success $PREREQ 'setup expect' "
562cat >expected-suppress-body-cccmd <<\EOF
5630001-Second.patch
564(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
565(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
566(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
567Dry-OK. Log says:
568Server: relay.example.com
569MAIL FROM:<from@example.com>
570RCPT TO:<to@example.com>
571RCPT TO:<author@example.com>
572RCPT TO:<one@example.com>
573RCPT TO:<two@example.com>
574From: Example <from@example.com>
575To: to@example.com
576Cc: A <author@example.com>,
577 One <one@example.com>,
578 two@example.com
579Subject: [PATCH 1/1] Second.
580Date: DATE-STRING
581Message-Id: MESSAGE-ID-STRING
582X-Mailer: X-MAILER-STRING
583
584Result: OK
585EOF
586"
587
588test_expect_success $PREREQ '--suppress-cc=body --suppress-cc=cccmd' '
589 test_suppression body cccmd
590'
591
592test_expect_success $PREREQ 'setup expect' "
593cat >expected-suppress-sob <<\EOF
5940001-Second.patch
595(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
596(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
597(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
598Dry-OK. Log says:
599Server: relay.example.com
600MAIL FROM:<from@example.com>
601RCPT TO:<to@example.com>
602RCPT TO:<author@example.com>
603RCPT TO:<one@example.com>
604RCPT TO:<two@example.com>
605From: Example <from@example.com>
606To: to@example.com
607Cc: A <author@example.com>,
608 One <one@example.com>,
609 two@example.com
610Subject: [PATCH 1/1] Second.
611Date: DATE-STRING
612Message-Id: MESSAGE-ID-STRING
613X-Mailer: X-MAILER-STRING
614
615Result: OK
616EOF
617"
618
619test_expect_success $PREREQ '--suppress-cc=sob' '
620 test_might_fail git config --unset sendemail.cccmd &&
621 test_suppression sob
622'
623
624test_expect_success $PREREQ 'setup expect' "
625cat >expected-suppress-bodycc <<\EOF
6260001-Second.patch
627(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
628(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
629(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
630(body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
631Dry-OK. Log says:
632Server: relay.example.com
633MAIL FROM:<from@example.com>
634RCPT TO:<to@example.com>
635RCPT TO:<author@example.com>
636RCPT TO:<one@example.com>
637RCPT TO:<two@example.com>
638RCPT TO:<committer@example.com>
639From: Example <from@example.com>
640To: to@example.com
641Cc: A <author@example.com>,
642 One <one@example.com>,
643 two@example.com,
644 C O Mitter <committer@example.com>
645Subject: [PATCH 1/1] Second.
646Date: DATE-STRING
647Message-Id: MESSAGE-ID-STRING
648X-Mailer: X-MAILER-STRING
649
650Result: OK
651EOF
652"
653
654test_expect_success $PREREQ '--suppress-cc=bodycc' '
655 test_suppression bodycc
656'
657
658test_expect_success $PREREQ 'setup expect' "
659cat >expected-suppress-cc <<\EOF
6600001-Second.patch
661(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
662(body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
663Dry-OK. Log says:
664Server: relay.example.com
665MAIL FROM:<from@example.com>
666RCPT TO:<to@example.com>
667RCPT TO:<author@example.com>
668RCPT TO:<committer@example.com>
669From: Example <from@example.com>
670To: to@example.com
671Cc: A <author@example.com>,
672 C O Mitter <committer@example.com>
673Subject: [PATCH 1/1] Second.
674Date: DATE-STRING
675Message-Id: MESSAGE-ID-STRING
676X-Mailer: X-MAILER-STRING
677
678Result: OK
679EOF
680"
681
682test_expect_success $PREREQ '--suppress-cc=cc' '
683 test_suppression cc
684'
685
686test_confirm () {
687 echo y | \
688 GIT_SEND_EMAIL_NOTTY=1 \
689 git send-email \
690 --from="Example <nobody@example.com>" \
691 --to=nobody@example.com \
692 --smtp-server="$(pwd)/fake.sendmail" \
693 $@ $patches > stdout &&
694 grep "Send this email" stdout
695}
696
697test_expect_success $PREREQ '--confirm=always' '
698 test_confirm --confirm=always --suppress-cc=all
699'
700
701test_expect_success $PREREQ '--confirm=auto' '
702 test_confirm --confirm=auto
703'
704
705test_expect_success $PREREQ '--confirm=cc' '
706 test_confirm --confirm=cc
707'
708
709test_expect_success $PREREQ '--confirm=compose' '
710 test_confirm --confirm=compose --compose
711'
712
713test_expect_success $PREREQ 'confirm by default (due to cc)' '
714 CONFIRM=$(git config --get sendemail.confirm) &&
715 git config --unset sendemail.confirm &&
716 test_confirm
717 ret="$?"
718 git config sendemail.confirm ${CONFIRM:-never}
719 test $ret = "0"
720'
721
722test_expect_success $PREREQ 'confirm by default (due to --compose)' '
723 CONFIRM=$(git config --get sendemail.confirm) &&
724 git config --unset sendemail.confirm &&
725 test_confirm --suppress-cc=all --compose
726 ret="$?"
727 git config sendemail.confirm ${CONFIRM:-never}
728 test $ret = "0"
729'
730
731test_expect_success $PREREQ 'confirm detects EOF (inform assumes y)' '
732 CONFIRM=$(git config --get sendemail.confirm) &&
733 git config --unset sendemail.confirm &&
734 rm -fr outdir &&
735 git format-patch -2 -o outdir &&
736 GIT_SEND_EMAIL_NOTTY=1 \
737 git send-email \
738 --from="Example <nobody@example.com>" \
739 --to=nobody@example.com \
740 --smtp-server="$(pwd)/fake.sendmail" \
741 outdir/*.patch < /dev/null
742 ret="$?"
743 git config sendemail.confirm ${CONFIRM:-never}
744 test $ret = "0"
745'
746
747test_expect_success $PREREQ 'confirm detects EOF (auto causes failure)' '
748 CONFIRM=$(git config --get sendemail.confirm) &&
749 git config sendemail.confirm auto &&
750 GIT_SEND_EMAIL_NOTTY=1 &&
751 export GIT_SEND_EMAIL_NOTTY &&
752 test_must_fail git send-email \
753 --from="Example <nobody@example.com>" \
754 --to=nobody@example.com \
755 --smtp-server="$(pwd)/fake.sendmail" \
756 $patches < /dev/null
757 ret="$?"
758 git config sendemail.confirm ${CONFIRM:-never}
759 test $ret = "0"
760'
761
762test_expect_success $PREREQ 'confirm doesnt loop forever' '
763 CONFIRM=$(git config --get sendemail.confirm) &&
764 git config sendemail.confirm auto &&
765 GIT_SEND_EMAIL_NOTTY=1 &&
766 export GIT_SEND_EMAIL_NOTTY &&
767 yes "bogus" | test_must_fail git send-email \
768 --from="Example <nobody@example.com>" \
769 --to=nobody@example.com \
770 --smtp-server="$(pwd)/fake.sendmail" \
771 $patches
772 ret="$?"
773 git config sendemail.confirm ${CONFIRM:-never}
774 test $ret = "0"
775'
776
777test_expect_success $PREREQ 'utf8 Cc is rfc2047 encoded' '
778 clean_fake_sendmail &&
779 rm -fr outdir &&
780 git format-patch -1 -o outdir --cc="àéìöú <utf8@example.com>" &&
781 git send-email \
782 --from="Example <nobody@example.com>" \
783 --to=nobody@example.com \
784 --smtp-server="$(pwd)/fake.sendmail" \
785 outdir/*.patch &&
786 grep "^ " msgtxt1 |
787 grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>"
788'
789
790test_expect_success $PREREQ '--compose adds MIME for utf8 body' '
791 clean_fake_sendmail &&
792 (echo "#!$SHELL_PATH" &&
793 echo "echo utf8 body: àéìöú >>\"\$1\""
794 ) >fake-editor-utf8 &&
795 chmod +x fake-editor-utf8 &&
796 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
797 git send-email \
798 --compose --subject foo \
799 --from="Example <nobody@example.com>" \
800 --to=nobody@example.com \
801 --smtp-server="$(pwd)/fake.sendmail" \
802 $patches &&
803 grep "^utf8 body" msgtxt1 &&
804 grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
805'
806
807test_expect_success $PREREQ '--compose respects user mime type' '
808 clean_fake_sendmail &&
809 (echo "#!$SHELL_PATH" &&
810 echo "(echo MIME-Version: 1.0"
811 echo " echo Content-Type: text/plain\\; charset=iso-8859-1"
812 echo " echo Content-Transfer-Encoding: 8bit"
813 echo " echo Subject: foo"
814 echo " echo "
815 echo " echo utf8 body: àéìöú) >\"\$1\""
816 ) >fake-editor-utf8-mime &&
817 chmod +x fake-editor-utf8-mime &&
818 GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \
819 git send-email \
820 --compose --subject foo \
821 --from="Example <nobody@example.com>" \
822 --to=nobody@example.com \
823 --smtp-server="$(pwd)/fake.sendmail" \
824 $patches &&
825 grep "^utf8 body" msgtxt1 &&
826 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 &&
827 ! grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
828'
829
830test_expect_success $PREREQ '--compose adds MIME for utf8 subject' '
831 clean_fake_sendmail &&
832 GIT_EDITOR="\"$(pwd)/fake-editor\"" \
833 git send-email \
834 --compose --subject utf8-sübjëct \
835 --from="Example <nobody@example.com>" \
836 --to=nobody@example.com \
837 --smtp-server="$(pwd)/fake.sendmail" \
838 $patches &&
839 grep "^fake edit" msgtxt1 &&
840 grep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
841'
842
843test_expect_success $PREREQ 'utf8 author is correctly passed on' '
844 clean_fake_sendmail &&
845 test_commit weird_author &&
846 test_when_finished "git reset --hard HEAD^" &&
847 git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" &&
848 git format-patch --stdout -1 >funny_name.patch &&
849 git send-email --from="Example <nobody@example.com>" \
850 --to=nobody@example.com \
851 --smtp-server="$(pwd)/fake.sendmail" \
852 funny_name.patch &&
853 grep "^From: Füñný Nâmé <odd_?=mail@example.com>" msgtxt1
854'
855
856test_expect_success $PREREQ 'sendemail.composeencoding works' '
857 clean_fake_sendmail &&
858 git config sendemail.composeencoding iso-8859-1 &&
859 (echo "#!$SHELL_PATH" &&
860 echo "echo utf8 body: àéìöú >>\"\$1\""
861 ) >fake-editor-utf8 &&
862 chmod +x fake-editor-utf8 &&
863 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
864 git send-email \
865 --compose --subject foo \
866 --from="Example <nobody@example.com>" \
867 --to=nobody@example.com \
868 --smtp-server="$(pwd)/fake.sendmail" \
869 $patches &&
870 grep "^utf8 body" msgtxt1 &&
871 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1
872'
873
874test_expect_success $PREREQ '--compose-encoding works' '
875 clean_fake_sendmail &&
876 (echo "#!$SHELL_PATH" &&
877 echo "echo utf8 body: àéìöú >>\"\$1\""
878 ) >fake-editor-utf8 &&
879 chmod +x fake-editor-utf8 &&
880 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
881 git send-email \
882 --compose-encoding iso-8859-1 \
883 --compose --subject foo \
884 --from="Example <nobody@example.com>" \
885 --to=nobody@example.com \
886 --smtp-server="$(pwd)/fake.sendmail" \
887 $patches &&
888 grep "^utf8 body" msgtxt1 &&
889 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1
890'
891
892test_expect_success $PREREQ '--compose-encoding overrides sendemail.composeencoding' '
893 clean_fake_sendmail &&
894 git config sendemail.composeencoding iso-8859-1 &&
895 (echo "#!$SHELL_PATH" &&
896 echo "echo utf8 body: àéìöú >>\"\$1\""
897 ) >fake-editor-utf8 &&
898 chmod +x fake-editor-utf8 &&
899 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
900 git send-email \
901 --compose-encoding iso-8859-2 \
902 --compose --subject foo \
903 --from="Example <nobody@example.com>" \
904 --to=nobody@example.com \
905 --smtp-server="$(pwd)/fake.sendmail" \
906 $patches &&
907 grep "^utf8 body" msgtxt1 &&
908 grep "^Content-Type: text/plain; charset=iso-8859-2" msgtxt1
909'
910
911test_expect_success $PREREQ '--compose-encoding adds correct MIME for subject' '
912 clean_fake_sendmail &&
913 GIT_EDITOR="\"$(pwd)/fake-editor\"" \
914 git send-email \
915 --compose-encoding iso-8859-2 \
916 --compose --subject utf8-sübjëct \
917 --from="Example <nobody@example.com>" \
918 --to=nobody@example.com \
919 --smtp-server="$(pwd)/fake.sendmail" \
920 $patches &&
921 grep "^fake edit" msgtxt1 &&
922 grep "^Subject: =?iso-8859-2?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
923'
924
925test_expect_success $PREREQ 'detects ambiguous reference/file conflict' '
926 echo master > master &&
927 git add master &&
928 git commit -m"add master" &&
929 test_must_fail git send-email --dry-run master 2>errors &&
930 grep disambiguate errors
931'
932
933test_expect_success $PREREQ 'feed two files' '
934 rm -fr outdir &&
935 git format-patch -2 -o outdir &&
936 git send-email \
937 --dry-run \
938 --from="Example <nobody@example.com>" \
939 --to=nobody@example.com \
940 outdir/000?-*.patch 2>errors >out &&
941 grep "^Subject: " out >subjects &&
942 test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." &&
943 test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add master"
944'
945
946test_expect_success $PREREQ 'in-reply-to but no threading' '
947 git send-email \
948 --dry-run \
949 --from="Example <nobody@example.com>" \
950 --to=nobody@example.com \
951 --in-reply-to="<in-reply-id@example.com>" \
952 --nothread \
953 $patches |
954 grep "In-Reply-To: <in-reply-id@example.com>"
955'
956
957test_expect_success $PREREQ 'no in-reply-to and no threading' '
958 git send-email \
959 --dry-run \
960 --from="Example <nobody@example.com>" \
961 --to=nobody@example.com \
962 --nothread \
963 $patches $patches >stdout &&
964 ! grep "In-Reply-To: " stdout
965'
966
967test_expect_success $PREREQ 'threading but no chain-reply-to' '
968 git send-email \
969 --dry-run \
970 --from="Example <nobody@example.com>" \
971 --to=nobody@example.com \
972 --thread \
973 --nochain-reply-to \
974 $patches $patches >stdout &&
975 grep "In-Reply-To: " stdout
976'
977
978test_expect_success $PREREQ 'warning with an implicit --chain-reply-to' '
979 git send-email \
980 --dry-run \
981 --from="Example <nobody@example.com>" \
982 --to=nobody@example.com \
983 outdir/000?-*.patch 2>errors >out &&
984 grep "no-chain-reply-to" errors
985'
986
987test_expect_success $PREREQ 'no warning with an explicit --chain-reply-to' '
988 git send-email \
989 --dry-run \
990 --from="Example <nobody@example.com>" \
991 --to=nobody@example.com \
992 --chain-reply-to \
993 outdir/000?-*.patch 2>errors >out &&
994 ! grep "no-chain-reply-to" errors
995'
996
997test_expect_success $PREREQ 'no warning with an explicit --no-chain-reply-to' '
998 git send-email \
999 --dry-run \
1000 --from="Example <nobody@example.com>" \
1001 --to=nobody@example.com \
1002 --nochain-reply-to \
1003 outdir/000?-*.patch 2>errors >out &&
1004 ! grep "no-chain-reply-to" errors
1005'
1006
1007test_expect_success $PREREQ 'no warning with sendemail.chainreplyto = false' '
1008 git config sendemail.chainreplyto false &&
1009 git send-email \
1010 --dry-run \
1011 --from="Example <nobody@example.com>" \
1012 --to=nobody@example.com \
1013 outdir/000?-*.patch 2>errors >out &&
1014 ! grep "no-chain-reply-to" errors
1015'
1016
1017test_expect_success $PREREQ 'no warning with sendemail.chainreplyto = true' '
1018 git config sendemail.chainreplyto true &&
1019 git send-email \
1020 --dry-run \
1021 --from="Example <nobody@example.com>" \
1022 --to=nobody@example.com \
1023 outdir/000?-*.patch 2>errors >out &&
1024 ! grep "no-chain-reply-to" errors
1025'
1026
1027test_expect_success $PREREQ 'sendemail.to works' '
1028 git config --replace-all sendemail.to "Somebody <somebody@ex.com>" &&
1029 git send-email \
1030 --dry-run \
1031 --from="Example <nobody@example.com>" \
1032 $patches $patches >stdout &&
1033 grep "To: Somebody <somebody@ex.com>" stdout
1034'
1035
1036test_expect_success $PREREQ '--no-to overrides sendemail.to' '
1037 git send-email \
1038 --dry-run \
1039 --from="Example <nobody@example.com>" \
1040 --no-to \
1041 --to=nobody@example.com \
1042 $patches $patches >stdout &&
1043 grep "To: nobody@example.com" stdout &&
1044 ! grep "To: Somebody <somebody@ex.com>" stdout
1045'
1046
1047test_expect_success $PREREQ 'sendemail.cc works' '
1048 git config --replace-all sendemail.cc "Somebody <somebody@ex.com>" &&
1049 git send-email \
1050 --dry-run \
1051 --from="Example <nobody@example.com>" \
1052 --to=nobody@example.com \
1053 $patches $patches >stdout &&
1054 grep "Cc: Somebody <somebody@ex.com>" stdout
1055'
1056
1057test_expect_success $PREREQ '--no-cc overrides sendemail.cc' '
1058 git send-email \
1059 --dry-run \
1060 --from="Example <nobody@example.com>" \
1061 --no-cc \
1062 --cc=bodies@example.com \
1063 --to=nobody@example.com \
1064 $patches $patches >stdout &&
1065 grep "Cc: bodies@example.com" stdout &&
1066 ! grep "Cc: Somebody <somebody@ex.com>" stdout
1067'
1068
1069test_expect_success $PREREQ 'sendemail.bcc works' '
1070 git config --replace-all sendemail.bcc "Other <other@ex.com>" &&
1071 git send-email \
1072 --dry-run \
1073 --from="Example <nobody@example.com>" \
1074 --to=nobody@example.com \
1075 --smtp-server relay.example.com \
1076 $patches $patches >stdout &&
1077 grep "RCPT TO:<other@ex.com>" stdout
1078'
1079
1080test_expect_success $PREREQ '--no-bcc overrides sendemail.bcc' '
1081 git send-email \
1082 --dry-run \
1083 --from="Example <nobody@example.com>" \
1084 --no-bcc \
1085 --bcc=bodies@example.com \
1086 --to=nobody@example.com \
1087 --smtp-server relay.example.com \
1088 $patches $patches >stdout &&
1089 grep "RCPT TO:<bodies@example.com>" stdout &&
1090 ! grep "RCPT TO:<other@ex.com>" stdout
1091'
1092
1093test_expect_success $PREREQ 'patches To headers are used by default' '
1094 patch=`git format-patch -1 --to="bodies@example.com"` &&
1095 test_when_finished "rm $patch" &&
1096 git send-email \
1097 --dry-run \
1098 --from="Example <nobody@example.com>" \
1099 --smtp-server relay.example.com \
1100 $patch >stdout &&
1101 grep "RCPT TO:<bodies@example.com>" stdout
1102'
1103
1104test_expect_success $PREREQ 'patches To headers are appended to' '
1105 patch=`git format-patch -1 --to="bodies@example.com"` &&
1106 test_when_finished "rm $patch" &&
1107 git send-email \
1108 --dry-run \
1109 --from="Example <nobody@example.com>" \
1110 --to=nobody@example.com \
1111 --smtp-server relay.example.com \
1112 $patch >stdout &&
1113 grep "RCPT TO:<bodies@example.com>" stdout &&
1114 grep "RCPT TO:<nobody@example.com>" stdout
1115'
1116
1117test_expect_success $PREREQ 'To headers from files reset each patch' '
1118 patch1=`git format-patch -1 --to="bodies@example.com"` &&
1119 patch2=`git format-patch -1 --to="other@example.com" HEAD~` &&
1120 test_when_finished "rm $patch1 && rm $patch2" &&
1121 git send-email \
1122 --dry-run \
1123 --from="Example <nobody@example.com>" \
1124 --to="nobody@example.com" \
1125 --smtp-server relay.example.com \
1126 $patch1 $patch2 >stdout &&
1127 test $(grep -c "RCPT TO:<bodies@example.com>" stdout) = 1 &&
1128 test $(grep -c "RCPT TO:<nobody@example.com>" stdout) = 2 &&
1129 test $(grep -c "RCPT TO:<other@example.com>" stdout) = 1
1130'
1131
1132test_expect_success $PREREQ 'setup expect' '
1133cat >email-using-8bit <<EOF
1134From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1135Message-Id: <bogus-message-id@example.com>
1136From: author@example.com
1137Date: Sat, 12 Jun 2010 15:53:58 +0200
1138Subject: subject goes here
1139
1140Dieser deutsche Text enthält einen Umlaut!
1141EOF
1142'
1143
1144test_expect_success $PREREQ 'setup expect' '
1145cat >expected <<EOF
1146Subject: subject goes here
1147EOF
1148'
1149
1150test_expect_success $PREREQ 'ASCII subject is not RFC2047 quoted' '
1151 clean_fake_sendmail &&
1152 echo bogus |
1153 git send-email --from=author@example.com --to=nobody@example.com \
1154 --smtp-server="$(pwd)/fake.sendmail" \
1155 --8bit-encoding=UTF-8 \
1156 email-using-8bit >stdout &&
1157 grep "Subject" msgtxt1 >actual &&
1158 test_cmp expected actual
1159'
1160
1161test_expect_success $PREREQ 'setup expect' '
1162cat >content-type-decl <<EOF
1163MIME-Version: 1.0
1164Content-Type: text/plain; charset=UTF-8
1165Content-Transfer-Encoding: 8bit
1166EOF
1167'
1168
1169test_expect_success $PREREQ 'asks about and fixes 8bit encodings' '
1170 clean_fake_sendmail &&
1171 echo |
1172 git send-email --from=author@example.com --to=nobody@example.com \
1173 --smtp-server="$(pwd)/fake.sendmail" \
1174 email-using-8bit >stdout &&
1175 grep "do not declare a Content-Transfer-Encoding" stdout &&
1176 grep email-using-8bit stdout &&
1177 grep "Which 8bit encoding" stdout &&
1178 egrep "Content|MIME" msgtxt1 >actual &&
1179 test_cmp actual content-type-decl
1180'
1181
1182test_expect_success $PREREQ 'sendemail.8bitEncoding works' '
1183 clean_fake_sendmail &&
1184 git config sendemail.assume8bitEncoding UTF-8 &&
1185 echo bogus |
1186 git send-email --from=author@example.com --to=nobody@example.com \
1187 --smtp-server="$(pwd)/fake.sendmail" \
1188 email-using-8bit >stdout &&
1189 egrep "Content|MIME" msgtxt1 >actual &&
1190 test_cmp actual content-type-decl
1191'
1192
1193test_expect_success $PREREQ '--8bit-encoding overrides sendemail.8bitEncoding' '
1194 clean_fake_sendmail &&
1195 git config sendemail.assume8bitEncoding "bogus too" &&
1196 echo bogus |
1197 git send-email --from=author@example.com --to=nobody@example.com \
1198 --smtp-server="$(pwd)/fake.sendmail" \
1199 --8bit-encoding=UTF-8 \
1200 email-using-8bit >stdout &&
1201 egrep "Content|MIME" msgtxt1 >actual &&
1202 test_cmp actual content-type-decl
1203'
1204
1205test_expect_success $PREREQ 'setup expect' '
1206cat >email-using-8bit <<EOF
1207From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1208Message-Id: <bogus-message-id@example.com>
1209From: author@example.com
1210Date: Sat, 12 Jun 2010 15:53:58 +0200
1211Subject: Dieser Betreff enthält auch einen Umlaut!
1212
1213Nothing to see here.
1214EOF
1215'
1216
1217test_expect_success $PREREQ 'setup expect' '
1218cat >expected <<EOF
1219Subject: =?UTF-8?q?Dieser=20Betreff=20enth=C3=A4lt=20auch=20einen=20Umlaut!?=
1220EOF
1221'
1222
1223test_expect_success $PREREQ '--8bit-encoding also treats subject' '
1224 clean_fake_sendmail &&
1225 echo bogus |
1226 git send-email --from=author@example.com --to=nobody@example.com \
1227 --smtp-server="$(pwd)/fake.sendmail" \
1228 --8bit-encoding=UTF-8 \
1229 email-using-8bit >stdout &&
1230 grep "Subject" msgtxt1 >actual &&
1231 test_cmp expected actual
1232'
1233
1234# Note that the patches in this test are deliberately out of order; we
1235# want to make sure it works even if the cover-letter is not in the
1236# first mail.
1237test_expect_success $PREREQ 'refusing to send cover letter template' '
1238 clean_fake_sendmail &&
1239 rm -fr outdir &&
1240 git format-patch --cover-letter -2 -o outdir &&
1241 test_must_fail git send-email \
1242 --from="Example <nobody@example.com>" \
1243 --to=nobody@example.com \
1244 --smtp-server="$(pwd)/fake.sendmail" \
1245 outdir/0002-*.patch \
1246 outdir/0000-*.patch \
1247 outdir/0001-*.patch \
1248 2>errors >out &&
1249 grep "SUBJECT HERE" errors &&
1250 test -z "$(ls msgtxt*)"
1251'
1252
1253test_expect_success $PREREQ '--force sends cover letter template anyway' '
1254 clean_fake_sendmail &&
1255 rm -fr outdir &&
1256 git format-patch --cover-letter -2 -o outdir &&
1257 git send-email \
1258 --force \
1259 --from="Example <nobody@example.com>" \
1260 --to=nobody@example.com \
1261 --smtp-server="$(pwd)/fake.sendmail" \
1262 outdir/0002-*.patch \
1263 outdir/0000-*.patch \
1264 outdir/0001-*.patch \
1265 2>errors >out &&
1266 ! grep "SUBJECT HERE" errors &&
1267 test -n "$(ls msgtxt*)"
1268'
1269
1270test_expect_success $PREREQ 'sendemail.aliasfiletype=mailrc' '
1271 clean_fake_sendmail &&
1272 echo "alias sbd somebody@example.org" >.mailrc &&
1273 git config --replace-all sendemail.aliasesfile "$(pwd)/.mailrc" &&
1274 git config sendemail.aliasfiletype mailrc &&
1275 git send-email \
1276 --from="Example <nobody@example.com>" \
1277 --to=sbd \
1278 --smtp-server="$(pwd)/fake.sendmail" \
1279 outdir/0001-*.patch \
1280 2>errors >out &&
1281 grep "^!somebody@example\.org!$" commandline1
1282'
1283
1284test_expect_success $PREREQ 'sendemail.aliasfile=~/.mailrc' '
1285 clean_fake_sendmail &&
1286 echo "alias sbd someone@example.org" >~/.mailrc &&
1287 git config --replace-all sendemail.aliasesfile "~/.mailrc" &&
1288 git config sendemail.aliasfiletype mailrc &&
1289 git send-email \
1290 --from="Example <nobody@example.com>" \
1291 --to=sbd \
1292 --smtp-server="$(pwd)/fake.sendmail" \
1293 outdir/0001-*.patch \
1294 2>errors >out &&
1295 grep "^!someone@example\.org!$" commandline1
1296'
1297
1298test_done