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