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