]>
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 | |
6d34a2ba JK |
34 | clean_fake_sendmail() { |
35 | rm -f commandline* msgtxt* | |
36 | } | |
37 | ||
57cd35e6 | 38 | test_expect_success $PREREQ 'Extract patches' ' |
03335f22 | 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 | $@ \ | |
52 | $patches > stdout && | |
53 | test_must_fail grep "Send this email" stdout && | |
54 | > no_confirm_okay | |
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' ' |
2186d566 JH |
91 | cat >expected <<\EOF |
92 | !nobody@example.com! | |
93 | !author@example.com! | |
5012699d JS |
94 | !one@example.com! |
95 | !two@example.com! | |
2186d566 | 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' ' |
4f333bc1 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' ' |
c89e3241 FC |
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 | |
f9444147 | 143 | test_expect_success $PREREQ 'setup expect' " |
b7f30e0a DK |
144 | cat >expected-show-all-headers <<\EOF |
145 | 0001-Second.patch | |
146 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
5012699d JS |
147 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' |
148 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
b7f30e0a DK |
149 | Dry-OK. Log says: |
150 | Server: relay.example.com | |
151 | MAIL FROM:<from@example.com> | |
02461e0e JP |
152 | RCPT TO:<to@example.com> |
153 | RCPT TO:<cc@example.com> | |
154 | RCPT TO:<author@example.com> | |
155 | RCPT TO:<one@example.com> | |
156 | RCPT TO:<two@example.com> | |
157 | RCPT TO:<bcc@example.com> | |
b7f30e0a DK |
158 | From: Example <from@example.com> |
159 | To: to@example.com | |
02461e0e JP |
160 | Cc: cc@example.com, |
161 | A <author@example.com>, | |
162 | One <one@example.com>, | |
163 | two@example.com | |
b7f30e0a DK |
164 | Subject: [PATCH 1/1] Second. |
165 | Date: DATE-STRING | |
166 | Message-Id: MESSAGE-ID-STRING | |
167 | X-Mailer: X-MAILER-STRING | |
168 | In-Reply-To: <unique-message-id@example.com> | |
169 | References: <unique-message-id@example.com> | |
170 | ||
171 | Result: OK | |
172 | EOF | |
f9444147 | 173 | " |
b7f30e0a | 174 | |
5adcf2c6 MT |
175 | test_suppress_self () { |
176 | test_commit $3 && | |
177 | test_when_finished "git reset --hard HEAD^" && | |
178 | ||
179 | write_script cccmd-sed <<-EOF && | |
180 | sed -n -e s/^cccmd--//p "\$1" | |
181 | EOF | |
182 | ||
183 | git commit --amend --author="$1 <$2>" -F - && | |
184 | clean_fake_sendmail && | |
185 | git format-patch --stdout -1 >"suppress-self-$3.patch" && | |
186 | ||
187 | git send-email --from="$1 <$2>" \ | |
188 | --to=nobody@example.com \ | |
189 | --cc-cmd=./cccmd-sed \ | |
190 | --suppress-cc=self \ | |
191 | --smtp-server="$(pwd)/fake.sendmail" \ | |
192 | suppress-self-$3.patch && | |
193 | ||
194 | mv msgtxt1 msgtxt1-$3 && | |
195 | sed -e '/^$/q' msgtxt1-$3 >"msghdr1-$3" && | |
196 | >"expected-no-cc-$3" && | |
197 | ||
198 | (grep '^Cc:' msghdr1-$3 >"actual-no-cc-$3"; | |
199 | test_cmp expected-no-cc-$3 actual-no-cc-$3) | |
200 | } | |
201 | ||
202 | test_suppress_self_unquoted () { | |
203 | test_suppress_self "$1" "$2" "unquoted-$3" <<-EOF | |
204 | test suppress-cc.self unquoted-$3 with name $1 email $2 | |
205 | ||
206 | unquoted-$3 | |
207 | ||
d6ee4456 MT |
208 | cccmd--$1 <$2> |
209 | ||
5adcf2c6 MT |
210 | Cc: $1 <$2> |
211 | Signed-off-by: $1 <$2> | |
212 | EOF | |
213 | } | |
214 | ||
dd29f0b4 MT |
215 | test_suppress_self_quoted () { |
216 | test_suppress_self "$1" "$2" "quoted-$3" <<-EOF | |
217 | test suppress-cc.self quoted-$3 with name $1 email $2 | |
218 | ||
219 | quoted-$3 | |
220 | ||
221 | cccmd--"$1" <$2> | |
222 | ||
223 | Cc: $1 <$2> | |
224 | Cc: "$1" <$2> | |
225 | Signed-off-by: $1 <$2> | |
226 | Signed-off-by: "$1" <$2> | |
227 | EOF | |
228 | } | |
229 | ||
5adcf2c6 | 230 | test_expect_success $PREREQ 'self name is suppressed' " |
d6ee4456 | 231 | test_suppress_self_unquoted 'A U Thor' 'author@example.com' \ |
5adcf2c6 MT |
232 | 'self_name_suppressed' |
233 | " | |
234 | ||
dd29f0b4 MT |
235 | test_expect_success $PREREQ 'self name with dot is suppressed' " |
236 | test_suppress_self_quoted 'A U. Thor' 'author@example.com' \ | |
237 | 'self_name_dot_suppressed' | |
238 | " | |
239 | ||
4b45bcf7 MT |
240 | test_expect_success $PREREQ 'non-ascii self name is suppressed' " |
241 | test_suppress_self_quoted 'Füñný Nâmé' 'odd_?=mail@example.com' \ | |
242 | 'non_ascii_self_suppressed' | |
243 | " | |
244 | ||
14952666 MT |
245 | test_expect_success $PREREQ 'sanitized self name is suppressed' " |
246 | test_suppress_self_unquoted '\"A U. Thor\"' 'author@example.com' \ | |
247 | 'self_name_sanitized_suppressed' | |
248 | " | |
249 | ||
57cd35e6 | 250 | test_expect_success $PREREQ 'Show all headers' ' |
b7f30e0a DK |
251 | git send-email \ |
252 | --dry-run \ | |
3531e270 | 253 | --suppress-cc=sob \ |
b7f30e0a DK |
254 | --from="Example <from@example.com>" \ |
255 | --to=to@example.com \ | |
256 | --cc=cc@example.com \ | |
257 | --bcc=bcc@example.com \ | |
258 | --in-reply-to="<unique-message-id@example.com>" \ | |
259 | --smtp-server relay.example.com \ | |
260 | $patches | | |
261 | sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \ | |
262 | -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \ | |
263 | -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \ | |
264 | >actual-show-all-headers && | |
82ebb0b6 | 265 | test_cmp expected-show-all-headers actual-show-all-headers |
b7f30e0a DK |
266 | ' |
267 | ||
57cd35e6 | 268 | test_expect_success $PREREQ 'Prompting works' ' |
0da43a68 | 269 | clean_fake_sendmail && |
8cac13dc | 270 | (echo "to@example.com" |
0da43a68 JS |
271 | echo "" |
272 | ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \ | |
273 | --smtp-server="$(pwd)/fake.sendmail" \ | |
274 | $patches \ | |
275 | 2>errors && | |
8cac13dc | 276 | grep "^From: A U Thor <author@example.com>\$" msgtxt1 && |
9524cf29 | 277 | grep "^To: to@example.com\$" msgtxt1 |
0da43a68 JS |
278 | ' |
279 | ||
59defcc3 JK |
280 | test_expect_success $PREREQ,AUTOIDENT 'implicit ident is allowed' ' |
281 | clean_fake_sendmail && | |
282 | (sane_unset GIT_AUTHOR_NAME && | |
283 | sane_unset GIT_AUTHOR_EMAIL && | |
284 | sane_unset GIT_COMMITTER_NAME && | |
285 | sane_unset GIT_COMMITTER_EMAIL && | |
286 | GIT_SEND_EMAIL_NOTTY=1 git send-email \ | |
287 | --smtp-server="$(pwd)/fake.sendmail" \ | |
288 | --to=to@example.com \ | |
289 | $patches </dev/null 2>errors | |
290 | ) | |
291 | ' | |
292 | ||
293 | test_expect_success $PREREQ,!AUTOIDENT 'broken implicit ident aborts send-email' ' | |
294 | clean_fake_sendmail && | |
295 | (sane_unset GIT_AUTHOR_NAME && | |
296 | sane_unset GIT_AUTHOR_EMAIL && | |
297 | sane_unset GIT_COMMITTER_NAME && | |
298 | sane_unset GIT_COMMITTER_EMAIL && | |
299 | GIT_SEND_EMAIL_NOTTY=1 && export GIT_SEND_EMAIL_NOTTY && | |
300 | test_must_fail git send-email \ | |
301 | --smtp-server="$(pwd)/fake.sendmail" \ | |
302 | --to=to@example.com \ | |
303 | $patches </dev/null 2>errors && | |
304 | test_i18ngrep "tell me who you are" errors | |
305 | ) | |
306 | ' | |
307 | ||
6e74e075 JP |
308 | test_expect_success $PREREQ 'tocmd works' ' |
309 | clean_fake_sendmail && | |
310 | cp $patches tocmd.patch && | |
311 | echo tocmd--tocmd@example.com >>tocmd.patch && | |
acd72b56 JH |
312 | write_script tocmd-sed <<-\EOF && |
313 | sed -n -e "s/^tocmd--//p" "$1" | |
314 | EOF | |
6e74e075 JP |
315 | git send-email \ |
316 | --from="Example <nobody@example.com>" \ | |
317 | --to-cmd=./tocmd-sed \ | |
318 | --smtp-server="$(pwd)/fake.sendmail" \ | |
319 | tocmd.patch \ | |
320 | && | |
321 | grep "^To: tocmd@example.com" msgtxt1 | |
322 | ' | |
323 | ||
57cd35e6 | 324 | test_expect_success $PREREQ 'cccmd works' ' |
cb8a9bd5 PB |
325 | clean_fake_sendmail && |
326 | cp $patches cccmd.patch && | |
41ae8f1d | 327 | echo "cccmd-- cccmd@example.com" >>cccmd.patch && |
acd72b56 JH |
328 | write_script cccmd-sed <<-\EOF && |
329 | sed -n -e "s/^cccmd--//p" "$1" | |
330 | EOF | |
cb8a9bd5 PB |
331 | git send-email \ |
332 | --from="Example <nobody@example.com>" \ | |
333 | --to=nobody@example.com \ | |
334 | --cc-cmd=./cccmd-sed \ | |
335 | --smtp-server="$(pwd)/fake.sendmail" \ | |
336 | cccmd.patch \ | |
337 | && | |
02461e0e | 338 | grep "^ cccmd@example.com" msgtxt1 |
cb8a9bd5 PB |
339 | ' |
340 | ||
57cd35e6 | 341 | test_expect_success $PREREQ 'reject long lines' ' |
f9444147 ÆAB |
342 | z8=zzzzzzzz && |
343 | z64=$z8$z8$z8$z8$z8$z8$z8$z8 && | |
344 | z512=$z64$z64$z64$z64$z64$z64$z64$z64 && | |
6d34a2ba | 345 | clean_fake_sendmail && |
747bbff9 JK |
346 | cp $patches longline.patch && |
347 | echo $z512$z512 >>longline.patch && | |
d492b31c | 348 | test_must_fail git send-email \ |
747bbff9 JK |
349 | --from="Example <nobody@example.com>" \ |
350 | --to=nobody@example.com \ | |
351 | --smtp-server="$(pwd)/fake.sendmail" \ | |
352 | $patches longline.patch \ | |
353 | 2>errors && | |
354 | grep longline.patch errors | |
355 | ' | |
356 | ||
57cd35e6 | 357 | test_expect_success $PREREQ 'no patch was sent' ' |
6d34a2ba | 358 | ! test -e commandline1 |
747bbff9 JK |
359 | ' |
360 | ||
57cd35e6 | 361 | test_expect_success $PREREQ 'Author From: in message body' ' |
5012699d JS |
362 | clean_fake_sendmail && |
363 | git send-email \ | |
364 | --from="Example <nobody@example.com>" \ | |
365 | --to=nobody@example.com \ | |
366 | --smtp-server="$(pwd)/fake.sendmail" \ | |
367 | $patches && | |
cc7e8167 | 368 | sed "1,/^\$/d" < msgtxt1 > msgbody1 && |
5012699d JS |
369 | grep "From: A <author@example.com>" msgbody1 |
370 | ' | |
371 | ||
57cd35e6 | 372 | test_expect_success $PREREQ 'Author From: not in message body' ' |
5012699d JS |
373 | clean_fake_sendmail && |
374 | git send-email \ | |
375 | --from="A <author@example.com>" \ | |
376 | --to=nobody@example.com \ | |
377 | --smtp-server="$(pwd)/fake.sendmail" \ | |
378 | $patches && | |
cc7e8167 | 379 | sed "1,/^\$/d" < msgtxt1 > msgbody1 && |
5012699d JS |
380 | ! grep "From: A <author@example.com>" msgbody1 |
381 | ' | |
382 | ||
57cd35e6 | 383 | test_expect_success $PREREQ 'allow long lines with --no-validate' ' |
c764a0c2 JK |
384 | git send-email \ |
385 | --from="Example <nobody@example.com>" \ | |
386 | --to=nobody@example.com \ | |
387 | --smtp-server="$(pwd)/fake.sendmail" \ | |
3fee1fe8 | 388 | --novalidate \ |
c764a0c2 JK |
389 | $patches longline.patch \ |
390 | 2>errors | |
391 | ' | |
392 | ||
57cd35e6 | 393 | test_expect_success $PREREQ 'Invalid In-Reply-To' ' |
6d34a2ba | 394 | clean_fake_sendmail && |
0fb7fc75 JS |
395 | git send-email \ |
396 | --from="Example <nobody@example.com>" \ | |
397 | --to=nobody@example.com \ | |
398 | --in-reply-to=" " \ | |
399 | --smtp-server="$(pwd)/fake.sendmail" \ | |
5b57413c | 400 | $patches \ |
cc7e8167 | 401 | 2>errors && |
6d34a2ba | 402 | ! grep "^In-Reply-To: < *>" msgtxt1 |
0fb7fc75 JS |
403 | ' |
404 | ||
57cd35e6 | 405 | test_expect_success $PREREQ 'Valid In-Reply-To when prompting' ' |
6d34a2ba | 406 | clean_fake_sendmail && |
0fb7fc75 JS |
407 | (echo "From Example <from@example.com>" |
408 | echo "To Example <to@example.com>" | |
409 | echo "" | |
6eca18ca | 410 | ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \ |
0fb7fc75 JS |
411 | --smtp-server="$(pwd)/fake.sendmail" \ |
412 | $patches 2>errors && | |
6d34a2ba | 413 | ! grep "^In-Reply-To: < *>" msgtxt1 |
0fb7fc75 JS |
414 | ' |
415 | ||
54aae5e1 JH |
416 | test_expect_success $PREREQ 'In-Reply-To without --chain-reply-to' ' |
417 | clean_fake_sendmail && | |
418 | echo "<unique-message-id@example.com>" >expect && | |
419 | git send-email \ | |
420 | --from="Example <nobody@example.com>" \ | |
421 | --to=nobody@example.com \ | |
d2559f73 | 422 | --nochain-reply-to \ |
54aae5e1 JH |
423 | --in-reply-to="$(cat expect)" \ |
424 | --smtp-server="$(pwd)/fake.sendmail" \ | |
425 | $patches $patches $patches \ | |
426 | 2>errors && | |
db54c8e7 | 427 | # The first message is a reply to --in-reply-to |
54aae5e1 JH |
428 | sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual && |
429 | test_cmp expect actual && | |
db54c8e7 AO |
430 | # Second and subsequent messages are replies to the first one |
431 | sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect && | |
54aae5e1 JH |
432 | sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual && |
433 | test_cmp expect actual && | |
434 | sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual && | |
435 | test_cmp expect actual | |
436 | ' | |
437 | ||
438 | test_expect_success $PREREQ 'In-Reply-To with --chain-reply-to' ' | |
439 | clean_fake_sendmail && | |
440 | echo "<unique-message-id@example.com>" >expect && | |
441 | git send-email \ | |
442 | --from="Example <nobody@example.com>" \ | |
443 | --to=nobody@example.com \ | |
444 | --chain-reply-to \ | |
445 | --in-reply-to="$(cat expect)" \ | |
446 | --smtp-server="$(pwd)/fake.sendmail" \ | |
447 | $patches $patches $patches \ | |
448 | 2>errors && | |
449 | sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual && | |
450 | test_cmp expect actual && | |
451 | sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect && | |
452 | sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual && | |
453 | test_cmp expect actual && | |
454 | sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt2 >expect && | |
455 | sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual && | |
456 | test_cmp expect actual | |
457 | ' | |
458 | ||
57cd35e6 | 459 | test_expect_success $PREREQ 'setup fake editor' ' |
acd72b56 JH |
460 | write_script fake-editor <<-\EOF |
461 | echo fake edit >>"$1" | |
462 | EOF | |
8a8bf469 JK |
463 | ' |
464 | ||
7f0475c3 | 465 | test_set_editor "$(pwd)/fake-editor" |
065096c2 | 466 | |
57cd35e6 | 467 | test_expect_success $PREREQ '--compose works' ' |
8a8bf469 | 468 | clean_fake_sendmail && |
c1f2aa45 JS |
469 | git send-email \ |
470 | --compose --subject foo \ | |
471 | --from="Example <nobody@example.com>" \ | |
472 | --to=nobody@example.com \ | |
473 | --smtp-server="$(pwd)/fake.sendmail" \ | |
474 | $patches \ | |
475 | 2>errors | |
8a8bf469 JK |
476 | ' |
477 | ||
57cd35e6 | 478 | test_expect_success $PREREQ 'first message is compose text' ' |
8a8bf469 JK |
479 | grep "^fake edit" msgtxt1 |
480 | ' | |
481 | ||
57cd35e6 | 482 | test_expect_success $PREREQ 'second message is patch' ' |
8a8bf469 JK |
483 | grep "Subject:.*Second" msgtxt2 |
484 | ' | |
485 | ||
f9444147 | 486 | test_expect_success $PREREQ 'setup expect' " |
3531e270 | 487 | cat >expected-suppress-sob <<\EOF |
33c592dd MV |
488 | 0001-Second.patch |
489 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
5012699d JS |
490 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' |
491 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
33c592dd MV |
492 | Dry-OK. Log says: |
493 | Server: relay.example.com | |
494 | MAIL FROM:<from@example.com> | |
02461e0e JP |
495 | RCPT TO:<to@example.com> |
496 | RCPT TO:<cc@example.com> | |
497 | RCPT TO:<author@example.com> | |
498 | RCPT TO:<one@example.com> | |
499 | RCPT TO:<two@example.com> | |
33c592dd MV |
500 | From: Example <from@example.com> |
501 | To: to@example.com | |
02461e0e JP |
502 | Cc: cc@example.com, |
503 | A <author@example.com>, | |
504 | One <one@example.com>, | |
505 | two@example.com | |
33c592dd MV |
506 | Subject: [PATCH 1/1] Second. |
507 | Date: DATE-STRING | |
508 | Message-Id: MESSAGE-ID-STRING | |
509 | X-Mailer: X-MAILER-STRING | |
510 | ||
511 | Result: OK | |
512 | EOF | |
f9444147 | 513 | " |
33c592dd | 514 | |
3531e270 | 515 | test_suppression () { |
33c592dd MV |
516 | git send-email \ |
517 | --dry-run \ | |
cb8a9bd5 | 518 | --suppress-cc=$1 ${2+"--suppress-cc=$2"} \ |
33c592dd MV |
519 | --from="Example <from@example.com>" \ |
520 | --to=to@example.com \ | |
521 | --smtp-server relay.example.com \ | |
522 | $patches | | |
523 | sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \ | |
524 | -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \ | |
525 | -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \ | |
cb8a9bd5 PB |
526 | >actual-suppress-$1${2+"-$2"} && |
527 | test_cmp expected-suppress-$1${2+"-$2"} actual-suppress-$1${2+"-$2"} | |
3531e270 JS |
528 | } |
529 | ||
57cd35e6 | 530 | test_expect_success $PREREQ 'sendemail.cc set' ' |
3531e270 JS |
531 | git config sendemail.cc cc@example.com && |
532 | test_suppression sob | |
33c592dd MV |
533 | ' |
534 | ||
f9444147 | 535 | test_expect_success $PREREQ 'setup expect' " |
3531e270 | 536 | cat >expected-suppress-sob <<\EOF |
33c592dd MV |
537 | 0001-Second.patch |
538 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
5012699d JS |
539 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' |
540 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
33c592dd MV |
541 | Dry-OK. Log says: |
542 | Server: relay.example.com | |
543 | MAIL FROM:<from@example.com> | |
02461e0e JP |
544 | RCPT TO:<to@example.com> |
545 | RCPT TO:<author@example.com> | |
546 | RCPT TO:<one@example.com> | |
547 | RCPT TO:<two@example.com> | |
33c592dd MV |
548 | From: Example <from@example.com> |
549 | To: to@example.com | |
02461e0e JP |
550 | Cc: A <author@example.com>, |
551 | One <one@example.com>, | |
552 | two@example.com | |
33c592dd MV |
553 | Subject: [PATCH 1/1] Second. |
554 | Date: DATE-STRING | |
555 | Message-Id: MESSAGE-ID-STRING | |
556 | X-Mailer: X-MAILER-STRING | |
557 | ||
558 | Result: OK | |
559 | EOF | |
f9444147 | 560 | " |
33c592dd | 561 | |
57cd35e6 | 562 | test_expect_success $PREREQ 'sendemail.cc unset' ' |
33c592dd | 563 | git config --unset sendemail.cc && |
3531e270 JS |
564 | test_suppression sob |
565 | ' | |
566 | ||
f9444147 | 567 | test_expect_success $PREREQ 'setup expect' " |
cb8a9bd5 PB |
568 | cat >expected-suppress-cccmd <<\EOF |
569 | 0001-Second.patch | |
570 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
571 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' | |
572 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
573 | (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>' | |
574 | Dry-OK. Log says: | |
575 | Server: relay.example.com | |
576 | MAIL FROM:<from@example.com> | |
02461e0e JP |
577 | RCPT TO:<to@example.com> |
578 | RCPT TO:<author@example.com> | |
579 | RCPT TO:<one@example.com> | |
580 | RCPT TO:<two@example.com> | |
581 | RCPT TO:<committer@example.com> | |
cb8a9bd5 PB |
582 | From: Example <from@example.com> |
583 | To: to@example.com | |
02461e0e JP |
584 | Cc: A <author@example.com>, |
585 | One <one@example.com>, | |
586 | two@example.com, | |
587 | C O Mitter <committer@example.com> | |
cb8a9bd5 PB |
588 | Subject: [PATCH 1/1] Second. |
589 | Date: DATE-STRING | |
590 | Message-Id: MESSAGE-ID-STRING | |
591 | X-Mailer: X-MAILER-STRING | |
592 | ||
593 | Result: OK | |
594 | EOF | |
f9444147 | 595 | " |
cb8a9bd5 | 596 | |
57cd35e6 | 597 | test_expect_success $PREREQ 'sendemail.cccmd' ' |
acd72b56 JH |
598 | write_script cccmd <<-\EOF && |
599 | echo cc-cmd@example.com | |
600 | EOF | |
cb8a9bd5 PB |
601 | git config sendemail.cccmd ./cccmd && |
602 | test_suppression cccmd | |
603 | ' | |
604 | ||
f9444147 | 605 | test_expect_success $PREREQ 'setup expect' ' |
3531e270 JS |
606 | cat >expected-suppress-all <<\EOF |
607 | 0001-Second.patch | |
608 | Dry-OK. Log says: | |
609 | Server: relay.example.com | |
610 | MAIL FROM:<from@example.com> | |
611 | RCPT TO:<to@example.com> | |
612 | From: Example <from@example.com> | |
613 | To: to@example.com | |
614 | Subject: [PATCH 1/1] Second. | |
615 | Date: DATE-STRING | |
616 | Message-Id: MESSAGE-ID-STRING | |
617 | X-Mailer: X-MAILER-STRING | |
618 | ||
619 | Result: OK | |
620 | EOF | |
f9444147 | 621 | ' |
3531e270 | 622 | |
57cd35e6 | 623 | test_expect_success $PREREQ '--suppress-cc=all' ' |
3531e270 JS |
624 | test_suppression all |
625 | ' | |
626 | ||
f9444147 | 627 | test_expect_success $PREREQ 'setup expect' " |
3531e270 JS |
628 | cat >expected-suppress-body <<\EOF |
629 | 0001-Second.patch | |
630 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
631 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' | |
632 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
cb8a9bd5 | 633 | (cc-cmd) Adding cc: cc-cmd@example.com from: './cccmd' |
3531e270 JS |
634 | Dry-OK. Log says: |
635 | Server: relay.example.com | |
636 | MAIL FROM:<from@example.com> | |
02461e0e JP |
637 | RCPT TO:<to@example.com> |
638 | RCPT TO:<author@example.com> | |
639 | RCPT TO:<one@example.com> | |
640 | RCPT TO:<two@example.com> | |
641 | RCPT TO:<cc-cmd@example.com> | |
3531e270 JS |
642 | From: Example <from@example.com> |
643 | To: to@example.com | |
02461e0e JP |
644 | Cc: A <author@example.com>, |
645 | One <one@example.com>, | |
646 | two@example.com, | |
647 | cc-cmd@example.com | |
3531e270 JS |
648 | Subject: [PATCH 1/1] Second. |
649 | Date: DATE-STRING | |
650 | Message-Id: MESSAGE-ID-STRING | |
651 | X-Mailer: X-MAILER-STRING | |
652 | ||
653 | Result: OK | |
654 | EOF | |
f9444147 | 655 | " |
3531e270 | 656 | |
57cd35e6 | 657 | test_expect_success $PREREQ '--suppress-cc=body' ' |
3531e270 JS |
658 | test_suppression body |
659 | ' | |
660 | ||
f9444147 | 661 | test_expect_success $PREREQ 'setup expect' " |
cb8a9bd5 PB |
662 | cat >expected-suppress-body-cccmd <<\EOF |
663 | 0001-Second.patch | |
664 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
665 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' | |
666 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
667 | Dry-OK. Log says: | |
668 | Server: relay.example.com | |
669 | MAIL FROM:<from@example.com> | |
02461e0e JP |
670 | RCPT TO:<to@example.com> |
671 | RCPT TO:<author@example.com> | |
672 | RCPT TO:<one@example.com> | |
673 | RCPT TO:<two@example.com> | |
cb8a9bd5 PB |
674 | From: Example <from@example.com> |
675 | To: to@example.com | |
02461e0e JP |
676 | Cc: A <author@example.com>, |
677 | One <one@example.com>, | |
678 | two@example.com | |
cb8a9bd5 PB |
679 | Subject: [PATCH 1/1] Second. |
680 | Date: DATE-STRING | |
681 | Message-Id: MESSAGE-ID-STRING | |
682 | X-Mailer: X-MAILER-STRING | |
683 | ||
684 | Result: OK | |
685 | EOF | |
f9444147 | 686 | " |
cb8a9bd5 | 687 | |
57cd35e6 | 688 | test_expect_success $PREREQ '--suppress-cc=body --suppress-cc=cccmd' ' |
cb8a9bd5 PB |
689 | test_suppression body cccmd |
690 | ' | |
691 | ||
f9444147 | 692 | test_expect_success $PREREQ 'setup expect' " |
3531e270 JS |
693 | cat >expected-suppress-sob <<\EOF |
694 | 0001-Second.patch | |
695 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
696 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' | |
697 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
698 | Dry-OK. Log says: | |
699 | Server: relay.example.com | |
700 | MAIL FROM:<from@example.com> | |
02461e0e JP |
701 | RCPT TO:<to@example.com> |
702 | RCPT TO:<author@example.com> | |
703 | RCPT TO:<one@example.com> | |
704 | RCPT TO:<two@example.com> | |
3531e270 JS |
705 | From: Example <from@example.com> |
706 | To: to@example.com | |
02461e0e JP |
707 | Cc: A <author@example.com>, |
708 | One <one@example.com>, | |
709 | two@example.com | |
3531e270 JS |
710 | Subject: [PATCH 1/1] Second. |
711 | Date: DATE-STRING | |
712 | Message-Id: MESSAGE-ID-STRING | |
713 | X-Mailer: X-MAILER-STRING | |
714 | ||
715 | Result: OK | |
716 | EOF | |
f9444147 | 717 | " |
3531e270 | 718 | |
57cd35e6 | 719 | test_expect_success $PREREQ '--suppress-cc=sob' ' |
cc7e8167 | 720 | test_might_fail git config --unset sendemail.cccmd && |
3531e270 JS |
721 | test_suppression sob |
722 | ' | |
723 | ||
f9444147 | 724 | test_expect_success $PREREQ 'setup expect' " |
3531e270 JS |
725 | cat >expected-suppress-bodycc <<\EOF |
726 | 0001-Second.patch | |
727 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
728 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' | |
729 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
730 | (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>' | |
731 | Dry-OK. Log says: | |
732 | Server: relay.example.com | |
733 | MAIL FROM:<from@example.com> | |
02461e0e JP |
734 | RCPT TO:<to@example.com> |
735 | RCPT TO:<author@example.com> | |
736 | RCPT TO:<one@example.com> | |
737 | RCPT TO:<two@example.com> | |
738 | RCPT TO:<committer@example.com> | |
3531e270 JS |
739 | From: Example <from@example.com> |
740 | To: to@example.com | |
02461e0e JP |
741 | Cc: A <author@example.com>, |
742 | One <one@example.com>, | |
743 | two@example.com, | |
744 | C O Mitter <committer@example.com> | |
3531e270 JS |
745 | Subject: [PATCH 1/1] Second. |
746 | Date: DATE-STRING | |
747 | Message-Id: MESSAGE-ID-STRING | |
748 | X-Mailer: X-MAILER-STRING | |
749 | ||
750 | Result: OK | |
751 | EOF | |
f9444147 | 752 | " |
3531e270 | 753 | |
57cd35e6 | 754 | test_expect_success $PREREQ '--suppress-cc=bodycc' ' |
3531e270 JS |
755 | test_suppression bodycc |
756 | ' | |
757 | ||
f9444147 | 758 | test_expect_success $PREREQ 'setup expect' " |
3531e270 JS |
759 | cat >expected-suppress-cc <<\EOF |
760 | 0001-Second.patch | |
761 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
762 | (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>' | |
763 | Dry-OK. Log says: | |
764 | Server: relay.example.com | |
765 | MAIL FROM:<from@example.com> | |
02461e0e JP |
766 | RCPT TO:<to@example.com> |
767 | RCPT TO:<author@example.com> | |
768 | RCPT TO:<committer@example.com> | |
3531e270 JS |
769 | From: Example <from@example.com> |
770 | To: to@example.com | |
02461e0e JP |
771 | Cc: A <author@example.com>, |
772 | C O Mitter <committer@example.com> | |
3531e270 JS |
773 | Subject: [PATCH 1/1] Second. |
774 | Date: DATE-STRING | |
775 | Message-Id: MESSAGE-ID-STRING | |
776 | X-Mailer: X-MAILER-STRING | |
777 | ||
778 | Result: OK | |
779 | EOF | |
f9444147 | 780 | " |
3531e270 | 781 | |
57cd35e6 | 782 | test_expect_success $PREREQ '--suppress-cc=cc' ' |
3531e270 | 783 | test_suppression cc |
33c592dd MV |
784 | ' |
785 | ||
c1f2aa45 JS |
786 | test_confirm () { |
787 | echo y | \ | |
788 | GIT_SEND_EMAIL_NOTTY=1 \ | |
789 | git send-email \ | |
790 | --from="Example <nobody@example.com>" \ | |
791 | --to=nobody@example.com \ | |
792 | --smtp-server="$(pwd)/fake.sendmail" \ | |
c18f75a1 JS |
793 | $@ $patches > stdout && |
794 | grep "Send this email" stdout | |
c1f2aa45 JS |
795 | } |
796 | ||
57cd35e6 | 797 | test_expect_success $PREREQ '--confirm=always' ' |
c1f2aa45 JS |
798 | test_confirm --confirm=always --suppress-cc=all |
799 | ' | |
800 | ||
57cd35e6 | 801 | test_expect_success $PREREQ '--confirm=auto' ' |
c1f2aa45 JS |
802 | test_confirm --confirm=auto |
803 | ' | |
804 | ||
57cd35e6 | 805 | test_expect_success $PREREQ '--confirm=cc' ' |
c1f2aa45 JS |
806 | test_confirm --confirm=cc |
807 | ' | |
808 | ||
57cd35e6 | 809 | test_expect_success $PREREQ '--confirm=compose' ' |
c1f2aa45 JS |
810 | test_confirm --confirm=compose --compose |
811 | ' | |
812 | ||
57cd35e6 | 813 | test_expect_success $PREREQ 'confirm by default (due to cc)' ' |
c1f2aa45 JS |
814 | CONFIRM=$(git config --get sendemail.confirm) && |
815 | git config --unset sendemail.confirm && | |
c18f75a1 JS |
816 | test_confirm |
817 | ret="$?" | |
818 | git config sendemail.confirm ${CONFIRM:-never} | |
819 | test $ret = "0" | |
c1f2aa45 JS |
820 | ' |
821 | ||
57cd35e6 | 822 | test_expect_success $PREREQ 'confirm by default (due to --compose)' ' |
c1f2aa45 JS |
823 | CONFIRM=$(git config --get sendemail.confirm) && |
824 | git config --unset sendemail.confirm && | |
825 | test_confirm --suppress-cc=all --compose | |
826 | ret="$?" | |
827 | git config sendemail.confirm ${CONFIRM:-never} | |
828 | test $ret = "0" | |
829 | ' | |
830 | ||
57cd35e6 | 831 | test_expect_success $PREREQ 'confirm detects EOF (inform assumes y)' ' |
c18f75a1 JS |
832 | CONFIRM=$(git config --get sendemail.confirm) && |
833 | git config --unset sendemail.confirm && | |
dc1460aa JS |
834 | rm -fr outdir && |
835 | git format-patch -2 -o outdir && | |
c18f75a1 JS |
836 | GIT_SEND_EMAIL_NOTTY=1 \ |
837 | git send-email \ | |
838 | --from="Example <nobody@example.com>" \ | |
839 | --to=nobody@example.com \ | |
840 | --smtp-server="$(pwd)/fake.sendmail" \ | |
dc1460aa | 841 | outdir/*.patch < /dev/null |
c18f75a1 JS |
842 | ret="$?" |
843 | git config sendemail.confirm ${CONFIRM:-never} | |
844 | test $ret = "0" | |
845 | ' | |
846 | ||
57cd35e6 | 847 | test_expect_success $PREREQ 'confirm detects EOF (auto causes failure)' ' |
c18f75a1 JS |
848 | CONFIRM=$(git config --get sendemail.confirm) && |
849 | git config sendemail.confirm auto && | |
3b3637c3 JS |
850 | GIT_SEND_EMAIL_NOTTY=1 && |
851 | export GIT_SEND_EMAIL_NOTTY && | |
c18f75a1 JS |
852 | test_must_fail git send-email \ |
853 | --from="Example <nobody@example.com>" \ | |
854 | --to=nobody@example.com \ | |
855 | --smtp-server="$(pwd)/fake.sendmail" \ | |
856 | $patches < /dev/null | |
857 | ret="$?" | |
858 | git config sendemail.confirm ${CONFIRM:-never} | |
859 | test $ret = "0" | |
860 | ' | |
861 | ||
41ccfdd9 | 862 | test_expect_success $PREREQ 'confirm does not loop forever' ' |
c18f75a1 JS |
863 | CONFIRM=$(git config --get sendemail.confirm) && |
864 | git config sendemail.confirm auto && | |
3b3637c3 JS |
865 | GIT_SEND_EMAIL_NOTTY=1 && |
866 | export GIT_SEND_EMAIL_NOTTY && | |
867 | yes "bogus" | test_must_fail git send-email \ | |
c18f75a1 JS |
868 | --from="Example <nobody@example.com>" \ |
869 | --to=nobody@example.com \ | |
870 | --smtp-server="$(pwd)/fake.sendmail" \ | |
871 | $patches | |
872 | ret="$?" | |
873 | git config sendemail.confirm ${CONFIRM:-never} | |
874 | test $ret = "0" | |
875 | ' | |
876 | ||
57cd35e6 | 877 | test_expect_success $PREREQ 'utf8 Cc is rfc2047 encoded' ' |
a61c0ffa JS |
878 | clean_fake_sendmail && |
879 | rm -fr outdir && | |
880 | git format-patch -1 -o outdir --cc="àéìöú <utf8@example.com>" && | |
881 | git send-email \ | |
882 | --from="Example <nobody@example.com>" \ | |
883 | --to=nobody@example.com \ | |
884 | --smtp-server="$(pwd)/fake.sendmail" \ | |
885 | outdir/*.patch && | |
02461e0e | 886 | grep "^ " msgtxt1 | |
d1fff6fc | 887 | grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>" |
a61c0ffa JS |
888 | ' |
889 | ||
57cd35e6 | 890 | test_expect_success $PREREQ '--compose adds MIME for utf8 body' ' |
0706bd19 | 891 | clean_fake_sendmail && |
acd72b56 JH |
892 | write_script fake-editor-utf8 <<-\EOF && |
893 | echo "utf8 body: àéìöú" >>"$1" | |
894 | EOF | |
03335f22 JH |
895 | GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \ |
896 | git send-email \ | |
897 | --compose --subject foo \ | |
898 | --from="Example <nobody@example.com>" \ | |
899 | --to=nobody@example.com \ | |
900 | --smtp-server="$(pwd)/fake.sendmail" \ | |
901 | $patches && | |
0706bd19 | 902 | grep "^utf8 body" msgtxt1 && |
d1fff6fc | 903 | grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1 |
0706bd19 JK |
904 | ' |
905 | ||
57cd35e6 | 906 | test_expect_success $PREREQ '--compose respects user mime type' ' |
0706bd19 | 907 | clean_fake_sendmail && |
acd72b56 JH |
908 | write_script fake-editor-utf8-mime <<-\EOF && |
909 | cat >"$1" <<-\EOM | |
910 | MIME-Version: 1.0 | |
911 | Content-Type: text/plain; charset=iso-8859-1 | |
912 | Content-Transfer-Encoding: 8bit | |
913 | Subject: foo | |
914 | ||
915 | utf8 body: àéìöú | |
916 | EOM | |
917 | EOF | |
03335f22 JH |
918 | GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \ |
919 | git send-email \ | |
920 | --compose --subject foo \ | |
921 | --from="Example <nobody@example.com>" \ | |
922 | --to=nobody@example.com \ | |
923 | --smtp-server="$(pwd)/fake.sendmail" \ | |
924 | $patches && | |
0706bd19 JK |
925 | grep "^utf8 body" msgtxt1 && |
926 | grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 && | |
d1fff6fc | 927 | ! grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1 |
0706bd19 JK |
928 | ' |
929 | ||
57cd35e6 | 930 | test_expect_success $PREREQ '--compose adds MIME for utf8 subject' ' |
d54eaaa2 | 931 | clean_fake_sendmail && |
03335f22 JH |
932 | GIT_EDITOR="\"$(pwd)/fake-editor\"" \ |
933 | git send-email \ | |
934 | --compose --subject utf8-sübjëct \ | |
935 | --from="Example <nobody@example.com>" \ | |
936 | --to=nobody@example.com \ | |
937 | --smtp-server="$(pwd)/fake.sendmail" \ | |
938 | $patches && | |
d54eaaa2 | 939 | grep "^fake edit" msgtxt1 && |
d1fff6fc | 940 | grep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1 |
d54eaaa2 JK |
941 | ' |
942 | ||
b622d4d1 TR |
943 | test_expect_success $PREREQ 'utf8 author is correctly passed on' ' |
944 | clean_fake_sendmail && | |
945 | test_commit weird_author && | |
946 | test_when_finished "git reset --hard HEAD^" && | |
947 | git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" && | |
948 | git format-patch --stdout -1 >funny_name.patch && | |
949 | git send-email --from="Example <nobody@example.com>" \ | |
03335f22 JH |
950 | --to=nobody@example.com \ |
951 | --smtp-server="$(pwd)/fake.sendmail" \ | |
952 | funny_name.patch && | |
b622d4d1 TR |
953 | grep "^From: Füñný Nâmé <odd_?=mail@example.com>" msgtxt1 |
954 | ' | |
955 | ||
4cb46bdd | 956 | test_expect_success $PREREQ 'utf8 sender is not duplicated' ' |
f07075c2 MT |
957 | clean_fake_sendmail && |
958 | test_commit weird_sender && | |
959 | test_when_finished "git reset --hard HEAD^" && | |
960 | git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" && | |
961 | git format-patch --stdout -1 >funny_name.patch && | |
962 | git send-email --from="Füñný Nâmé <odd_?=mail@example.com>" \ | |
03335f22 JH |
963 | --to=nobody@example.com \ |
964 | --smtp-server="$(pwd)/fake.sendmail" \ | |
965 | funny_name.patch && | |
f07075c2 MT |
966 | grep "^From: " msgtxt1 >msgfrom && |
967 | test_line_count = 1 msgfrom | |
968 | ' | |
969 | ||
62e00690 KM |
970 | test_expect_success $PREREQ 'sendemail.composeencoding works' ' |
971 | clean_fake_sendmail && | |
972 | git config sendemail.composeencoding iso-8859-1 && | |
acd72b56 JH |
973 | write_script fake-editor-utf8 <<-\EOF && |
974 | echo "utf8 body: àéìöú" >>"$1" | |
975 | EOF | |
03335f22 JH |
976 | GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \ |
977 | git send-email \ | |
978 | --compose --subject foo \ | |
979 | --from="Example <nobody@example.com>" \ | |
980 | --to=nobody@example.com \ | |
981 | --smtp-server="$(pwd)/fake.sendmail" \ | |
982 | $patches && | |
62e00690 KM |
983 | grep "^utf8 body" msgtxt1 && |
984 | grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 | |
985 | ' | |
986 | ||
987 | test_expect_success $PREREQ '--compose-encoding works' ' | |
988 | clean_fake_sendmail && | |
acd72b56 JH |
989 | write_script fake-editor-utf8 <<-\EOF && |
990 | echo "utf8 body: àéìöú" >>"$1" | |
991 | EOF | |
03335f22 JH |
992 | GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \ |
993 | git send-email \ | |
994 | --compose-encoding iso-8859-1 \ | |
995 | --compose --subject foo \ | |
996 | --from="Example <nobody@example.com>" \ | |
997 | --to=nobody@example.com \ | |
998 | --smtp-server="$(pwd)/fake.sendmail" \ | |
999 | $patches && | |
62e00690 KM |
1000 | grep "^utf8 body" msgtxt1 && |
1001 | grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 | |
1002 | ' | |
1003 | ||
1004 | test_expect_success $PREREQ '--compose-encoding overrides sendemail.composeencoding' ' | |
1005 | clean_fake_sendmail && | |
1006 | git config sendemail.composeencoding iso-8859-1 && | |
acd72b56 JH |
1007 | write_script fake-editor-utf8 <<-\EOF && |
1008 | echo "utf8 body: àéìöú" >>"$1" | |
1009 | EOF | |
03335f22 JH |
1010 | GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \ |
1011 | git send-email \ | |
1012 | --compose-encoding iso-8859-2 \ | |
1013 | --compose --subject foo \ | |
1014 | --from="Example <nobody@example.com>" \ | |
1015 | --to=nobody@example.com \ | |
1016 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1017 | $patches && | |
62e00690 KM |
1018 | grep "^utf8 body" msgtxt1 && |
1019 | grep "^Content-Type: text/plain; charset=iso-8859-2" msgtxt1 | |
1020 | ' | |
1021 | ||
4a47a4dd KM |
1022 | test_expect_success $PREREQ '--compose-encoding adds correct MIME for subject' ' |
1023 | clean_fake_sendmail && | |
03335f22 JH |
1024 | GIT_EDITOR="\"$(pwd)/fake-editor\"" \ |
1025 | git send-email \ | |
1026 | --compose-encoding iso-8859-2 \ | |
1027 | --compose --subject utf8-sübjëct \ | |
1028 | --from="Example <nobody@example.com>" \ | |
1029 | --to=nobody@example.com \ | |
1030 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1031 | $patches && | |
4a47a4dd KM |
1032 | grep "^fake edit" msgtxt1 && |
1033 | grep "^Subject: =?iso-8859-2?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1 | |
1034 | ' | |
1035 | ||
57cd35e6 | 1036 | test_expect_success $PREREQ 'detects ambiguous reference/file conflict' ' |
5df9fcf6 PH |
1037 | echo master > master && |
1038 | git add master && | |
1039 | git commit -m"add master" && | |
1040 | test_must_fail git send-email --dry-run master 2>errors && | |
1041 | grep disambiguate errors | |
1042 | ' | |
1043 | ||
57cd35e6 | 1044 | test_expect_success $PREREQ 'feed two files' ' |
69f4ce55 JH |
1045 | rm -fr outdir && |
1046 | git format-patch -2 -o outdir && | |
c1f2aa45 | 1047 | git send-email \ |
03335f22 JH |
1048 | --dry-run \ |
1049 | --from="Example <nobody@example.com>" \ | |
1050 | --to=nobody@example.com \ | |
1051 | outdir/000?-*.patch 2>errors >out && | |
69f4ce55 JH |
1052 | grep "^Subject: " out >subjects && |
1053 | test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." && | |
1054 | test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add master" | |
1055 | ' | |
1056 | ||
57cd35e6 | 1057 | test_expect_success $PREREQ 'in-reply-to but no threading' ' |
aaab4b9f TR |
1058 | git send-email \ |
1059 | --dry-run \ | |
1060 | --from="Example <nobody@example.com>" \ | |
1061 | --to=nobody@example.com \ | |
1062 | --in-reply-to="<in-reply-id@example.com>" \ | |
84eeb687 | 1063 | --nothread \ |
aaab4b9f TR |
1064 | $patches | |
1065 | grep "In-Reply-To: <in-reply-id@example.com>" | |
1066 | ' | |
1067 | ||
57cd35e6 | 1068 | test_expect_success $PREREQ 'no in-reply-to and no threading' ' |
32ae8319 MH |
1069 | git send-email \ |
1070 | --dry-run \ | |
1071 | --from="Example <nobody@example.com>" \ | |
1072 | --to=nobody@example.com \ | |
1073 | --nothread \ | |
1074 | $patches $patches >stdout && | |
1075 | ! grep "In-Reply-To: " stdout | |
1076 | ' | |
1077 | ||
57cd35e6 | 1078 | test_expect_success $PREREQ 'threading but no chain-reply-to' ' |
d67114a5 MH |
1079 | git send-email \ |
1080 | --dry-run \ | |
1081 | --from="Example <nobody@example.com>" \ | |
1082 | --to=nobody@example.com \ | |
1083 | --thread \ | |
1084 | --nochain-reply-to \ | |
1085 | $patches $patches >stdout && | |
1086 | grep "In-Reply-To: " stdout | |
1087 | ' | |
1088 | ||
57cd35e6 | 1089 | test_expect_success $PREREQ 'sendemail.to works' ' |
f434c083 SB |
1090 | git config --replace-all sendemail.to "Somebody <somebody@ex.com>" && |
1091 | git send-email \ | |
1092 | --dry-run \ | |
1093 | --from="Example <nobody@example.com>" \ | |
1094 | $patches $patches >stdout && | |
1095 | grep "To: Somebody <somebody@ex.com>" stdout | |
1096 | ' | |
1097 | ||
57cd35e6 | 1098 | test_expect_success $PREREQ '--no-to overrides sendemail.to' ' |
f434c083 SB |
1099 | git send-email \ |
1100 | --dry-run \ | |
1101 | --from="Example <nobody@example.com>" \ | |
1102 | --no-to \ | |
1103 | --to=nobody@example.com \ | |
1104 | $patches $patches >stdout && | |
1105 | grep "To: nobody@example.com" stdout && | |
1106 | ! grep "To: Somebody <somebody@ex.com>" stdout | |
1107 | ' | |
1108 | ||
57cd35e6 | 1109 | test_expect_success $PREREQ 'sendemail.cc works' ' |
f434c083 SB |
1110 | git config --replace-all sendemail.cc "Somebody <somebody@ex.com>" && |
1111 | git send-email \ | |
1112 | --dry-run \ | |
1113 | --from="Example <nobody@example.com>" \ | |
1114 | --to=nobody@example.com \ | |
1115 | $patches $patches >stdout && | |
1116 | grep "Cc: Somebody <somebody@ex.com>" stdout | |
1117 | ' | |
1118 | ||
57cd35e6 | 1119 | test_expect_success $PREREQ '--no-cc overrides sendemail.cc' ' |
f434c083 SB |
1120 | git send-email \ |
1121 | --dry-run \ | |
1122 | --from="Example <nobody@example.com>" \ | |
1123 | --no-cc \ | |
1124 | --cc=bodies@example.com \ | |
1125 | --to=nobody@example.com \ | |
1126 | $patches $patches >stdout && | |
1127 | grep "Cc: bodies@example.com" stdout && | |
1128 | ! grep "Cc: Somebody <somebody@ex.com>" stdout | |
1129 | ' | |
1130 | ||
57cd35e6 | 1131 | test_expect_success $PREREQ 'sendemail.bcc works' ' |
f434c083 SB |
1132 | git config --replace-all sendemail.bcc "Other <other@ex.com>" && |
1133 | git send-email \ | |
1134 | --dry-run \ | |
1135 | --from="Example <nobody@example.com>" \ | |
1136 | --to=nobody@example.com \ | |
1137 | --smtp-server relay.example.com \ | |
1138 | $patches $patches >stdout && | |
1139 | grep "RCPT TO:<other@ex.com>" stdout | |
1140 | ' | |
1141 | ||
57cd35e6 | 1142 | test_expect_success $PREREQ '--no-bcc overrides sendemail.bcc' ' |
f434c083 SB |
1143 | git send-email \ |
1144 | --dry-run \ | |
1145 | --from="Example <nobody@example.com>" \ | |
1146 | --no-bcc \ | |
1147 | --bcc=bodies@example.com \ | |
1148 | --to=nobody@example.com \ | |
1149 | --smtp-server relay.example.com \ | |
1150 | $patches $patches >stdout && | |
1151 | grep "RCPT TO:<bodies@example.com>" stdout && | |
1152 | ! grep "RCPT TO:<other@ex.com>" stdout | |
1153 | ' | |
1154 | ||
21802cd3 SB |
1155 | test_expect_success $PREREQ 'patches To headers are used by default' ' |
1156 | patch=`git format-patch -1 --to="bodies@example.com"` && | |
1157 | test_when_finished "rm $patch" && | |
1158 | git send-email \ | |
1159 | --dry-run \ | |
1160 | --from="Example <nobody@example.com>" \ | |
1161 | --smtp-server relay.example.com \ | |
1162 | $patch >stdout && | |
1163 | grep "RCPT TO:<bodies@example.com>" stdout | |
1164 | ' | |
1165 | ||
1166 | test_expect_success $PREREQ 'patches To headers are appended to' ' | |
1167 | patch=`git format-patch -1 --to="bodies@example.com"` && | |
1168 | test_when_finished "rm $patch" && | |
1169 | git send-email \ | |
1170 | --dry-run \ | |
1171 | --from="Example <nobody@example.com>" \ | |
1172 | --to=nobody@example.com \ | |
1173 | --smtp-server relay.example.com \ | |
1174 | $patch >stdout && | |
1175 | grep "RCPT TO:<bodies@example.com>" stdout && | |
1176 | grep "RCPT TO:<nobody@example.com>" stdout | |
1177 | ' | |
1178 | ||
3c3bb51c SB |
1179 | test_expect_success $PREREQ 'To headers from files reset each patch' ' |
1180 | patch1=`git format-patch -1 --to="bodies@example.com"` && | |
1181 | patch2=`git format-patch -1 --to="other@example.com" HEAD~` && | |
1182 | test_when_finished "rm $patch1 && rm $patch2" && | |
1183 | git send-email \ | |
1184 | --dry-run \ | |
1185 | --from="Example <nobody@example.com>" \ | |
1186 | --to="nobody@example.com" \ | |
1187 | --smtp-server relay.example.com \ | |
1188 | $patch1 $patch2 >stdout && | |
1189 | test $(grep -c "RCPT TO:<bodies@example.com>" stdout) = 1 && | |
1190 | test $(grep -c "RCPT TO:<nobody@example.com>" stdout) = 2 && | |
1191 | test $(grep -c "RCPT TO:<other@example.com>" stdout) = 1 | |
1192 | ' | |
1193 | ||
f9444147 | 1194 | test_expect_success $PREREQ 'setup expect' ' |
3cae7e5b TR |
1195 | cat >email-using-8bit <<EOF |
1196 | From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001 | |
1197 | Message-Id: <bogus-message-id@example.com> | |
1198 | From: author@example.com | |
1199 | Date: Sat, 12 Jun 2010 15:53:58 +0200 | |
1200 | Subject: subject goes here | |
1201 | ||
1202 | Dieser deutsche Text enthält einen Umlaut! | |
1203 | EOF | |
f9444147 | 1204 | ' |
3cae7e5b | 1205 | |
5637d857 KM |
1206 | test_expect_success $PREREQ 'setup expect' ' |
1207 | cat >expected <<EOF | |
1208 | Subject: subject goes here | |
1209 | EOF | |
1210 | ' | |
1211 | ||
1212 | test_expect_success $PREREQ 'ASCII subject is not RFC2047 quoted' ' | |
1213 | clean_fake_sendmail && | |
1214 | echo bogus | | |
1215 | git send-email --from=author@example.com --to=nobody@example.com \ | |
1216 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1217 | --8bit-encoding=UTF-8 \ | |
1218 | email-using-8bit >stdout && | |
1219 | grep "Subject" msgtxt1 >actual && | |
1220 | test_cmp expected actual | |
1221 | ' | |
1222 | ||
f9444147 | 1223 | test_expect_success $PREREQ 'setup expect' ' |
3cae7e5b TR |
1224 | cat >content-type-decl <<EOF |
1225 | MIME-Version: 1.0 | |
1226 | Content-Type: text/plain; charset=UTF-8 | |
1227 | Content-Transfer-Encoding: 8bit | |
1228 | EOF | |
f9444147 | 1229 | ' |
3cae7e5b | 1230 | |
57cd35e6 | 1231 | test_expect_success $PREREQ 'asks about and fixes 8bit encodings' ' |
3cae7e5b TR |
1232 | clean_fake_sendmail && |
1233 | echo | | |
1234 | git send-email --from=author@example.com --to=nobody@example.com \ | |
1235 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1236 | email-using-8bit >stdout && | |
1237 | grep "do not declare a Content-Transfer-Encoding" stdout && | |
1238 | grep email-using-8bit stdout && | |
1239 | grep "Which 8bit encoding" stdout && | |
31832862 | 1240 | egrep "Content|MIME" msgtxt1 >actual && |
3cae7e5b TR |
1241 | test_cmp actual content-type-decl |
1242 | ' | |
1243 | ||
57cd35e6 | 1244 | test_expect_success $PREREQ 'sendemail.8bitEncoding works' ' |
3cae7e5b TR |
1245 | clean_fake_sendmail && |
1246 | git config sendemail.assume8bitEncoding UTF-8 && | |
1247 | echo bogus | | |
1248 | git send-email --from=author@example.com --to=nobody@example.com \ | |
1249 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1250 | email-using-8bit >stdout && | |
31832862 | 1251 | egrep "Content|MIME" msgtxt1 >actual && |
3cae7e5b TR |
1252 | test_cmp actual content-type-decl |
1253 | ' | |
1254 | ||
57cd35e6 | 1255 | test_expect_success $PREREQ '--8bit-encoding overrides sendemail.8bitEncoding' ' |
3cae7e5b TR |
1256 | clean_fake_sendmail && |
1257 | git config sendemail.assume8bitEncoding "bogus too" && | |
1258 | echo bogus | | |
1259 | git send-email --from=author@example.com --to=nobody@example.com \ | |
1260 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1261 | --8bit-encoding=UTF-8 \ | |
1262 | email-using-8bit >stdout && | |
31832862 | 1263 | egrep "Content|MIME" msgtxt1 >actual && |
3cae7e5b TR |
1264 | test_cmp actual content-type-decl |
1265 | ' | |
1266 | ||
f9444147 | 1267 | test_expect_success $PREREQ 'setup expect' ' |
3cae7e5b TR |
1268 | cat >email-using-8bit <<EOF |
1269 | From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001 | |
1270 | Message-Id: <bogus-message-id@example.com> | |
1271 | From: author@example.com | |
1272 | Date: Sat, 12 Jun 2010 15:53:58 +0200 | |
1273 | Subject: Dieser Betreff enthält auch einen Umlaut! | |
1274 | ||
1275 | Nothing to see here. | |
1276 | EOF | |
f9444147 | 1277 | ' |
3cae7e5b | 1278 | |
f9444147 | 1279 | test_expect_success $PREREQ 'setup expect' ' |
3cae7e5b TR |
1280 | cat >expected <<EOF |
1281 | Subject: =?UTF-8?q?Dieser=20Betreff=20enth=C3=A4lt=20auch=20einen=20Umlaut!?= | |
1282 | EOF | |
f9444147 | 1283 | ' |
3cae7e5b | 1284 | |
57cd35e6 | 1285 | test_expect_success $PREREQ '--8bit-encoding also treats subject' ' |
3cae7e5b TR |
1286 | clean_fake_sendmail && |
1287 | echo bogus | | |
1288 | git send-email --from=author@example.com --to=nobody@example.com \ | |
1289 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1290 | --8bit-encoding=UTF-8 \ | |
1291 | email-using-8bit >stdout && | |
1292 | grep "Subject" msgtxt1 >actual && | |
1293 | test_cmp expected actual | |
1294 | ' | |
1295 | ||
8d814084 PB |
1296 | test_expect_success $PREREQ 'setup expect' ' |
1297 | cat >email-using-8bit <<EOF | |
1298 | From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001 | |
1299 | Message-Id: <bogus-message-id@example.com> | |
1300 | From: A U Thor <author@example.com> | |
1301 | Date: Sat, 12 Jun 2010 15:53:58 +0200 | |
1302 | Content-Type: text/plain; charset=UTF-8 | |
1303 | Subject: Nothing to see here. | |
1304 | ||
1305 | Dieser Betreff enthält auch einen Umlaut! | |
1306 | EOF | |
1307 | ' | |
1308 | ||
1309 | test_expect_success $PREREQ 'sendemail.transferencoding=7bit fails on 8bit data' ' | |
1310 | clean_fake_sendmail && | |
1311 | git config sendemail.transferEncoding 7bit && | |
1312 | test_must_fail git send-email \ | |
03335f22 JH |
1313 | --transfer-encoding=7bit \ |
1314 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1315 | email-using-8bit \ | |
1316 | 2>errors >out && | |
8d814084 PB |
1317 | grep "cannot send message as 7bit" errors && |
1318 | test -z "$(ls msgtxt*)" | |
1319 | ' | |
1320 | ||
1321 | test_expect_success $PREREQ '--transfer-encoding overrides sendemail.transferEncoding' ' | |
1322 | clean_fake_sendmail && | |
1323 | git config sendemail.transferEncoding 8bit | |
1324 | test_must_fail git send-email \ | |
03335f22 JH |
1325 | --transfer-encoding=7bit \ |
1326 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1327 | email-using-8bit \ | |
1328 | 2>errors >out && | |
8d814084 PB |
1329 | grep "cannot send message as 7bit" errors && |
1330 | test -z "$(ls msgtxt*)" | |
1331 | ' | |
1332 | ||
1333 | test_expect_success $PREREQ 'sendemail.transferencoding=8bit' ' | |
1334 | clean_fake_sendmail && | |
1335 | git send-email \ | |
03335f22 JH |
1336 | --transfer-encoding=8bit \ |
1337 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1338 | email-using-8bit \ | |
1339 | 2>errors >out && | |
8d814084 PB |
1340 | sed '1,/^$/d' msgtxt1 >actual && |
1341 | sed '1,/^$/d' email-using-8bit >expected && | |
1342 | test_cmp expected actual | |
1343 | ' | |
1344 | ||
1345 | test_expect_success $PREREQ 'setup expect' ' | |
1346 | cat >expected <<EOF | |
1347 | Dieser Betreff enth=C3=A4lt auch einen Umlaut! | |
1348 | EOF | |
1349 | ' | |
1350 | ||
1351 | test_expect_success $PREREQ '8-bit and sendemail.transferencoding=quoted-printable' ' | |
1352 | clean_fake_sendmail && | |
1353 | git send-email \ | |
03335f22 JH |
1354 | --transfer-encoding=quoted-printable \ |
1355 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1356 | email-using-8bit \ | |
1357 | 2>errors >out && | |
8d814084 PB |
1358 | sed '1,/^$/d' msgtxt1 >actual && |
1359 | test_cmp expected actual | |
1360 | ' | |
1361 | ||
1362 | test_expect_success $PREREQ 'setup expect' ' | |
1363 | cat >expected <<EOF | |
1364 | RGllc2VyIEJldHJlZmYgZW50aMOkbHQgYXVjaCBlaW5lbiBVbWxhdXQhCg== | |
1365 | EOF | |
1366 | ' | |
1367 | ||
1368 | test_expect_success $PREREQ '8-bit and sendemail.transferencoding=base64' ' | |
1369 | clean_fake_sendmail && | |
1370 | git send-email \ | |
03335f22 JH |
1371 | --transfer-encoding=base64 \ |
1372 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1373 | email-using-8bit \ | |
1374 | 2>errors >out && | |
8d814084 PB |
1375 | sed '1,/^$/d' msgtxt1 >actual && |
1376 | test_cmp expected actual | |
1377 | ' | |
1378 | ||
1379 | test_expect_success $PREREQ 'setup expect' ' | |
1380 | cat >email-using-qp <<EOF | |
1381 | From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001 | |
1382 | Message-Id: <bogus-message-id@example.com> | |
1383 | From: A U Thor <author@example.com> | |
1384 | Date: Sat, 12 Jun 2010 15:53:58 +0200 | |
1385 | MIME-Version: 1.0 | |
1386 | Content-Transfer-Encoding: quoted-printable | |
1387 | Content-Type: text/plain; charset=UTF-8 | |
1388 | Subject: Nothing to see here. | |
1389 | ||
1390 | Dieser Betreff enth=C3=A4lt auch einen Umlaut! | |
1391 | EOF | |
1392 | ' | |
1393 | ||
1394 | test_expect_success $PREREQ 'convert from quoted-printable to base64' ' | |
1395 | clean_fake_sendmail && | |
1396 | git send-email \ | |
03335f22 JH |
1397 | --transfer-encoding=base64 \ |
1398 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1399 | email-using-qp \ | |
1400 | 2>errors >out && | |
8d814084 PB |
1401 | sed '1,/^$/d' msgtxt1 >actual && |
1402 | test_cmp expected actual | |
1403 | ' | |
1404 | ||
1405 | test_expect_success $PREREQ 'setup expect' " | |
1406 | tr -d '\\015' | tr '%' '\\015' > email-using-crlf <<EOF | |
1407 | From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001 | |
1408 | Message-Id: <bogus-message-id@example.com> | |
1409 | From: A U Thor <author@example.com> | |
1410 | Date: Sat, 12 Jun 2010 15:53:58 +0200 | |
1411 | Content-Type: text/plain; charset=UTF-8 | |
1412 | Subject: Nothing to see here. | |
1413 | ||
1414 | Look, I have a CRLF and an = sign!% | |
1415 | EOF | |
1416 | " | |
1417 | ||
1418 | test_expect_success $PREREQ 'setup expect' ' | |
1419 | cat >expected <<EOF | |
1420 | Look, I have a CRLF and an =3D sign!=0D | |
1421 | EOF | |
1422 | ' | |
1423 | ||
1424 | test_expect_success $PREREQ 'CRLF and sendemail.transferencoding=quoted-printable' ' | |
1425 | clean_fake_sendmail && | |
1426 | git send-email \ | |
03335f22 JH |
1427 | --transfer-encoding=quoted-printable \ |
1428 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1429 | email-using-crlf \ | |
1430 | 2>errors >out && | |
8d814084 PB |
1431 | sed '1,/^$/d' msgtxt1 >actual && |
1432 | test_cmp expected actual | |
1433 | ' | |
1434 | ||
1435 | test_expect_success $PREREQ 'setup expect' ' | |
1436 | cat >expected <<EOF | |
1437 | TG9vaywgSSBoYXZlIGEgQ1JMRiBhbmQgYW4gPSBzaWduIQ0K | |
1438 | EOF | |
1439 | ' | |
1440 | ||
1441 | test_expect_success $PREREQ 'CRLF and sendemail.transferencoding=base64' ' | |
1442 | clean_fake_sendmail && | |
1443 | git send-email \ | |
03335f22 JH |
1444 | --transfer-encoding=base64 \ |
1445 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1446 | email-using-crlf \ | |
1447 | 2>errors >out && | |
8d814084 PB |
1448 | sed '1,/^$/d' msgtxt1 >actual && |
1449 | test_cmp expected actual | |
1450 | ' | |
1451 | ||
1452 | ||
a03bc5b6 TR |
1453 | # Note that the patches in this test are deliberately out of order; we |
1454 | # want to make sure it works even if the cover-letter is not in the | |
1455 | # first mail. | |
57da2042 | 1456 | test_expect_success $PREREQ 'refusing to send cover letter template' ' |
a03bc5b6 TR |
1457 | clean_fake_sendmail && |
1458 | rm -fr outdir && | |
1459 | git format-patch --cover-letter -2 -o outdir && | |
1460 | test_must_fail git send-email \ | |
03335f22 JH |
1461 | --from="Example <nobody@example.com>" \ |
1462 | --to=nobody@example.com \ | |
1463 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1464 | outdir/0002-*.patch \ | |
1465 | outdir/0000-*.patch \ | |
1466 | outdir/0001-*.patch \ | |
1467 | 2>errors >out && | |
a03bc5b6 TR |
1468 | grep "SUBJECT HERE" errors && |
1469 | test -z "$(ls msgtxt*)" | |
1470 | ' | |
1471 | ||
57da2042 | 1472 | test_expect_success $PREREQ '--force sends cover letter template anyway' ' |
a03bc5b6 TR |
1473 | clean_fake_sendmail && |
1474 | rm -fr outdir && | |
1475 | git format-patch --cover-letter -2 -o outdir && | |
1476 | git send-email \ | |
03335f22 JH |
1477 | --force \ |
1478 | --from="Example <nobody@example.com>" \ | |
1479 | --to=nobody@example.com \ | |
1480 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1481 | outdir/0002-*.patch \ | |
1482 | outdir/0000-*.patch \ | |
1483 | outdir/0001-*.patch \ | |
1484 | 2>errors >out && | |
a03bc5b6 TR |
1485 | ! grep "SUBJECT HERE" errors && |
1486 | test -n "$(ls msgtxt*)" | |
1487 | ' | |
1488 | ||
8ccc4e42 MT |
1489 | test_cover_addresses () { |
1490 | header="$1" | |
1491 | shift | |
1492 | clean_fake_sendmail && | |
1493 | rm -fr outdir && | |
1494 | git format-patch --cover-letter -2 -o outdir && | |
1495 | cover=`echo outdir/0000-*.patch` && | |
1496 | mv $cover cover-to-edit.patch && | |
35ec002c | 1497 | perl -pe "s/^From:/$header: extra\@address.com\nFrom:/" cover-to-edit.patch >"$cover" && |
8ccc4e42 | 1498 | git send-email \ |
03335f22 JH |
1499 | --force \ |
1500 | --from="Example <nobody@example.com>" \ | |
1501 | --no-to --no-cc \ | |
1502 | "$@" \ | |
1503 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1504 | outdir/0000-*.patch \ | |
1505 | outdir/0001-*.patch \ | |
1506 | outdir/0002-*.patch \ | |
1507 | 2>errors >out && | |
8ccc4e42 MT |
1508 | grep "^$header: extra@address.com" msgtxt1 >to1 && |
1509 | grep "^$header: extra@address.com" msgtxt2 >to2 && | |
1510 | grep "^$header: extra@address.com" msgtxt3 >to3 && | |
1511 | test_line_count = 1 to1 && | |
1512 | test_line_count = 1 to2 && | |
1513 | test_line_count = 1 to3 | |
1514 | } | |
1515 | ||
1516 | test_expect_success $PREREQ 'to-cover adds To to all mail' ' | |
1517 | test_cover_addresses "To" --to-cover | |
1518 | ' | |
1519 | ||
1520 | test_expect_success $PREREQ 'cc-cover adds Cc to all mail' ' | |
1521 | test_cover_addresses "Cc" --cc-cover | |
1522 | ' | |
1523 | ||
1524 | test_expect_success $PREREQ 'tocover adds To to all mail' ' | |
1525 | test_config sendemail.tocover true && | |
1526 | test_cover_addresses "To" | |
1527 | ' | |
1528 | ||
1529 | test_expect_success $PREREQ 'cccover adds Cc to all mail' ' | |
1530 | test_config sendemail.cccover true && | |
1531 | test_cover_addresses "Cc" | |
1532 | ' | |
1533 | ||
463b0ea2 CS |
1534 | test_expect_success $PREREQ 'sendemail.aliasfiletype=mailrc' ' |
1535 | clean_fake_sendmail && | |
1536 | echo "alias sbd somebody@example.org" >.mailrc && | |
1537 | git config --replace-all sendemail.aliasesfile "$(pwd)/.mailrc" && | |
1538 | git config sendemail.aliasfiletype mailrc && | |
1539 | git send-email \ | |
03335f22 JH |
1540 | --from="Example <nobody@example.com>" \ |
1541 | --to=sbd \ | |
1542 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1543 | outdir/0001-*.patch \ | |
1544 | 2>errors >out && | |
463b0ea2 CS |
1545 | grep "^!somebody@example\.org!$" commandline1 |
1546 | ' | |
1547 | ||
1548 | test_expect_success $PREREQ 'sendemail.aliasfile=~/.mailrc' ' | |
1549 | clean_fake_sendmail && | |
1550 | echo "alias sbd someone@example.org" >~/.mailrc && | |
1551 | git config --replace-all sendemail.aliasesfile "~/.mailrc" && | |
1552 | git config sendemail.aliasfiletype mailrc && | |
1553 | git send-email \ | |
03335f22 JH |
1554 | --from="Example <nobody@example.com>" \ |
1555 | --to=sbd \ | |
1556 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1557 | outdir/0001-*.patch \ | |
1558 | 2>errors >out && | |
463b0ea2 CS |
1559 | grep "^!someone@example\.org!$" commandline1 |
1560 | ' | |
1561 | ||
ce903018 | 1562 | test_done |