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