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