]> git.ipfire.org Git - thirdparty/git.git/blame - t/t9001-send-email.sh
git-send-email: refactor duplicate $? checks into a function
[thirdparty/git.git] / t / t9001-send-email.sh
CommitLineData
ce903018
RA
1#!/bin/sh
2
47a528ad 3test_description='git send-email'
a881baa2 4GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
5export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
6
ce903018
RA
7. ./test-lib.sh
8
57cd35e6
ÆAB
9# May be altered later in the test
10PREREQ="PERL"
1b19ccd2 11
ec3b4b06
CL
12replace_variable_fields () {
13 sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
14 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
15 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/"
16}
17
aca56064 18test_expect_success $PREREQ 'prepare reference tree' '
03335f22
JH
19 echo "1A quick brown fox jumps over the" >file &&
20 echo "lazy dog" >>file &&
21 git add file &&
22 GIT_AUTHOR_NAME="A" git commit -a -m "Initial."
aca56064 23'
ce903018 24
aca56064 25test_expect_success $PREREQ 'Setup helper tool' '
acd72b56
JH
26 write_script fake.sendmail <<-\EOF &&
27 shift
28 output=1
29 while test -f commandline$output
30 do
31 output=$(($output+1))
32 done
33 for a
34 do
35 echo "!$a!"
36 done >commandline$output
37 cat >"msgtxt$output"
38 EOF
03335f22
JH
39 git add fake.sendmail &&
40 GIT_AUTHOR_NAME="A" git commit -a -m "Second."
aca56064 41'
ce903018 42
ee756a81 43clean_fake_sendmail () {
6d34a2ba
JK
44 rm -f commandline* msgtxt*
45}
46
57cd35e6 47test_expect_success $PREREQ 'Extract patches' '
f9f60d70
RA
48 patches=$(git format-patch -s --cc="One <one@example.com>" --cc=two@example.com -n HEAD^1) &&
49 threaded_patches=$(git format-patch -o threaded -s --in-reply-to="format" HEAD^1)
280242d1
JH
50'
51
c1f2aa45
JS
52# Test no confirm early to ensure remaining tests will not hang
53test_no_confirm () {
54 rm -f no_confirm_okay
55 echo n | \
56 GIT_SEND_EMAIL_NOTTY=1 \
57 git send-email \
58 --from="Example <from@example.com>" \
59 --to=nobody@example.com \
60 --smtp-server="$(pwd)/fake.sendmail" \
61 $@ \
ee756a81 62 $patches >stdout &&
c7cf9566 63 ! grep "Send this email" stdout &&
ee756a81 64 >no_confirm_okay
c1f2aa45
JS
65}
66
67# Exit immediately to prevent hang if a no-confirm test fails
68check_no_confirm () {
57cd35e6
ÆAB
69 if ! test -f no_confirm_okay
70 then
71 say 'confirm test failed; skipping remaining tests to prevent hanging'
72 PREREQ="$PREREQ,CHECK_NO_CONFIRM"
73 fi
74 return 0
c1f2aa45
JS
75}
76
57cd35e6
ÆAB
77test_expect_success $PREREQ 'No confirm with --suppress-cc' '
78 test_no_confirm --suppress-cc=sob &&
79 check_no_confirm
c1f2aa45 80'
c1f2aa45 81
57cd35e6
ÆAB
82
83test_expect_success $PREREQ 'No confirm with --confirm=never' '
84 test_no_confirm --confirm=never &&
85 check_no_confirm
c1f2aa45 86'
c1f2aa45
JS
87
88# leave sendemail.confirm set to never after this so that none of the
89# remaining tests prompt unintentionally.
57cd35e6 90test_expect_success $PREREQ 'No confirm with sendemail.confirm=never' '
c1f2aa45 91 git config sendemail.confirm never &&
57cd35e6
ÆAB
92 test_no_confirm --compose --subject=foo &&
93 check_no_confirm
c1f2aa45 94'
c1f2aa45 95
57cd35e6 96test_expect_success $PREREQ 'Send patches' '
03335f22 97 git send-email --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors
280242d1 98'
ce903018 99
f9444147 100test_expect_success $PREREQ 'setup expect' '
0720a51b
JH
101 cat >expected <<-\EOF
102 !nobody@example.com!
103 !author@example.com!
104 !one@example.com!
105 !two@example.com!
106 EOF
f9444147
ÆAB
107'
108
aca56064
JH
109test_expect_success $PREREQ 'Verify commandline' '
110 test_cmp expected commandline1
111'
ce903018 112
57cd35e6 113test_expect_success $PREREQ 'Send patches with --envelope-sender' '
03335f22
JH
114 clean_fake_sendmail &&
115 git send-email --envelope-sender="Patch Contributor <patch@example.com>" --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors
4f333bc1
JH
116'
117
f9444147 118test_expect_success $PREREQ 'setup expect' '
0720a51b
JH
119 cat >expected <<-\EOF
120 !patch@example.com!
121 !-i!
122 !nobody@example.com!
123 !author@example.com!
124 !one@example.com!
125 !two@example.com!
126 EOF
f9444147
ÆAB
127'
128
aca56064
JH
129test_expect_success $PREREQ 'Verify commandline' '
130 test_cmp expected commandline1
131'
4f333bc1 132
57cd35e6 133test_expect_success $PREREQ 'Send patches with --envelope-sender=auto' '
03335f22
JH
134 clean_fake_sendmail &&
135 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
c89e3241
FC
136'
137
f9444147 138test_expect_success $PREREQ 'setup expect' '
0720a51b
JH
139 cat >expected <<-\EOF
140 !nobody@example.com!
141 !-i!
142 !nobody@example.com!
143 !author@example.com!
144 !one@example.com!
145 !two@example.com!
146 EOF
f9444147
ÆAB
147'
148
aca56064
JH
149test_expect_success $PREREQ 'Verify commandline' '
150 test_cmp expected commandline1
151'
c89e3241 152
e3fdbcc8
MM
153test_expect_success $PREREQ 'setup expect for cc trailer' "
154cat >expected-cc <<\EOF
155!recipient@example.com!
156!author@example.com!
157!one@example.com!
158!two@example.com!
159!three@example.com!
160!four@example.com!
cb2922fe
MM
161!five@example.com!
162!six@example.com!
e3fdbcc8
MM
163EOF
164"
165
166test_expect_success $PREREQ 'cc trailer with various syntax' '
167 test_commit cc-trailer &&
168 test_when_finished "git reset --hard HEAD^" &&
169 git commit --amend -F - <<-EOF &&
170 Test Cc: trailers.
171
172 Cc: one@example.com
9d334396
JH
173 Cc: <two@example.com> # trailing comments are ignored
174 Cc: <three@example.com>, <not.four@example.com> one address per line
175 Cc: "Some # Body" <four@example.com> [ <also.a.comment> ]
cb2922fe
MM
176 Cc: five@example.com # not.six@example.com
177 Cc: six@example.com, not.seven@example.com
e3fdbcc8
MM
178 EOF
179 clean_fake_sendmail &&
180 git send-email -1 --to=recipient@example.com \
181 --smtp-server="$(pwd)/fake.sendmail" &&
182 test_cmp expected-cc commandline1
183'
184
d60be8ac
AB
185test_expect_success $PREREQ 'setup fake get_maintainer.pl script for cc trailer' "
186 write_script expected-cc-script.sh <<-EOF
187 echo 'One Person <one@example.com> (supporter:THIS (FOO/bar))'
188 echo 'Two Person <two@example.com> (maintainer:THIS THING)'
189 echo 'Third List <three@example.com> (moderated list:THIS THING (FOO/bar))'
190 echo '<four@example.com> (moderated list:FOR THING)'
191 echo 'five@example.com (open list:FOR THING (FOO/bar))'
192 echo 'six@example.com (open list)'
193 EOF
194"
195
196test_expect_success $PREREQ 'cc trailer with get_maintainer.pl output' '
197 clean_fake_sendmail &&
198 git send-email -1 --to=recipient@example.com \
199 --cc-cmd=./expected-cc-script.sh \
200 --smtp-server="$(pwd)/fake.sendmail" &&
201 test_cmp expected-cc commandline1
202'
203
f9444147 204test_expect_success $PREREQ 'setup expect' "
b7f30e0a
DK
205cat >expected-show-all-headers <<\EOF
2060001-Second.patch
207(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
5012699d
JS
208(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
209(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
b7f30e0a
DK
210Dry-OK. Log says:
211Server: relay.example.com
212MAIL FROM:<from@example.com>
02461e0e
JP
213RCPT TO:<to@example.com>
214RCPT TO:<cc@example.com>
215RCPT TO:<author@example.com>
216RCPT TO:<one@example.com>
217RCPT TO:<two@example.com>
218RCPT TO:<bcc@example.com>
b7f30e0a
DK
219From: Example <from@example.com>
220To: to@example.com
02461e0e
JP
221Cc: cc@example.com,
222 A <author@example.com>,
223 One <one@example.com>,
224 two@example.com
b7f30e0a
DK
225Subject: [PATCH 1/1] Second.
226Date: DATE-STRING
227Message-Id: MESSAGE-ID-STRING
228X-Mailer: X-MAILER-STRING
229In-Reply-To: <unique-message-id@example.com>
230References: <unique-message-id@example.com>
d11c943c 231Reply-To: Reply <reply@example.com>
e67a228c 232MIME-Version: 1.0
233Content-Transfer-Encoding: 8bit
b7f30e0a
DK
234
235Result: OK
236EOF
f9444147 237"
b7f30e0a 238
5adcf2c6
MT
239test_suppress_self () {
240 test_commit $3 &&
241 test_when_finished "git reset --hard HEAD^" &&
242
243 write_script cccmd-sed <<-EOF &&
244 sed -n -e s/^cccmd--//p "\$1"
245 EOF
246
247 git commit --amend --author="$1 <$2>" -F - &&
248 clean_fake_sendmail &&
249 git format-patch --stdout -1 >"suppress-self-$3.patch" &&
250
251 git send-email --from="$1 <$2>" \
252 --to=nobody@example.com \
253 --cc-cmd=./cccmd-sed \
254 --suppress-cc=self \
255 --smtp-server="$(pwd)/fake.sendmail" \
256 suppress-self-$3.patch &&
257
258 mv msgtxt1 msgtxt1-$3 &&
259 sed -e '/^$/q' msgtxt1-$3 >"msghdr1-$3" &&
5adcf2c6
MT
260
261 (grep '^Cc:' msghdr1-$3 >"actual-no-cc-$3";
d3c6751b 262 test_must_be_empty actual-no-cc-$3)
5adcf2c6
MT
263}
264
265test_suppress_self_unquoted () {
266 test_suppress_self "$1" "$2" "unquoted-$3" <<-EOF
267 test suppress-cc.self unquoted-$3 with name $1 email $2
268
269 unquoted-$3
270
d6ee4456
MT
271 cccmd--$1 <$2>
272
5adcf2c6
MT
273 Cc: $1 <$2>
274 Signed-off-by: $1 <$2>
275 EOF
276}
277
dd29f0b4
MT
278test_suppress_self_quoted () {
279 test_suppress_self "$1" "$2" "quoted-$3" <<-EOF
280 test suppress-cc.self quoted-$3 with name $1 email $2
281
282 quoted-$3
283
284 cccmd--"$1" <$2>
285
286 Cc: $1 <$2>
287 Cc: "$1" <$2>
288 Signed-off-by: $1 <$2>
289 Signed-off-by: "$1" <$2>
290 EOF
291}
292
5adcf2c6 293test_expect_success $PREREQ 'self name is suppressed' "
d6ee4456 294 test_suppress_self_unquoted 'A U Thor' 'author@example.com' \
5adcf2c6
MT
295 'self_name_suppressed'
296"
297
dd29f0b4
MT
298test_expect_success $PREREQ 'self name with dot is suppressed' "
299 test_suppress_self_quoted 'A U. Thor' 'author@example.com' \
300 'self_name_dot_suppressed'
301"
302
4b45bcf7
MT
303test_expect_success $PREREQ 'non-ascii self name is suppressed' "
304 test_suppress_self_quoted 'Füñný Nâmé' 'odd_?=mail@example.com' \
305 'non_ascii_self_suppressed'
306"
307
ab47e2a5
РД
308# This name is long enough to force format-patch to split it into multiple
309# encoded-words, assuming it uses UTF-8 with the "Q" encoding.
310test_expect_success $PREREQ 'long non-ascii self name is suppressed' "
311 test_suppress_self_quoted 'Ƒüñníęř €. Nâṁé' 'odd_?=mail@example.com' \
312 'long_non_ascii_self_suppressed'
313"
314
14952666
MT
315test_expect_success $PREREQ 'sanitized self name is suppressed' "
316 test_suppress_self_unquoted '\"A U. Thor\"' 'author@example.com' \
317 'self_name_sanitized_suppressed'
318"
319
57cd35e6 320test_expect_success $PREREQ 'Show all headers' '
b7f30e0a
DK
321 git send-email \
322 --dry-run \
3531e270 323 --suppress-cc=sob \
b7f30e0a 324 --from="Example <from@example.com>" \
d11c943c 325 --reply-to="Reply <reply@example.com>" \
b7f30e0a
DK
326 --to=to@example.com \
327 --cc=cc@example.com \
328 --bcc=bcc@example.com \
329 --in-reply-to="<unique-message-id@example.com>" \
330 --smtp-server relay.example.com \
ec3b4b06 331 $patches | replace_variable_fields \
b7f30e0a 332 >actual-show-all-headers &&
82ebb0b6 333 test_cmp expected-show-all-headers actual-show-all-headers
b7f30e0a
DK
334'
335
57cd35e6 336test_expect_success $PREREQ 'Prompting works' '
0da43a68 337 clean_fake_sendmail &&
cff4243d 338 (echo "to@example.com" &&
0da43a68
JS
339 echo ""
340 ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
341 --smtp-server="$(pwd)/fake.sendmail" \
342 $patches \
343 2>errors &&
8cac13dc 344 grep "^From: A U Thor <author@example.com>\$" msgtxt1 &&
9524cf29 345 grep "^To: to@example.com\$" msgtxt1
0da43a68
JS
346'
347
59defcc3
JK
348test_expect_success $PREREQ,AUTOIDENT 'implicit ident is allowed' '
349 clean_fake_sendmail &&
350 (sane_unset GIT_AUTHOR_NAME &&
351 sane_unset GIT_AUTHOR_EMAIL &&
352 sane_unset GIT_COMMITTER_NAME &&
353 sane_unset GIT_COMMITTER_EMAIL &&
354 GIT_SEND_EMAIL_NOTTY=1 git send-email \
355 --smtp-server="$(pwd)/fake.sendmail" \
356 --to=to@example.com \
357 $patches </dev/null 2>errors
358 )
359'
360
361test_expect_success $PREREQ,!AUTOIDENT 'broken implicit ident aborts send-email' '
362 clean_fake_sendmail &&
363 (sane_unset GIT_AUTHOR_NAME &&
364 sane_unset GIT_AUTHOR_EMAIL &&
365 sane_unset GIT_COMMITTER_NAME &&
366 sane_unset GIT_COMMITTER_EMAIL &&
367 GIT_SEND_EMAIL_NOTTY=1 && export GIT_SEND_EMAIL_NOTTY &&
368 test_must_fail git send-email \
369 --smtp-server="$(pwd)/fake.sendmail" \
370 --to=to@example.com \
371 $patches </dev/null 2>errors &&
372 test_i18ngrep "tell me who you are" errors
373 )
374'
375
62089fb8
RL
376test_expect_success $PREREQ 'setup tocmd and cccmd scripts' '
377 write_script tocmd-sed <<-\EOF &&
378 sed -n -e "s/^tocmd--//p" "$1"
379 EOF
380 write_script cccmd-sed <<-\EOF
381 sed -n -e "s/^cccmd--//p" "$1"
382 EOF
383'
384
6e74e075
JP
385test_expect_success $PREREQ 'tocmd works' '
386 clean_fake_sendmail &&
387 cp $patches tocmd.patch &&
388 echo tocmd--tocmd@example.com >>tocmd.patch &&
6e74e075
JP
389 git send-email \
390 --from="Example <nobody@example.com>" \
391 --to-cmd=./tocmd-sed \
392 --smtp-server="$(pwd)/fake.sendmail" \
393 tocmd.patch \
394 &&
395 grep "^To: tocmd@example.com" msgtxt1
396'
397
57cd35e6 398test_expect_success $PREREQ 'cccmd works' '
cb8a9bd5
PB
399 clean_fake_sendmail &&
400 cp $patches cccmd.patch &&
41ae8f1d 401 echo "cccmd-- cccmd@example.com" >>cccmd.patch &&
cb8a9bd5
PB
402 git send-email \
403 --from="Example <nobody@example.com>" \
404 --to=nobody@example.com \
405 --cc-cmd=./cccmd-sed \
406 --smtp-server="$(pwd)/fake.sendmail" \
407 cccmd.patch \
408 &&
02461e0e 409 grep "^ cccmd@example.com" msgtxt1
cb8a9bd5
PB
410'
411
57cd35e6 412test_expect_success $PREREQ 'reject long lines' '
f9444147
ÆAB
413 z8=zzzzzzzz &&
414 z64=$z8$z8$z8$z8$z8$z8$z8$z8 &&
415 z512=$z64$z64$z64$z64$z64$z64$z64$z64 &&
6d34a2ba 416 clean_fake_sendmail &&
747bbff9
JK
417 cp $patches longline.patch &&
418 echo $z512$z512 >>longline.patch &&
d492b31c 419 test_must_fail git send-email \
747bbff9
JK
420 --from="Example <nobody@example.com>" \
421 --to=nobody@example.com \
422 --smtp-server="$(pwd)/fake.sendmail" \
e67a228c 423 --transfer-encoding=8bit \
747bbff9 424 $patches longline.patch \
e585210e
ÆAB
425 2>actual &&
426 cat >expect <<-\EOF &&
427 fatal: longline.patch: 35: patch contains a line longer than 998 characters
428 warning: no patches were sent
429 EOF
430 test_cmp expect actual
747bbff9
JK
431'
432
57cd35e6 433test_expect_success $PREREQ 'no patch was sent' '
6d34a2ba 434 ! test -e commandline1
747bbff9
JK
435'
436
57cd35e6 437test_expect_success $PREREQ 'Author From: in message body' '
5012699d
JS
438 clean_fake_sendmail &&
439 git send-email \
440 --from="Example <nobody@example.com>" \
441 --to=nobody@example.com \
442 --smtp-server="$(pwd)/fake.sendmail" \
443 $patches &&
ee756a81 444 sed "1,/^\$/d" <msgtxt1 >msgbody1 &&
5012699d
JS
445 grep "From: A <author@example.com>" msgbody1
446'
447
57cd35e6 448test_expect_success $PREREQ 'Author From: not in message body' '
5012699d
JS
449 clean_fake_sendmail &&
450 git send-email \
451 --from="A <author@example.com>" \
452 --to=nobody@example.com \
453 --smtp-server="$(pwd)/fake.sendmail" \
454 $patches &&
ee756a81 455 sed "1,/^\$/d" <msgtxt1 >msgbody1 &&
5012699d
JS
456 ! grep "From: A <author@example.com>" msgbody1
457'
458
57cd35e6 459test_expect_success $PREREQ 'allow long lines with --no-validate' '
c764a0c2
JK
460 git send-email \
461 --from="Example <nobody@example.com>" \
462 --to=nobody@example.com \
463 --smtp-server="$(pwd)/fake.sendmail" \
f4714943 464 --no-validate \
c764a0c2
JK
465 $patches longline.patch \
466 2>errors
467'
468
7a36987f 469test_expect_success $PREREQ 'short lines with auto encoding are 8bit' '
470 clean_fake_sendmail &&
471 git send-email \
472 --from="A <author@example.com>" \
473 --to=nobody@example.com \
474 --smtp-server="$(pwd)/fake.sendmail" \
475 --transfer-encoding=auto \
476 $patches &&
477 grep "Content-Transfer-Encoding: 8bit" msgtxt1
478'
479
480test_expect_success $PREREQ 'long lines with auto encoding are quoted-printable' '
481 clean_fake_sendmail &&
482 git send-email \
483 --from="Example <nobody@example.com>" \
484 --to=nobody@example.com \
485 --smtp-server="$(pwd)/fake.sendmail" \
486 --transfer-encoding=auto \
487 --no-validate \
488 longline.patch &&
489 grep "Content-Transfer-Encoding: quoted-printable" msgtxt1
490'
491
74d76a17 492test_expect_success $PREREQ 'carriage returns with auto encoding are quoted-printable' '
493 clean_fake_sendmail &&
494 cp $patches cr.patch &&
495 printf "this is a line\r\n" >>cr.patch &&
496 git send-email \
497 --from="Example <nobody@example.com>" \
498 --to=nobody@example.com \
499 --smtp-server="$(pwd)/fake.sendmail" \
500 --transfer-encoding=auto \
501 --no-validate \
502 cr.patch &&
503 grep "Content-Transfer-Encoding: quoted-printable" msgtxt1
504'
505
f2d06fb1 506for enc in auto quoted-printable base64
507do
508 test_expect_success $PREREQ "--validate passes with encoding $enc" '
509 git send-email \
510 --from="Example <nobody@example.com>" \
511 --to=nobody@example.com \
512 --smtp-server="$(pwd)/fake.sendmail" \
513 --transfer-encoding=$enc \
514 --validate \
515 $patches longline.patch
516 '
3c88e46f
AL
517
518done
519
c8243933
RF
520test_expect_success $PREREQ "--validate respects relative core.hooksPath path" '
521 clean_fake_sendmail &&
522 mkdir my-hooks &&
523 test_when_finished "rm my-hooks.ran" &&
524 write_script my-hooks/sendemail-validate <<-\EOF &&
525 >my-hooks.ran
526 exit 1
527 EOF
528 test_config core.hooksPath "my-hooks" &&
529 test_must_fail git send-email \
530 --from="Example <nobody@example.com>" \
531 --to=nobody@example.com \
532 --smtp-server="$(pwd)/fake.sendmail" \
533 --validate \
e585210e 534 longline.patch 2>actual &&
c8243933 535 test_path_is_file my-hooks.ran &&
e585210e
ÆAB
536 cat >expect <<-\EOF &&
537 fatal: longline.patch: rejected by sendemail-validate hook
538 warning: no patches were sent
539 EOF
540 test_cmp expect actual
c8243933
RF
541'
542
543test_expect_success $PREREQ "--validate respects absolute core.hooksPath path" '
544 test_config core.hooksPath "$(pwd)/my-hooks" &&
545 test_when_finished "rm my-hooks.ran" &&
546 test_must_fail git send-email \
547 --from="Example <nobody@example.com>" \
548 --to=nobody@example.com \
549 --smtp-server="$(pwd)/fake.sendmail" \
550 --validate \
e585210e 551 longline.patch 2>actual &&
c8243933 552 test_path_is_file my-hooks.ran &&
e585210e
ÆAB
553 cat >expect <<-\EOF &&
554 fatal: longline.patch: rejected by sendemail-validate hook
555 warning: no patches were sent
556 EOF
557 test_cmp expect actual
c8243933
RF
558'
559
3c88e46f
AL
560for enc in 7bit 8bit quoted-printable base64
561do
562 test_expect_success $PREREQ "--transfer-encoding=$enc produces correct header" '
563 clean_fake_sendmail &&
564 git send-email \
565 --from="Example <nobody@example.com>" \
566 --to=nobody@example.com \
567 --smtp-server="$(pwd)/fake.sendmail" \
568 --transfer-encoding=$enc \
569 $patches &&
570 grep "Content-Transfer-Encoding: $enc" msgtxt1
571 '
f2d06fb1 572done
573
57cd35e6 574test_expect_success $PREREQ 'Invalid In-Reply-To' '
6d34a2ba 575 clean_fake_sendmail &&
0fb7fc75
JS
576 git send-email \
577 --from="Example <nobody@example.com>" \
578 --to=nobody@example.com \
579 --in-reply-to=" " \
580 --smtp-server="$(pwd)/fake.sendmail" \
5b57413c 581 $patches \
cc7e8167 582 2>errors &&
6d34a2ba 583 ! grep "^In-Reply-To: < *>" msgtxt1
0fb7fc75
JS
584'
585
57cd35e6 586test_expect_success $PREREQ 'Valid In-Reply-To when prompting' '
6d34a2ba 587 clean_fake_sendmail &&
cff4243d
ES
588 (echo "From Example <from@example.com>" &&
589 echo "To Example <to@example.com>" &&
0fb7fc75 590 echo ""
6eca18ca 591 ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
0fb7fc75
JS
592 --smtp-server="$(pwd)/fake.sendmail" \
593 $patches 2>errors &&
6d34a2ba 594 ! grep "^In-Reply-To: < *>" msgtxt1
0fb7fc75
JS
595'
596
54aae5e1
JH
597test_expect_success $PREREQ 'In-Reply-To without --chain-reply-to' '
598 clean_fake_sendmail &&
599 echo "<unique-message-id@example.com>" >expect &&
600 git send-email \
601 --from="Example <nobody@example.com>" \
602 --to=nobody@example.com \
f4714943 603 --no-chain-reply-to \
54aae5e1
JH
604 --in-reply-to="$(cat expect)" \
605 --smtp-server="$(pwd)/fake.sendmail" \
606 $patches $patches $patches \
607 2>errors &&
db54c8e7 608 # The first message is a reply to --in-reply-to
54aae5e1
JH
609 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual &&
610 test_cmp expect actual &&
db54c8e7
AO
611 # Second and subsequent messages are replies to the first one
612 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect &&
54aae5e1
JH
613 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual &&
614 test_cmp expect actual &&
615 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual &&
616 test_cmp expect actual
617'
618
619test_expect_success $PREREQ 'In-Reply-To with --chain-reply-to' '
620 clean_fake_sendmail &&
621 echo "<unique-message-id@example.com>" >expect &&
622 git send-email \
623 --from="Example <nobody@example.com>" \
624 --to=nobody@example.com \
625 --chain-reply-to \
626 --in-reply-to="$(cat expect)" \
627 --smtp-server="$(pwd)/fake.sendmail" \
628 $patches $patches $patches \
629 2>errors &&
630 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual &&
631 test_cmp expect actual &&
632 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect &&
633 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual &&
634 test_cmp expect actual &&
635 sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt2 >expect &&
636 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual &&
637 test_cmp expect actual
638'
639
57cd35e6 640test_expect_success $PREREQ 'setup fake editor' '
acd72b56
JH
641 write_script fake-editor <<-\EOF
642 echo fake edit >>"$1"
643 EOF
8a8bf469
JK
644'
645
7f0475c3 646test_set_editor "$(pwd)/fake-editor"
065096c2 647
57cd35e6 648test_expect_success $PREREQ '--compose works' '
8a8bf469 649 clean_fake_sendmail &&
c1f2aa45
JS
650 git send-email \
651 --compose --subject foo \
652 --from="Example <nobody@example.com>" \
653 --to=nobody@example.com \
654 --smtp-server="$(pwd)/fake.sendmail" \
655 $patches \
656 2>errors
8a8bf469
JK
657'
658
57cd35e6 659test_expect_success $PREREQ 'first message is compose text' '
8a8bf469
JK
660 grep "^fake edit" msgtxt1
661'
662
57cd35e6 663test_expect_success $PREREQ 'second message is patch' '
8a8bf469
JK
664 grep "Subject:.*Second" msgtxt2
665'
666
f9444147 667test_expect_success $PREREQ 'setup expect' "
3531e270 668cat >expected-suppress-sob <<\EOF
33c592dd
MV
6690001-Second.patch
670(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
5012699d
JS
671(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
672(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
33c592dd
MV
673Dry-OK. Log says:
674Server: relay.example.com
675MAIL FROM:<from@example.com>
02461e0e
JP
676RCPT TO:<to@example.com>
677RCPT TO:<cc@example.com>
678RCPT TO:<author@example.com>
679RCPT TO:<one@example.com>
680RCPT TO:<two@example.com>
33c592dd
MV
681From: Example <from@example.com>
682To: to@example.com
02461e0e
JP
683Cc: cc@example.com,
684 A <author@example.com>,
685 One <one@example.com>,
686 two@example.com
33c592dd
MV
687Subject: [PATCH 1/1] Second.
688Date: DATE-STRING
689Message-Id: MESSAGE-ID-STRING
690X-Mailer: X-MAILER-STRING
e67a228c 691MIME-Version: 1.0
692Content-Transfer-Encoding: 8bit
33c592dd
MV
693
694Result: OK
695EOF
f9444147 696"
33c592dd 697
3531e270 698test_suppression () {
33c592dd
MV
699 git send-email \
700 --dry-run \
cb8a9bd5 701 --suppress-cc=$1 ${2+"--suppress-cc=$2"} \
33c592dd
MV
702 --from="Example <from@example.com>" \
703 --to=to@example.com \
704 --smtp-server relay.example.com \
d4cf11c2 705 $patches | replace_variable_fields \
cb8a9bd5
PB
706 >actual-suppress-$1${2+"-$2"} &&
707 test_cmp expected-suppress-$1${2+"-$2"} actual-suppress-$1${2+"-$2"}
3531e270
JS
708}
709
57cd35e6 710test_expect_success $PREREQ 'sendemail.cc set' '
3531e270
JS
711 git config sendemail.cc cc@example.com &&
712 test_suppression sob
33c592dd
MV
713'
714
f9444147 715test_expect_success $PREREQ 'setup expect' "
3531e270 716cat >expected-suppress-sob <<\EOF
33c592dd
MV
7170001-Second.patch
718(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
5012699d
JS
719(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
720(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
33c592dd
MV
721Dry-OK. Log says:
722Server: relay.example.com
723MAIL FROM:<from@example.com>
02461e0e
JP
724RCPT TO:<to@example.com>
725RCPT TO:<author@example.com>
726RCPT TO:<one@example.com>
727RCPT TO:<two@example.com>
33c592dd
MV
728From: Example <from@example.com>
729To: to@example.com
02461e0e
JP
730Cc: A <author@example.com>,
731 One <one@example.com>,
732 two@example.com
33c592dd
MV
733Subject: [PATCH 1/1] Second.
734Date: DATE-STRING
735Message-Id: MESSAGE-ID-STRING
736X-Mailer: X-MAILER-STRING
e67a228c 737MIME-Version: 1.0
738Content-Transfer-Encoding: 8bit
33c592dd
MV
739
740Result: OK
741EOF
f9444147 742"
33c592dd 743
57cd35e6 744test_expect_success $PREREQ 'sendemail.cc unset' '
33c592dd 745 git config --unset sendemail.cc &&
3531e270
JS
746 test_suppression sob
747'
748
f9444147 749test_expect_success $PREREQ 'setup expect' "
cb8a9bd5
PB
750cat >expected-suppress-cccmd <<\EOF
7510001-Second.patch
752(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
753(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
754(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
755(body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
756Dry-OK. Log says:
757Server: relay.example.com
758MAIL FROM:<from@example.com>
02461e0e
JP
759RCPT TO:<to@example.com>
760RCPT TO:<author@example.com>
761RCPT TO:<one@example.com>
762RCPT TO:<two@example.com>
763RCPT TO:<committer@example.com>
cb8a9bd5
PB
764From: Example <from@example.com>
765To: to@example.com
02461e0e
JP
766Cc: A <author@example.com>,
767 One <one@example.com>,
768 two@example.com,
769 C O Mitter <committer@example.com>
cb8a9bd5
PB
770Subject: [PATCH 1/1] Second.
771Date: DATE-STRING
772Message-Id: MESSAGE-ID-STRING
773X-Mailer: X-MAILER-STRING
e67a228c 774MIME-Version: 1.0
775Content-Transfer-Encoding: 8bit
cb8a9bd5
PB
776
777Result: OK
778EOF
f9444147 779"
cb8a9bd5 780
57cd35e6 781test_expect_success $PREREQ 'sendemail.cccmd' '
acd72b56
JH
782 write_script cccmd <<-\EOF &&
783 echo cc-cmd@example.com
784 EOF
cb8a9bd5
PB
785 git config sendemail.cccmd ./cccmd &&
786 test_suppression cccmd
787'
788
f9444147 789test_expect_success $PREREQ 'setup expect' '
3531e270
JS
790cat >expected-suppress-all <<\EOF
7910001-Second.patch
792Dry-OK. Log says:
793Server: relay.example.com
794MAIL FROM:<from@example.com>
795RCPT TO:<to@example.com>
796From: Example <from@example.com>
797To: to@example.com
798Subject: [PATCH 1/1] Second.
799Date: DATE-STRING
800Message-Id: MESSAGE-ID-STRING
801X-Mailer: X-MAILER-STRING
e67a228c 802MIME-Version: 1.0
803Content-Transfer-Encoding: 8bit
3531e270
JS
804
805Result: OK
806EOF
f9444147 807'
3531e270 808
57cd35e6 809test_expect_success $PREREQ '--suppress-cc=all' '
3531e270
JS
810 test_suppression all
811'
812
f9444147 813test_expect_success $PREREQ 'setup expect' "
3531e270
JS
814cat >expected-suppress-body <<\EOF
8150001-Second.patch
816(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
817(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
818(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
cb8a9bd5 819(cc-cmd) Adding cc: cc-cmd@example.com from: './cccmd'
3531e270
JS
820Dry-OK. Log says:
821Server: relay.example.com
822MAIL FROM:<from@example.com>
02461e0e
JP
823RCPT TO:<to@example.com>
824RCPT TO:<author@example.com>
825RCPT TO:<one@example.com>
826RCPT TO:<two@example.com>
827RCPT TO:<cc-cmd@example.com>
3531e270
JS
828From: Example <from@example.com>
829To: to@example.com
02461e0e
JP
830Cc: A <author@example.com>,
831 One <one@example.com>,
832 two@example.com,
833 cc-cmd@example.com
3531e270
JS
834Subject: [PATCH 1/1] Second.
835Date: DATE-STRING
836Message-Id: MESSAGE-ID-STRING
837X-Mailer: X-MAILER-STRING
e67a228c 838MIME-Version: 1.0
839Content-Transfer-Encoding: 8bit
3531e270
JS
840
841Result: OK
842EOF
f9444147 843"
3531e270 844
57cd35e6 845test_expect_success $PREREQ '--suppress-cc=body' '
3531e270
JS
846 test_suppression body
847'
848
f9444147 849test_expect_success $PREREQ 'setup expect' "
cb8a9bd5
PB
850cat >expected-suppress-body-cccmd <<\EOF
8510001-Second.patch
852(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
853(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
854(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
855Dry-OK. Log says:
856Server: relay.example.com
857MAIL FROM:<from@example.com>
02461e0e
JP
858RCPT TO:<to@example.com>
859RCPT TO:<author@example.com>
860RCPT TO:<one@example.com>
861RCPT TO:<two@example.com>
cb8a9bd5
PB
862From: Example <from@example.com>
863To: to@example.com
02461e0e
JP
864Cc: A <author@example.com>,
865 One <one@example.com>,
866 two@example.com
cb8a9bd5
PB
867Subject: [PATCH 1/1] Second.
868Date: DATE-STRING
869Message-Id: MESSAGE-ID-STRING
870X-Mailer: X-MAILER-STRING
e67a228c 871MIME-Version: 1.0
872Content-Transfer-Encoding: 8bit
cb8a9bd5
PB
873
874Result: OK
875EOF
f9444147 876"
cb8a9bd5 877
57cd35e6 878test_expect_success $PREREQ '--suppress-cc=body --suppress-cc=cccmd' '
cb8a9bd5
PB
879 test_suppression body cccmd
880'
881
f9444147 882test_expect_success $PREREQ 'setup expect' "
3531e270
JS
883cat >expected-suppress-sob <<\EOF
8840001-Second.patch
885(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
886(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
887(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
888Dry-OK. Log says:
889Server: relay.example.com
890MAIL FROM:<from@example.com>
02461e0e
JP
891RCPT TO:<to@example.com>
892RCPT TO:<author@example.com>
893RCPT TO:<one@example.com>
894RCPT TO:<two@example.com>
3531e270
JS
895From: Example <from@example.com>
896To: to@example.com
02461e0e
JP
897Cc: A <author@example.com>,
898 One <one@example.com>,
899 two@example.com
3531e270
JS
900Subject: [PATCH 1/1] Second.
901Date: DATE-STRING
902Message-Id: MESSAGE-ID-STRING
903X-Mailer: X-MAILER-STRING
e67a228c 904MIME-Version: 1.0
905Content-Transfer-Encoding: 8bit
3531e270
JS
906
907Result: OK
908EOF
f9444147 909"
3531e270 910
57cd35e6 911test_expect_success $PREREQ '--suppress-cc=sob' '
cc7e8167 912 test_might_fail git config --unset sendemail.cccmd &&
3531e270
JS
913 test_suppression sob
914'
915
f9444147 916test_expect_success $PREREQ 'setup expect' "
3531e270
JS
917cat >expected-suppress-bodycc <<\EOF
9180001-Second.patch
919(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
920(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
921(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
922(body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
923Dry-OK. Log says:
924Server: relay.example.com
925MAIL FROM:<from@example.com>
02461e0e
JP
926RCPT TO:<to@example.com>
927RCPT TO:<author@example.com>
928RCPT TO:<one@example.com>
929RCPT TO:<two@example.com>
930RCPT TO:<committer@example.com>
3531e270
JS
931From: Example <from@example.com>
932To: to@example.com
02461e0e
JP
933Cc: A <author@example.com>,
934 One <one@example.com>,
935 two@example.com,
936 C O Mitter <committer@example.com>
3531e270
JS
937Subject: [PATCH 1/1] Second.
938Date: DATE-STRING
939Message-Id: MESSAGE-ID-STRING
940X-Mailer: X-MAILER-STRING
e67a228c 941MIME-Version: 1.0
942Content-Transfer-Encoding: 8bit
3531e270
JS
943
944Result: OK
945EOF
f9444147 946"
3531e270 947
57cd35e6 948test_expect_success $PREREQ '--suppress-cc=bodycc' '
3531e270
JS
949 test_suppression bodycc
950'
951
f9444147 952test_expect_success $PREREQ 'setup expect' "
3531e270
JS
953cat >expected-suppress-cc <<\EOF
9540001-Second.patch
955(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
956(body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
957Dry-OK. Log says:
958Server: relay.example.com
959MAIL FROM:<from@example.com>
02461e0e
JP
960RCPT TO:<to@example.com>
961RCPT TO:<author@example.com>
962RCPT TO:<committer@example.com>
3531e270
JS
963From: Example <from@example.com>
964To: to@example.com
02461e0e
JP
965Cc: A <author@example.com>,
966 C O Mitter <committer@example.com>
3531e270
JS
967Subject: [PATCH 1/1] Second.
968Date: DATE-STRING
969Message-Id: MESSAGE-ID-STRING
970X-Mailer: X-MAILER-STRING
e67a228c 971MIME-Version: 1.0
972Content-Transfer-Encoding: 8bit
3531e270
JS
973
974Result: OK
975EOF
f9444147 976"
3531e270 977
57cd35e6 978test_expect_success $PREREQ '--suppress-cc=cc' '
3531e270 979 test_suppression cc
33c592dd
MV
980'
981
c1f2aa45
JS
982test_confirm () {
983 echo y | \
984 GIT_SEND_EMAIL_NOTTY=1 \
985 git send-email \
986 --from="Example <nobody@example.com>" \
987 --to=nobody@example.com \
988 --smtp-server="$(pwd)/fake.sendmail" \
ee756a81 989 $@ $patches >stdout &&
c18f75a1 990 grep "Send this email" stdout
c1f2aa45
JS
991}
992
57cd35e6 993test_expect_success $PREREQ '--confirm=always' '
c1f2aa45
JS
994 test_confirm --confirm=always --suppress-cc=all
995'
996
57cd35e6 997test_expect_success $PREREQ '--confirm=auto' '
c1f2aa45
JS
998 test_confirm --confirm=auto
999'
1000
57cd35e6 1001test_expect_success $PREREQ '--confirm=cc' '
c1f2aa45
JS
1002 test_confirm --confirm=cc
1003'
1004
57cd35e6 1005test_expect_success $PREREQ '--confirm=compose' '
c1f2aa45
JS
1006 test_confirm --confirm=compose --compose
1007'
1008
545871bf 1009test_expect_success $PREREQ 'confirm by default (due to cc)' '
fc99da1f 1010 test_when_finished git config sendemail.confirm never &&
c1f2aa45 1011 git config --unset sendemail.confirm &&
c18f75a1 1012 test_confirm
c1f2aa45
JS
1013'
1014
57cd35e6 1015test_expect_success $PREREQ 'confirm by default (due to --compose)' '
fc99da1f 1016 test_when_finished git config sendemail.confirm never &&
c1f2aa45
JS
1017 git config --unset sendemail.confirm &&
1018 test_confirm --suppress-cc=all --compose
c1f2aa45
JS
1019'
1020
57cd35e6 1021test_expect_success $PREREQ 'confirm detects EOF (inform assumes y)' '
fc99da1f 1022 test_when_finished git config sendemail.confirm never &&
c18f75a1 1023 git config --unset sendemail.confirm &&
dc1460aa
JS
1024 rm -fr outdir &&
1025 git format-patch -2 -o outdir &&
c18f75a1
JS
1026 GIT_SEND_EMAIL_NOTTY=1 \
1027 git send-email \
1028 --from="Example <nobody@example.com>" \
1029 --to=nobody@example.com \
1030 --smtp-server="$(pwd)/fake.sendmail" \
ee756a81 1031 outdir/*.patch </dev/null
c18f75a1
JS
1032'
1033
57cd35e6 1034test_expect_success $PREREQ 'confirm detects EOF (auto causes failure)' '
fc99da1f 1035 test_when_finished git config sendemail.confirm never &&
c18f75a1 1036 git config sendemail.confirm auto &&
3b3637c3
JS
1037 GIT_SEND_EMAIL_NOTTY=1 &&
1038 export GIT_SEND_EMAIL_NOTTY &&
c18f75a1
JS
1039 test_must_fail git send-email \
1040 --from="Example <nobody@example.com>" \
1041 --to=nobody@example.com \
1042 --smtp-server="$(pwd)/fake.sendmail" \
ee756a81 1043 $patches </dev/null
c18f75a1
JS
1044'
1045
41ccfdd9 1046test_expect_success $PREREQ 'confirm does not loop forever' '
fc99da1f 1047 test_when_finished git config sendemail.confirm never &&
c18f75a1 1048 git config sendemail.confirm auto &&
3b3637c3
JS
1049 GIT_SEND_EMAIL_NOTTY=1 &&
1050 export GIT_SEND_EMAIL_NOTTY &&
1051 yes "bogus" | test_must_fail git send-email \
c18f75a1
JS
1052 --from="Example <nobody@example.com>" \
1053 --to=nobody@example.com \
1054 --smtp-server="$(pwd)/fake.sendmail" \
1055 $patches
c18f75a1
JS
1056'
1057
57cd35e6 1058test_expect_success $PREREQ 'utf8 Cc is rfc2047 encoded' '
a61c0ffa
JS
1059 clean_fake_sendmail &&
1060 rm -fr outdir &&
1061 git format-patch -1 -o outdir --cc="àéìöú <utf8@example.com>" &&
1062 git send-email \
1063 --from="Example <nobody@example.com>" \
1064 --to=nobody@example.com \
1065 --smtp-server="$(pwd)/fake.sendmail" \
1066 outdir/*.patch &&
02461e0e 1067 grep "^ " msgtxt1 |
d1fff6fc 1068 grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>"
a61c0ffa
JS
1069'
1070
57cd35e6 1071test_expect_success $PREREQ '--compose adds MIME for utf8 body' '
0706bd19 1072 clean_fake_sendmail &&
acd72b56
JH
1073 write_script fake-editor-utf8 <<-\EOF &&
1074 echo "utf8 body: àéìöú" >>"$1"
1075 EOF
03335f22
JH
1076 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
1077 git send-email \
1078 --compose --subject foo \
1079 --from="Example <nobody@example.com>" \
1080 --to=nobody@example.com \
1081 --smtp-server="$(pwd)/fake.sendmail" \
1082 $patches &&
0706bd19 1083 grep "^utf8 body" msgtxt1 &&
d1fff6fc 1084 grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
0706bd19
JK
1085'
1086
57cd35e6 1087test_expect_success $PREREQ '--compose respects user mime type' '
0706bd19 1088 clean_fake_sendmail &&
acd72b56
JH
1089 write_script fake-editor-utf8-mime <<-\EOF &&
1090 cat >"$1" <<-\EOM
1091 MIME-Version: 1.0
1092 Content-Type: text/plain; charset=iso-8859-1
1093 Content-Transfer-Encoding: 8bit
1094 Subject: foo
1095
1096 utf8 body: àéìöú
1097 EOM
1098 EOF
03335f22
JH
1099 GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \
1100 git send-email \
1101 --compose --subject foo \
1102 --from="Example <nobody@example.com>" \
1103 --to=nobody@example.com \
1104 --smtp-server="$(pwd)/fake.sendmail" \
1105 $patches &&
0706bd19
JK
1106 grep "^utf8 body" msgtxt1 &&
1107 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 &&
d1fff6fc 1108 ! grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
0706bd19
JK
1109'
1110
57cd35e6 1111test_expect_success $PREREQ '--compose adds MIME for utf8 subject' '
d54eaaa2 1112 clean_fake_sendmail &&
03335f22
JH
1113 GIT_EDITOR="\"$(pwd)/fake-editor\"" \
1114 git send-email \
1115 --compose --subject utf8-sübjëct \
1116 --from="Example <nobody@example.com>" \
1117 --to=nobody@example.com \
1118 --smtp-server="$(pwd)/fake.sendmail" \
1119 $patches &&
d54eaaa2 1120 grep "^fake edit" msgtxt1 &&
d1fff6fc 1121 grep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
d54eaaa2
JK
1122'
1123
b622d4d1
TR
1124test_expect_success $PREREQ 'utf8 author is correctly passed on' '
1125 clean_fake_sendmail &&
1126 test_commit weird_author &&
1127 test_when_finished "git reset --hard HEAD^" &&
1128 git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" &&
1129 git format-patch --stdout -1 >funny_name.patch &&
1130 git send-email --from="Example <nobody@example.com>" \
03335f22
JH
1131 --to=nobody@example.com \
1132 --smtp-server="$(pwd)/fake.sendmail" \
1133 funny_name.patch &&
b622d4d1
TR
1134 grep "^From: Füñný Nâmé <odd_?=mail@example.com>" msgtxt1
1135'
1136
4cb46bdd 1137test_expect_success $PREREQ 'utf8 sender is not duplicated' '
f07075c2
MT
1138 clean_fake_sendmail &&
1139 test_commit weird_sender &&
1140 test_when_finished "git reset --hard HEAD^" &&
1141 git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" &&
1142 git format-patch --stdout -1 >funny_name.patch &&
1143 git send-email --from="Füñný Nâmé <odd_?=mail@example.com>" \
03335f22
JH
1144 --to=nobody@example.com \
1145 --smtp-server="$(pwd)/fake.sendmail" \
1146 funny_name.patch &&
f07075c2
MT
1147 grep "^From: " msgtxt1 >msgfrom &&
1148 test_line_count = 1 msgfrom
1149'
1150
62e00690
KM
1151test_expect_success $PREREQ 'sendemail.composeencoding works' '
1152 clean_fake_sendmail &&
1153 git config sendemail.composeencoding iso-8859-1 &&
acd72b56
JH
1154 write_script fake-editor-utf8 <<-\EOF &&
1155 echo "utf8 body: àéìöú" >>"$1"
1156 EOF
03335f22
JH
1157 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
1158 git send-email \
1159 --compose --subject foo \
1160 --from="Example <nobody@example.com>" \
1161 --to=nobody@example.com \
1162 --smtp-server="$(pwd)/fake.sendmail" \
1163 $patches &&
62e00690
KM
1164 grep "^utf8 body" msgtxt1 &&
1165 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1
1166'
1167
1168test_expect_success $PREREQ '--compose-encoding works' '
1169 clean_fake_sendmail &&
acd72b56
JH
1170 write_script fake-editor-utf8 <<-\EOF &&
1171 echo "utf8 body: àéìöú" >>"$1"
1172 EOF
03335f22
JH
1173 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
1174 git send-email \
1175 --compose-encoding iso-8859-1 \
1176 --compose --subject foo \
1177 --from="Example <nobody@example.com>" \
1178 --to=nobody@example.com \
1179 --smtp-server="$(pwd)/fake.sendmail" \
1180 $patches &&
62e00690
KM
1181 grep "^utf8 body" msgtxt1 &&
1182 grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1
1183'
1184
1185test_expect_success $PREREQ '--compose-encoding overrides sendemail.composeencoding' '
1186 clean_fake_sendmail &&
1187 git config sendemail.composeencoding iso-8859-1 &&
acd72b56
JH
1188 write_script fake-editor-utf8 <<-\EOF &&
1189 echo "utf8 body: àéìöú" >>"$1"
1190 EOF
03335f22
JH
1191 GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
1192 git send-email \
1193 --compose-encoding iso-8859-2 \
1194 --compose --subject foo \
1195 --from="Example <nobody@example.com>" \
1196 --to=nobody@example.com \
1197 --smtp-server="$(pwd)/fake.sendmail" \
1198 $patches &&
62e00690
KM
1199 grep "^utf8 body" msgtxt1 &&
1200 grep "^Content-Type: text/plain; charset=iso-8859-2" msgtxt1
1201'
1202
4a47a4dd
KM
1203test_expect_success $PREREQ '--compose-encoding adds correct MIME for subject' '
1204 clean_fake_sendmail &&
03335f22
JH
1205 GIT_EDITOR="\"$(pwd)/fake-editor\"" \
1206 git send-email \
1207 --compose-encoding iso-8859-2 \
1208 --compose --subject utf8-sübjëct \
1209 --from="Example <nobody@example.com>" \
1210 --to=nobody@example.com \
1211 --smtp-server="$(pwd)/fake.sendmail" \
1212 $patches &&
4a47a4dd
KM
1213 grep "^fake edit" msgtxt1 &&
1214 grep "^Subject: =?iso-8859-2?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
1215'
1216
57cd35e6 1217test_expect_success $PREREQ 'detects ambiguous reference/file conflict' '
a881baa2
JS
1218 echo main >main &&
1219 git add main &&
1220 git commit -m"add main" &&
1221 test_must_fail git send-email --dry-run main 2>errors &&
5df9fcf6
PH
1222 grep disambiguate errors
1223'
1224
57cd35e6 1225test_expect_success $PREREQ 'feed two files' '
69f4ce55
JH
1226 rm -fr outdir &&
1227 git format-patch -2 -o outdir &&
c1f2aa45 1228 git send-email \
03335f22
JH
1229 --dry-run \
1230 --from="Example <nobody@example.com>" \
1231 --to=nobody@example.com \
1232 outdir/000?-*.patch 2>errors >out &&
69f4ce55
JH
1233 grep "^Subject: " out >subjects &&
1234 test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." &&
a881baa2 1235 test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add main"
69f4ce55
JH
1236'
1237
57cd35e6 1238test_expect_success $PREREQ 'in-reply-to but no threading' '
aaab4b9f
TR
1239 git send-email \
1240 --dry-run \
1241 --from="Example <nobody@example.com>" \
1242 --to=nobody@example.com \
1243 --in-reply-to="<in-reply-id@example.com>" \
f4714943 1244 --no-thread \
de26f02d
JS
1245 $patches >out &&
1246 grep "In-Reply-To: <in-reply-id@example.com>" out
aaab4b9f
TR
1247'
1248
57cd35e6 1249test_expect_success $PREREQ 'no in-reply-to and no threading' '
32ae8319
MH
1250 git send-email \
1251 --dry-run \
1252 --from="Example <nobody@example.com>" \
1253 --to=nobody@example.com \
f4714943 1254 --no-thread \
2554dd1a 1255 $patches >stdout &&
32ae8319
MH
1256 ! grep "In-Reply-To: " stdout
1257'
1258
57cd35e6 1259test_expect_success $PREREQ 'threading but no chain-reply-to' '
d67114a5
MH
1260 git send-email \
1261 --dry-run \
1262 --from="Example <nobody@example.com>" \
1263 --to=nobody@example.com \
1264 --thread \
f4714943 1265 --no-chain-reply-to \
d67114a5
MH
1266 $patches $patches >stdout &&
1267 grep "In-Reply-To: " stdout
1268'
1269
f9f60d70
RA
1270test_expect_success $PREREQ 'override in-reply-to if no threading' '
1271 git send-email \
1272 --dry-run \
1273 --from="Example <nobody@example.com>" \
1274 --to=nobody@example.com \
1275 --no-thread \
1276 --in-reply-to="override" \
1277 $threaded_patches >stdout &&
1278 grep "In-Reply-To: <override>" stdout
1279'
1280
57cd35e6 1281test_expect_success $PREREQ 'sendemail.to works' '
f434c083
SB
1282 git config --replace-all sendemail.to "Somebody <somebody@ex.com>" &&
1283 git send-email \
1284 --dry-run \
1285 --from="Example <nobody@example.com>" \
2554dd1a 1286 $patches >stdout &&
f434c083
SB
1287 grep "To: Somebody <somebody@ex.com>" stdout
1288'
1289
3ff15040
ÆAB
1290test_expect_success $PREREQ 'setup sendemail.identity' '
1291 git config --replace-all sendemail.to "default@example.com" &&
1292 git config --replace-all sendemail.isp.to "isp@example.com" &&
1293 git config --replace-all sendemail.cloud.to "cloud@example.com"
1294'
1295
1296test_expect_success $PREREQ 'sendemail.identity: reads the correct identity config' '
1297 git -c sendemail.identity=cloud send-email \
1298 --dry-run \
1299 --from="nobody@example.com" \
1300 $patches >stdout &&
1301 grep "To: cloud@example.com" stdout
1302'
1303
1304test_expect_success $PREREQ 'sendemail.identity: identity overrides sendemail.identity' '
1305 git -c sendemail.identity=cloud send-email \
1306 --identity=isp \
1307 --dry-run \
1308 --from="nobody@example.com" \
1309 $patches >stdout &&
1310 grep "To: isp@example.com" stdout
1311'
1312
1313test_expect_success $PREREQ 'sendemail.identity: --no-identity clears previous identity' '
1314 git -c sendemail.identity=cloud send-email \
1315 --no-identity \
1316 --dry-run \
1317 --from="nobody@example.com" \
1318 $patches >stdout &&
1319 grep "To: default@example.com" stdout
1320'
1321
4dc8b1c1 1322test_expect_success $PREREQ 'sendemail.identity: bool identity variable existence overrides' '
3ff15040
ÆAB
1323 git -c sendemail.identity=cloud \
1324 -c sendemail.xmailer=true \
1325 -c sendemail.cloud.xmailer=false \
1326 send-email \
1327 --dry-run \
1328 --from="nobody@example.com" \
1329 $patches >stdout &&
1330 grep "To: cloud@example.com" stdout &&
1331 ! grep "X-Mailer" stdout
1332'
1333
1334test_expect_success $PREREQ 'sendemail.identity: bool variable fallback' '
1335 git -c sendemail.identity=cloud \
1336 -c sendemail.xmailer=false \
1337 send-email \
1338 --dry-run \
1339 --from="nobody@example.com" \
1340 $patches >stdout &&
1341 grep "To: cloud@example.com" stdout &&
1342 ! grep "X-Mailer" stdout
1343'
1344
57cd35e6 1345test_expect_success $PREREQ '--no-to overrides sendemail.to' '
f434c083
SB
1346 git send-email \
1347 --dry-run \
1348 --from="Example <nobody@example.com>" \
1349 --no-to \
1350 --to=nobody@example.com \
2554dd1a 1351 $patches >stdout &&
f434c083
SB
1352 grep "To: nobody@example.com" stdout &&
1353 ! grep "To: Somebody <somebody@ex.com>" stdout
1354'
1355
57cd35e6 1356test_expect_success $PREREQ 'sendemail.cc works' '
f434c083
SB
1357 git config --replace-all sendemail.cc "Somebody <somebody@ex.com>" &&
1358 git send-email \
1359 --dry-run \
1360 --from="Example <nobody@example.com>" \
1361 --to=nobody@example.com \
2554dd1a 1362 $patches >stdout &&
f434c083
SB
1363 grep "Cc: Somebody <somebody@ex.com>" stdout
1364'
1365
57cd35e6 1366test_expect_success $PREREQ '--no-cc overrides sendemail.cc' '
f434c083
SB
1367 git send-email \
1368 --dry-run \
1369 --from="Example <nobody@example.com>" \
1370 --no-cc \
1371 --cc=bodies@example.com \
1372 --to=nobody@example.com \
2554dd1a 1373 $patches >stdout &&
f434c083
SB
1374 grep "Cc: bodies@example.com" stdout &&
1375 ! grep "Cc: Somebody <somebody@ex.com>" stdout
1376'
1377
57cd35e6 1378test_expect_success $PREREQ 'sendemail.bcc works' '
f434c083
SB
1379 git config --replace-all sendemail.bcc "Other <other@ex.com>" &&
1380 git send-email \
1381 --dry-run \
1382 --from="Example <nobody@example.com>" \
1383 --to=nobody@example.com \
1384 --smtp-server relay.example.com \
2554dd1a 1385 $patches >stdout &&
f434c083
SB
1386 grep "RCPT TO:<other@ex.com>" stdout
1387'
1388
57cd35e6 1389test_expect_success $PREREQ '--no-bcc overrides sendemail.bcc' '
f434c083
SB
1390 git send-email \
1391 --dry-run \
1392 --from="Example <nobody@example.com>" \
1393 --no-bcc \
1394 --bcc=bodies@example.com \
1395 --to=nobody@example.com \
1396 --smtp-server relay.example.com \
2554dd1a 1397 $patches >stdout &&
f434c083
SB
1398 grep "RCPT TO:<bodies@example.com>" stdout &&
1399 ! grep "RCPT TO:<other@ex.com>" stdout
1400'
1401
21802cd3 1402test_expect_success $PREREQ 'patches To headers are used by default' '
bdf20f5e 1403 patch=$(git format-patch -1 --to="bodies@example.com") &&
21802cd3
SB
1404 test_when_finished "rm $patch" &&
1405 git send-email \
1406 --dry-run \
1407 --from="Example <nobody@example.com>" \
1408 --smtp-server relay.example.com \
1409 $patch >stdout &&
1410 grep "RCPT TO:<bodies@example.com>" stdout
1411'
1412
1413test_expect_success $PREREQ 'patches To headers are appended to' '
bdf20f5e 1414 patch=$(git format-patch -1 --to="bodies@example.com") &&
21802cd3
SB
1415 test_when_finished "rm $patch" &&
1416 git send-email \
1417 --dry-run \
1418 --from="Example <nobody@example.com>" \
1419 --to=nobody@example.com \
1420 --smtp-server relay.example.com \
1421 $patch >stdout &&
1422 grep "RCPT TO:<bodies@example.com>" stdout &&
1423 grep "RCPT TO:<nobody@example.com>" stdout
1424'
1425
3c3bb51c 1426test_expect_success $PREREQ 'To headers from files reset each patch' '
bdf20f5e
EP
1427 patch1=$(git format-patch -1 --to="bodies@example.com") &&
1428 patch2=$(git format-patch -1 --to="other@example.com" HEAD~) &&
3c3bb51c
SB
1429 test_when_finished "rm $patch1 && rm $patch2" &&
1430 git send-email \
1431 --dry-run \
1432 --from="Example <nobody@example.com>" \
1433 --to="nobody@example.com" \
1434 --smtp-server relay.example.com \
1435 $patch1 $patch2 >stdout &&
1436 test $(grep -c "RCPT TO:<bodies@example.com>" stdout) = 1 &&
1437 test $(grep -c "RCPT TO:<nobody@example.com>" stdout) = 2 &&
1438 test $(grep -c "RCPT TO:<other@example.com>" stdout) = 1
1439'
1440
f9444147 1441test_expect_success $PREREQ 'setup expect' '
0720a51b 1442cat >email-using-8bit <<\EOF
3cae7e5b
TR
1443From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1444Message-Id: <bogus-message-id@example.com>
1445From: author@example.com
1446Date: Sat, 12 Jun 2010 15:53:58 +0200
1447Subject: subject goes here
1448
1449Dieser deutsche Text enthält einen Umlaut!
1450EOF
f9444147 1451'
3cae7e5b 1452
5637d857 1453test_expect_success $PREREQ 'setup expect' '
0720a51b 1454 echo "Subject: subject goes here" >expected
5637d857
KM
1455'
1456
1457test_expect_success $PREREQ 'ASCII subject is not RFC2047 quoted' '
1458 clean_fake_sendmail &&
1459 echo bogus |
1460 git send-email --from=author@example.com --to=nobody@example.com \
1461 --smtp-server="$(pwd)/fake.sendmail" \
1462 --8bit-encoding=UTF-8 \
1463 email-using-8bit >stdout &&
1464 grep "Subject" msgtxt1 >actual &&
1465 test_cmp expected actual
1466'
1467
f9444147 1468test_expect_success $PREREQ 'setup expect' '
0720a51b
JH
1469 cat >content-type-decl <<-\EOF
1470 MIME-Version: 1.0
1471 Content-Type: text/plain; charset=UTF-8
1472 Content-Transfer-Encoding: 8bit
1473 EOF
f9444147 1474'
3cae7e5b 1475
57cd35e6 1476test_expect_success $PREREQ 'asks about and fixes 8bit encodings' '
3cae7e5b
TR
1477 clean_fake_sendmail &&
1478 echo |
1479 git send-email --from=author@example.com --to=nobody@example.com \
1480 --smtp-server="$(pwd)/fake.sendmail" \
1481 email-using-8bit >stdout &&
1482 grep "do not declare a Content-Transfer-Encoding" stdout &&
1483 grep email-using-8bit stdout &&
1484 grep "Which 8bit encoding" stdout &&
31832862 1485 egrep "Content|MIME" msgtxt1 >actual &&
9c5b2fab 1486 test_cmp content-type-decl actual
3cae7e5b
TR
1487'
1488
57cd35e6 1489test_expect_success $PREREQ 'sendemail.8bitEncoding works' '
3cae7e5b
TR
1490 clean_fake_sendmail &&
1491 git config sendemail.assume8bitEncoding UTF-8 &&
1492 echo bogus |
1493 git send-email --from=author@example.com --to=nobody@example.com \
1494 --smtp-server="$(pwd)/fake.sendmail" \
1495 email-using-8bit >stdout &&
31832862 1496 egrep "Content|MIME" msgtxt1 >actual &&
9c5b2fab 1497 test_cmp content-type-decl actual
3cae7e5b
TR
1498'
1499
57cd35e6 1500test_expect_success $PREREQ '--8bit-encoding overrides sendemail.8bitEncoding' '
3cae7e5b
TR
1501 clean_fake_sendmail &&
1502 git config sendemail.assume8bitEncoding "bogus too" &&
1503 echo bogus |
1504 git send-email --from=author@example.com --to=nobody@example.com \
1505 --smtp-server="$(pwd)/fake.sendmail" \
1506 --8bit-encoding=UTF-8 \
1507 email-using-8bit >stdout &&
31832862 1508 egrep "Content|MIME" msgtxt1 >actual &&
9c5b2fab 1509 test_cmp content-type-decl actual
3cae7e5b
TR
1510'
1511
f9444147 1512test_expect_success $PREREQ 'setup expect' '
0720a51b
JH
1513 cat >email-using-8bit <<-\EOF
1514 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1515 Message-Id: <bogus-message-id@example.com>
1516 From: author@example.com
1517 Date: Sat, 12 Jun 2010 15:53:58 +0200
1518 Subject: Dieser Betreff enthält auch einen Umlaut!
1519
1520 Nothing to see here.
1521 EOF
f9444147 1522'
3cae7e5b 1523
f9444147 1524test_expect_success $PREREQ 'setup expect' '
0720a51b
JH
1525 cat >expected <<-\EOF
1526 Subject: =?UTF-8?q?Dieser=20Betreff=20enth=C3=A4lt=20auch=20einen=20Umlaut!?=
1527 EOF
f9444147 1528'
3cae7e5b 1529
57cd35e6 1530test_expect_success $PREREQ '--8bit-encoding also treats subject' '
3cae7e5b
TR
1531 clean_fake_sendmail &&
1532 echo bogus |
1533 git send-email --from=author@example.com --to=nobody@example.com \
1534 --smtp-server="$(pwd)/fake.sendmail" \
1535 --8bit-encoding=UTF-8 \
1536 email-using-8bit >stdout &&
1537 grep "Subject" msgtxt1 >actual &&
1538 test_cmp expected actual
1539'
1540
8d814084 1541test_expect_success $PREREQ 'setup expect' '
0720a51b
JH
1542 cat >email-using-8bit <<-\EOF
1543 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1544 Message-Id: <bogus-message-id@example.com>
1545 From: A U Thor <author@example.com>
1546 Date: Sat, 12 Jun 2010 15:53:58 +0200
1547 Content-Type: text/plain; charset=UTF-8
1548 Subject: Nothing to see here.
1549
1550 Dieser Betreff enthält auch einen Umlaut!
1551 EOF
8d814084
PB
1552'
1553
a8aea5db 1554test_expect_success $PREREQ '--transfer-encoding overrides sendemail.transferEncoding' '
8d814084 1555 clean_fake_sendmail &&
a8aea5db
ÆAB
1556 test_must_fail git -c sendemail.transferEncoding=8bit \
1557 send-email \
03335f22
JH
1558 --transfer-encoding=7bit \
1559 --smtp-server="$(pwd)/fake.sendmail" \
1560 email-using-8bit \
1561 2>errors >out &&
8d814084
PB
1562 grep "cannot send message as 7bit" errors &&
1563 test -z "$(ls msgtxt*)"
1564'
1565
a8aea5db 1566test_expect_success $PREREQ 'sendemail.transferEncoding via config' '
8d814084 1567 clean_fake_sendmail &&
a8aea5db
ÆAB
1568 test_must_fail git -c sendemail.transferEncoding=7bit \
1569 send-email \
03335f22
JH
1570 --smtp-server="$(pwd)/fake.sendmail" \
1571 email-using-8bit \
1572 2>errors >out &&
8d814084
PB
1573 grep "cannot send message as 7bit" errors &&
1574 test -z "$(ls msgtxt*)"
1575'
1576
a8aea5db 1577test_expect_success $PREREQ 'sendemail.transferEncoding via cli' '
8d814084 1578 clean_fake_sendmail &&
a8aea5db
ÆAB
1579 test_must_fail git send-email \
1580 --transfer-encoding=7bit \
03335f22
JH
1581 --smtp-server="$(pwd)/fake.sendmail" \
1582 email-using-8bit \
1583 2>errors >out &&
a8aea5db
ÆAB
1584 grep "cannot send message as 7bit" errors &&
1585 test -z "$(ls msgtxt*)"
8d814084
PB
1586'
1587
1588test_expect_success $PREREQ 'setup expect' '
0720a51b
JH
1589 cat >expected <<-\EOF
1590 Dieser Betreff enth=C3=A4lt auch einen Umlaut!
1591 EOF
8d814084
PB
1592'
1593
1594test_expect_success $PREREQ '8-bit and sendemail.transferencoding=quoted-printable' '
1595 clean_fake_sendmail &&
1596 git send-email \
03335f22
JH
1597 --transfer-encoding=quoted-printable \
1598 --smtp-server="$(pwd)/fake.sendmail" \
1599 email-using-8bit \
1600 2>errors >out &&
c76b84a1 1601 sed "1,/^$/d" msgtxt1 >actual &&
8d814084
PB
1602 test_cmp expected actual
1603'
1604
1605test_expect_success $PREREQ 'setup expect' '
0720a51b
JH
1606 cat >expected <<-\EOF
1607 RGllc2VyIEJldHJlZmYgZW50aMOkbHQgYXVjaCBlaW5lbiBVbWxhdXQhCg==
1608 EOF
8d814084
PB
1609'
1610
1611test_expect_success $PREREQ '8-bit and sendemail.transferencoding=base64' '
1612 clean_fake_sendmail &&
1613 git send-email \
03335f22
JH
1614 --transfer-encoding=base64 \
1615 --smtp-server="$(pwd)/fake.sendmail" \
1616 email-using-8bit \
1617 2>errors >out &&
c76b84a1 1618 sed "1,/^$/d" msgtxt1 >actual &&
8d814084
PB
1619 test_cmp expected actual
1620'
1621
1622test_expect_success $PREREQ 'setup expect' '
0720a51b
JH
1623 cat >email-using-qp <<-\EOF
1624 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1625 Message-Id: <bogus-message-id@example.com>
1626 From: A U Thor <author@example.com>
1627 Date: Sat, 12 Jun 2010 15:53:58 +0200
1628 MIME-Version: 1.0
1629 Content-Transfer-Encoding: quoted-printable
1630 Content-Type: text/plain; charset=UTF-8
1631 Subject: Nothing to see here.
8d814084 1632
0720a51b
JH
1633 Dieser Betreff enth=C3=A4lt auch einen Umlaut!
1634 EOF
8d814084
PB
1635'
1636
1637test_expect_success $PREREQ 'convert from quoted-printable to base64' '
1638 clean_fake_sendmail &&
1639 git send-email \
03335f22
JH
1640 --transfer-encoding=base64 \
1641 --smtp-server="$(pwd)/fake.sendmail" \
1642 email-using-qp \
1643 2>errors >out &&
c76b84a1 1644 sed "1,/^$/d" msgtxt1 >actual &&
8d814084
PB
1645 test_cmp expected actual
1646'
1647
1648test_expect_success $PREREQ 'setup expect' "
ee756a81 1649tr -d '\\015' | tr '%' '\\015' >email-using-crlf <<EOF
8d814084
PB
1650From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1651Message-Id: <bogus-message-id@example.com>
1652From: A U Thor <author@example.com>
1653Date: Sat, 12 Jun 2010 15:53:58 +0200
1654Content-Type: text/plain; charset=UTF-8
1655Subject: Nothing to see here.
1656
1657Look, I have a CRLF and an = sign!%
1658EOF
1659"
1660
1661test_expect_success $PREREQ 'setup expect' '
0720a51b
JH
1662 cat >expected <<-\EOF
1663 Look, I have a CRLF and an =3D sign!=0D
1664 EOF
8d814084
PB
1665'
1666
1667test_expect_success $PREREQ 'CRLF and sendemail.transferencoding=quoted-printable' '
1668 clean_fake_sendmail &&
1669 git send-email \
03335f22
JH
1670 --transfer-encoding=quoted-printable \
1671 --smtp-server="$(pwd)/fake.sendmail" \
1672 email-using-crlf \
1673 2>errors >out &&
c76b84a1 1674 sed "1,/^$/d" msgtxt1 >actual &&
8d814084
PB
1675 test_cmp expected actual
1676'
1677
1678test_expect_success $PREREQ 'setup expect' '
0720a51b
JH
1679 cat >expected <<-\EOF
1680 TG9vaywgSSBoYXZlIGEgQ1JMRiBhbmQgYW4gPSBzaWduIQ0K
1681 EOF
8d814084
PB
1682'
1683
1684test_expect_success $PREREQ 'CRLF and sendemail.transferencoding=base64' '
1685 clean_fake_sendmail &&
1686 git send-email \
03335f22
JH
1687 --transfer-encoding=base64 \
1688 --smtp-server="$(pwd)/fake.sendmail" \
1689 email-using-crlf \
1690 2>errors >out &&
c76b84a1 1691 sed "1,/^$/d" msgtxt1 >actual &&
8d814084
PB
1692 test_cmp expected actual
1693'
1694
1695
a03bc5b6
TR
1696# Note that the patches in this test are deliberately out of order; we
1697# want to make sure it works even if the cover-letter is not in the
1698# first mail.
57da2042 1699test_expect_success $PREREQ 'refusing to send cover letter template' '
a03bc5b6
TR
1700 clean_fake_sendmail &&
1701 rm -fr outdir &&
1702 git format-patch --cover-letter -2 -o outdir &&
1703 test_must_fail git send-email \
03335f22
JH
1704 --from="Example <nobody@example.com>" \
1705 --to=nobody@example.com \
1706 --smtp-server="$(pwd)/fake.sendmail" \
1707 outdir/0002-*.patch \
1708 outdir/0000-*.patch \
1709 outdir/0001-*.patch \
1710 2>errors >out &&
a03bc5b6
TR
1711 grep "SUBJECT HERE" errors &&
1712 test -z "$(ls msgtxt*)"
1713'
1714
57da2042 1715test_expect_success $PREREQ '--force sends cover letter template anyway' '
a03bc5b6
TR
1716 clean_fake_sendmail &&
1717 rm -fr outdir &&
1718 git format-patch --cover-letter -2 -o outdir &&
1719 git send-email \
03335f22
JH
1720 --force \
1721 --from="Example <nobody@example.com>" \
1722 --to=nobody@example.com \
1723 --smtp-server="$(pwd)/fake.sendmail" \
1724 outdir/0002-*.patch \
1725 outdir/0000-*.patch \
1726 outdir/0001-*.patch \
1727 2>errors >out &&
a03bc5b6
TR
1728 ! grep "SUBJECT HERE" errors &&
1729 test -n "$(ls msgtxt*)"
1730'
1731
8ccc4e42
MT
1732test_cover_addresses () {
1733 header="$1"
1734 shift
1735 clean_fake_sendmail &&
1736 rm -fr outdir &&
1737 git format-patch --cover-letter -2 -o outdir &&
bdf20f5e 1738 cover=$(echo outdir/0000-*.patch) &&
8ccc4e42 1739 mv $cover cover-to-edit.patch &&
35ec002c 1740 perl -pe "s/^From:/$header: extra\@address.com\nFrom:/" cover-to-edit.patch >"$cover" &&
8ccc4e42 1741 git send-email \
03335f22
JH
1742 --force \
1743 --from="Example <nobody@example.com>" \
1744 --no-to --no-cc \
1745 "$@" \
1746 --smtp-server="$(pwd)/fake.sendmail" \
1747 outdir/0000-*.patch \
1748 outdir/0001-*.patch \
1749 outdir/0002-*.patch \
1750 2>errors >out &&
8ccc4e42
MT
1751 grep "^$header: extra@address.com" msgtxt1 >to1 &&
1752 grep "^$header: extra@address.com" msgtxt2 >to2 &&
1753 grep "^$header: extra@address.com" msgtxt3 >to3 &&
1754 test_line_count = 1 to1 &&
1755 test_line_count = 1 to2 &&
1756 test_line_count = 1 to3
1757}
1758
1759test_expect_success $PREREQ 'to-cover adds To to all mail' '
1760 test_cover_addresses "To" --to-cover
1761'
1762
1763test_expect_success $PREREQ 'cc-cover adds Cc to all mail' '
1764 test_cover_addresses "Cc" --cc-cover
1765'
1766
1767test_expect_success $PREREQ 'tocover adds To to all mail' '
1768 test_config sendemail.tocover true &&
1769 test_cover_addresses "To"
1770'
1771
1772test_expect_success $PREREQ 'cccover adds Cc to all mail' '
1773 test_config sendemail.cccover true &&
1774 test_cover_addresses "Cc"
1775'
1776
2c510f21
EW
1777test_expect_success $PREREQ 'escaped quotes in sendemail.aliasfiletype=mutt' '
1778 clean_fake_sendmail &&
1779 echo "alias sbd \\\"Dot U. Sir\\\" <somebody@example.org>" >.mutt &&
1780 git config --replace-all sendemail.aliasesfile "$(pwd)/.mutt" &&
1781 git config sendemail.aliasfiletype mutt &&
1782 git send-email \
1783 --from="Example <nobody@example.com>" \
1784 --to=sbd \
1785 --smtp-server="$(pwd)/fake.sendmail" \
1786 outdir/0001-*.patch \
1787 2>errors >out &&
1788 grep "^!somebody@example\.org!$" commandline1 &&
1789 grep -F "To: \"Dot U. Sir\" <somebody@example.org>" out
1790'
1791
463b0ea2
CS
1792test_expect_success $PREREQ 'sendemail.aliasfiletype=mailrc' '
1793 clean_fake_sendmail &&
1794 echo "alias sbd somebody@example.org" >.mailrc &&
1795 git config --replace-all sendemail.aliasesfile "$(pwd)/.mailrc" &&
1796 git config sendemail.aliasfiletype mailrc &&
1797 git send-email \
03335f22
JH
1798 --from="Example <nobody@example.com>" \
1799 --to=sbd \
1800 --smtp-server="$(pwd)/fake.sendmail" \
1801 outdir/0001-*.patch \
1802 2>errors >out &&
463b0ea2
CS
1803 grep "^!somebody@example\.org!$" commandline1
1804'
1805
1806test_expect_success $PREREQ 'sendemail.aliasfile=~/.mailrc' '
1807 clean_fake_sendmail &&
587089c1 1808 echo "alias sbd someone@example.org" >"$HOME/.mailrc" &&
463b0ea2
CS
1809 git config --replace-all sendemail.aliasesfile "~/.mailrc" &&
1810 git config sendemail.aliasfiletype mailrc &&
1811 git send-email \
03335f22
JH
1812 --from="Example <nobody@example.com>" \
1813 --to=sbd \
1814 --smtp-server="$(pwd)/fake.sendmail" \
1815 outdir/0001-*.patch \
1816 2>errors >out &&
463b0ea2
CS
1817 grep "^!someone@example\.org!$" commandline1
1818'
1819
17b7a832
JK
1820test_dump_aliases () {
1821 msg="$1" && shift &&
1822 filetype="$1" && shift &&
1823 printf '%s\n' "$@" >expect &&
1824 cat >.tmp-email-aliases &&
1825
1826 test_expect_success $PREREQ "$msg" '
1827 clean_fake_sendmail && rm -fr outdir &&
1828 git config --replace-all sendemail.aliasesfile \
1829 "$(pwd)/.tmp-email-aliases" &&
1830 git config sendemail.aliasfiletype "$filetype" &&
1831 git send-email --dump-aliases 2>errors >actual &&
1832 test_cmp expect actual
1833 '
1834}
1835
1836test_dump_aliases '--dump-aliases sendmail format' \
1837 'sendmail' \
1838 'abgroup' \
1839 'alice' \
1840 'bcgrp' \
1841 'bob' \
1842 'chloe' <<-\EOF
1843 alice: Alice W Land <awol@example.com>
1844 bob: Robert Bobbyton <bob@example.com>
1845 chloe: chloe@example.com
1846 abgroup: alice, bob
1847 bcgrp: bob, chloe, Other <o@example.com>
1848 EOF
1849
1850test_dump_aliases '--dump-aliases mutt format' \
1851 'mutt' \
1852 'alice' \
1853 'bob' \
1854 'chloe' \
1855 'donald' <<-\EOF
1856 alias alice Alice W Land <awol@example.com>
1857 alias donald Donald C Carlton <donc@example.com>
1858 alias bob Robert Bobbyton <bob@example.com>
1859 alias chloe chloe@example.com
1860 EOF
1861
1862test_dump_aliases '--dump-aliases mailrc format' \
1863 'mailrc' \
1864 'alice' \
1865 'bob' \
1866 'chloe' \
1867 'eve' <<-\EOF
1868 alias alice Alice W Land <awol@example.com>
1869 alias eve Eve <eve@example.com>
1870 alias bob Robert Bobbyton <bob@example.com>
1871 alias chloe chloe@example.com
1872 EOF
1873
1874test_dump_aliases '--dump-aliases pine format' \
1875 'pine' \
1876 'alice' \
1877 'bob' \
1878 'chloe' \
1879 'eve' <<-\EOF
1880 alice Alice W Land <awol@example.com>
1881 eve Eve <eve@example.com>
1882 bob Robert Bobbyton <bob@example.com>
1883 chloe chloe@example.com
1884 EOF
1885
1886test_dump_aliases '--dump-aliases gnus format' \
1887 'gnus' \
1888 'alice' \
1889 'bob' \
1890 'chloe' \
1891 'eve' <<-\EOF
1892 (define-mail-alias "alice" "awol@example.com")
1893 (define-mail-alias "eve" "eve@example.com")
1894 (define-mail-alias "bob" "bob@example.com")
1895 (define-mail-alias "chloe" "chloe@example.com")
1896 EOF
1897
1898test_expect_success '--dump-aliases must be used alone' '
1899 test_must_fail git send-email --dump-aliases --to=janice@example.com -1 refs/heads/accounting
1900'
1901
3ff15040
ÆAB
1902test_expect_success $PREREQ 'aliases and sendemail.identity' '
1903 test_must_fail git \
1904 -c sendemail.identity=cloud \
1905 -c sendemail.aliasesfile=default-aliases \
1906 -c sendemail.cloud.aliasesfile=cloud-aliases \
1907 send-email -1 2>stderr &&
1908 test_i18ngrep "cloud-aliases" stderr
1909'
1910
514554cf
ES
1911test_sendmail_aliases () {
1912 msg="$1" && shift &&
1913 expect="$@" &&
1914 cat >.tmp-email-aliases &&
1915
1916 test_expect_success $PREREQ "$msg" '
1917 clean_fake_sendmail && rm -fr outdir &&
1918 git format-patch -1 -o outdir &&
1919 git config --replace-all sendemail.aliasesfile \
1920 "$(pwd)/.tmp-email-aliases" &&
1921 git config sendemail.aliasfiletype sendmail &&
1922 git send-email \
1923 --from="Example <nobody@example.com>" \
1924 --to=alice --to=bcgrp \
1925 --smtp-server="$(pwd)/fake.sendmail" \
1926 outdir/0001-*.patch \
1927 2>errors >out &&
1928 for i in $expect
1929 do
1930 grep "^!$i!$" commandline1 || return 1
1931 done
1932 '
1933}
1934
1935test_sendmail_aliases 'sendemail.aliasfiletype=sendmail' \
1936 'awol@example\.com' \
1937 'bob@example\.com' \
1938 'chloe@example\.com' \
1939 'o@example\.com' <<-\EOF
3169e06d
AH
1940 alice: Alice W Land <awol@example.com>
1941 bob: Robert Bobbyton <bob@example.com>
1942 # this is a comment
1943 # this is also a comment
1944 chloe: chloe@example.com
1945 abgroup: alice, bob
1946 bcgrp: bob, chloe, Other <o@example.com>
1947 EOF
3169e06d 1948
6be02640
ES
1949test_sendmail_aliases 'sendmail aliases line folding' \
1950 alice1 \
1951 bob1 bob2 \
1952 chuck1 chuck2 \
1953 darla1 darla2 darla3 \
1954 elton1 elton2 elton3 \
1955 fred1 fred2 \
1956 greg1 <<-\EOF
1957 alice: alice1
1958 bob: bob1,\
1959 bob2
1960 chuck: chuck1,
1961 chuck2
1962 darla: darla1,\
1963 darla2,
1964 darla3
1965 elton: elton1,
1966 elton2,\
1967 elton3
1968 fred: fred1,\
1969 fred2
1970 greg: greg1
1971 bcgrp: bob, chuck, darla, elton, fred, greg
1972 EOF
1973
1974test_sendmail_aliases 'sendmail aliases tolerate bogus line folding' \
1975 alice1 bob1 <<-\EOF
1976 alice: alice1
1977 bcgrp: bob1\
1978 EOF
1979
1980test_sendmail_aliases 'sendmail aliases empty' alice bcgrp <<-\EOF
1981 EOF
1982
f6f79e5e
RL
1983test_expect_success $PREREQ 'alias support in To header' '
1984 clean_fake_sendmail &&
1985 echo "alias sbd someone@example.org" >.mailrc &&
1986 test_config sendemail.aliasesfile ".mailrc" &&
1987 test_config sendemail.aliasfiletype mailrc &&
1988 git format-patch --stdout -1 --to=sbd >aliased.patch &&
1989 git send-email \
1990 --from="Example <nobody@example.com>" \
1991 --smtp-server="$(pwd)/fake.sendmail" \
1992 aliased.patch \
1993 2>errors >out &&
1994 grep "^!someone@example\.org!$" commandline1
1995'
1996
1997test_expect_success $PREREQ 'alias support in Cc header' '
1998 clean_fake_sendmail &&
1999 echo "alias sbd someone@example.org" >.mailrc &&
2000 test_config sendemail.aliasesfile ".mailrc" &&
2001 test_config sendemail.aliasfiletype mailrc &&
2002 git format-patch --stdout -1 --cc=sbd >aliased.patch &&
2003 git send-email \
2004 --from="Example <nobody@example.com>" \
2005 --smtp-server="$(pwd)/fake.sendmail" \
2006 aliased.patch \
2007 2>errors >out &&
2008 grep "^!someone@example\.org!$" commandline1
2009'
2010
2011test_expect_success $PREREQ 'tocmd works with aliases' '
2012 clean_fake_sendmail &&
2013 echo "alias sbd someone@example.org" >.mailrc &&
2014 test_config sendemail.aliasesfile ".mailrc" &&
2015 test_config sendemail.aliasfiletype mailrc &&
2016 git format-patch --stdout -1 >tocmd.patch &&
2017 echo tocmd--sbd >>tocmd.patch &&
2018 git send-email \
2019 --from="Example <nobody@example.com>" \
2020 --to-cmd=./tocmd-sed \
2021 --smtp-server="$(pwd)/fake.sendmail" \
2022 tocmd.patch \
2023 2>errors >out &&
2024 grep "^!someone@example\.org!$" commandline1
2025'
2026
2027test_expect_success $PREREQ 'cccmd works with aliases' '
2028 clean_fake_sendmail &&
2029 echo "alias sbd someone@example.org" >.mailrc &&
2030 test_config sendemail.aliasesfile ".mailrc" &&
2031 test_config sendemail.aliasfiletype mailrc &&
2032 git format-patch --stdout -1 >cccmd.patch &&
2033 echo cccmd--sbd >>cccmd.patch &&
2034 git send-email \
2035 --from="Example <nobody@example.com>" \
2036 --cc-cmd=./cccmd-sed \
2037 --smtp-server="$(pwd)/fake.sendmail" \
2038 cccmd.patch \
2039 2>errors >out &&
2040 grep "^!someone@example\.org!$" commandline1
2041'
2042
2cf770f5
LH
2043do_xmailer_test () {
2044 expected=$1 params=$2 &&
2045 git format-patch -1 &&
2046 git send-email \
2047 --from="Example <nobody@example.com>" \
2048 --to=someone@example.com \
2049 --smtp-server="$(pwd)/fake.sendmail" \
2050 $params \
2051 0001-*.patch \
2052 2>errors >out &&
2053 { grep '^X-Mailer:' out || :; } >mailer &&
2054 test_line_count = $expected mailer
2055}
2056
2057test_expect_success $PREREQ '--[no-]xmailer without any configuration' '
2058 do_xmailer_test 1 "--xmailer" &&
2059 do_xmailer_test 0 "--no-xmailer"
2060'
2061
2062test_expect_success $PREREQ '--[no-]xmailer with sendemail.xmailer=true' '
2063 test_config sendemail.xmailer true &&
2064 do_xmailer_test 1 "" &&
2065 do_xmailer_test 0 "--no-xmailer" &&
2066 do_xmailer_test 1 "--xmailer"
2067'
2068
2069test_expect_success $PREREQ '--[no-]xmailer with sendemail.xmailer=false' '
2070 test_config sendemail.xmailer false &&
2071 do_xmailer_test 0 "" &&
2072 do_xmailer_test 0 "--no-xmailer" &&
2073 do_xmailer_test 1 "--xmailer"
2074'
2075
b1c8a11c
RL
2076test_expect_success $PREREQ 'setup expected-list' '
2077 git send-email \
2078 --dry-run \
2079 --from="Example <from@example.com>" \
2080 --to="To 1 <to1@example.com>" \
2081 --to="to2@example.com" \
2082 --to="to3@example.com" \
2083 --cc="Cc 1 <cc1@example.com>" \
2084 --cc="Cc2 <cc2@example.com>" \
2085 --bcc="bcc1@example.com" \
2086 --bcc="bcc2@example.com" \
a881baa2 2087 0001-add-main.patch | replace_variable_fields \
b1c8a11c
RL
2088 >expected-list
2089'
2090
2091test_expect_success $PREREQ 'use email list in --cc --to and --bcc' '
2092 git send-email \
2093 --dry-run \
2094 --from="Example <from@example.com>" \
2095 --to="To 1 <to1@example.com>, to2@example.com" \
2096 --to="to3@example.com" \
2097 --cc="Cc 1 <cc1@example.com>, Cc2 <cc2@example.com>" \
2098 --bcc="bcc1@example.com, bcc2@example.com" \
a881baa2 2099 0001-add-main.patch | replace_variable_fields \
b1c8a11c
RL
2100 >actual-list &&
2101 test_cmp expected-list actual-list
2102'
2103
2104test_expect_success $PREREQ 'aliases work with email list' '
2105 echo "alias to2 to2@example.com" >.mutt &&
2106 echo "alias cc1 Cc 1 <cc1@example.com>" >>.mutt &&
2107 test_config sendemail.aliasesfile ".mutt" &&
2108 test_config sendemail.aliasfiletype mutt &&
2109 git send-email \
2110 --dry-run \
2111 --from="Example <from@example.com>" \
2112 --to="To 1 <to1@example.com>, to2, to3@example.com" \
2113 --cc="cc1, Cc2 <cc2@example.com>" \
2114 --bcc="bcc1@example.com, bcc2@example.com" \
a881baa2 2115 0001-add-main.patch | replace_variable_fields \
b1c8a11c
RL
2116 >actual-list &&
2117 test_cmp expected-list actual-list
2118'
2119
fa5b1aa9
RL
2120test_expect_success $PREREQ 'leading and trailing whitespaces are removed' '
2121 echo "alias to2 to2@example.com" >.mutt &&
2122 echo "alias cc1 Cc 1 <cc1@example.com>" >>.mutt &&
2123 test_config sendemail.aliasesfile ".mutt" &&
2124 test_config sendemail.aliasfiletype mutt &&
2125 TO1=$(echo "QTo 1 <to1@example.com>" | q_to_tab) &&
2126 TO2=$(echo "QZto2" | qz_to_tab_space) &&
2127 CC1=$(echo "cc1" | append_cr) &&
c64368e3 2128 BCC1=$(echo " bcc1@example.com Q" | q_to_nul) &&
fa5b1aa9
RL
2129 git send-email \
2130 --dry-run \
2131 --from=" Example <from@example.com>" \
2132 --to="$TO1" \
2133 --to="$TO2" \
2134 --to=" to3@example.com " \
2135 --cc="$CC1" \
2136 --cc="Cc2 <cc2@example.com>" \
2137 --bcc="$BCC1" \
2138 --bcc="bcc2@example.com" \
a881baa2 2139 0001-add-main.patch | replace_variable_fields \
fa5b1aa9
RL
2140 >actual-list &&
2141 test_cmp expected-list actual-list
2142'
2143
6489660b
JT
2144test_expect_success $PREREQ 'invoke hook' '
2145 mkdir -p .git/hooks &&
2146
2147 write_script .git/hooks/sendemail-validate <<-\EOF &&
2148 # test that we have the correct environment variable, pwd, and
2149 # argument
2150 case "$GIT_DIR" in
2151 *.git)
2152 true
2153 ;;
2154 *)
2155 false
2156 ;;
2157 esac &&
a881baa2
JS
2158 test -f 0001-add-main.patch &&
2159 grep "add main" "$1"
6489660b
JT
2160 EOF
2161
2162 mkdir subdir &&
2163 (
2164 # Test that it works even if we are not at the root of the
2165 # working tree
2166 cd subdir &&
2167 git send-email \
2168 --from="Example <nobody@example.com>" \
2169 --to=nobody@example.com \
2170 --smtp-server="$(pwd)/../fake.sendmail" \
a881baa2 2171 ../0001-add-main.patch &&
6489660b
JT
2172
2173 # Verify error message when a patch is rejected by the hook
a881baa2 2174 sed -e "s/add main/x/" ../0001-add-main.patch >../another.patch &&
be8c48d4 2175 test_must_fail git send-email \
6489660b
JT
2176 --from="Example <nobody@example.com>" \
2177 --to=nobody@example.com \
2178 --smtp-server="$(pwd)/../fake.sendmail" \
be8c48d4 2179 ../another.patch 2>err &&
6489660b
JT
2180 test_i18ngrep "rejected by sendemail-validate hook" err
2181 )
2182'
2183
177409e5
JT
2184test_expect_success $PREREQ 'test that send-email works outside a repo' '
2185 nongit git send-email \
2186 --from="Example <nobody@example.com>" \
2187 --to=nobody@example.com \
2188 --smtp-server="$(pwd)/fake.sendmail" \
a881baa2 2189 "$(pwd)/0001-add-main.patch"
177409e5
JT
2190'
2191
dd84e528
DD
2192test_expect_success $PREREQ 'test that sendmail config is rejected' '
2193 test_config sendmail.program sendmail &&
2194 test_must_fail git send-email \
2195 --from="Example <nobody@example.com>" \
2196 --to=nobody@example.com \
2197 --smtp-server="$(pwd)/fake.sendmail" \
2198 HEAD^ 2>err &&
2199 test_i18ngrep "found configuration options for '"'"sendmail"'"'" err
2200'
2201
2202test_expect_success $PREREQ 'test that sendmail config rejection is specific' '
2203 test_config resendmail.program sendmail &&
2204 git send-email \
2205 --from="Example <nobody@example.com>" \
2206 --to=nobody@example.com \
2207 --smtp-server="$(pwd)/fake.sendmail" \
2208 HEAD^
2209'
2210
2211test_expect_success $PREREQ 'test forbidSendmailVariables behavior override' '
2212 test_config sendmail.program sendmail &&
2213 test_config sendemail.forbidSendmailVariables false &&
2214 git send-email \
2215 --from="Example <nobody@example.com>" \
2216 --to=nobody@example.com \
2217 --smtp-server="$(pwd)/fake.sendmail" \
2218 HEAD^
2219'
2220
ce903018 2221test_done