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