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