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