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