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