]>
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 | |
57cd35e6 | 9 | test_expect_success $PREREQ \ |
ce903018 RA |
10 | 'prepare reference tree' \ |
11 | 'echo "1A quick brown fox jumps over the" >file && | |
12 | echo "lazy dog" >>file && | |
c0d45281 | 13 | git add file && |
ce903018 RA |
14 | GIT_AUTHOR_NAME="A" git commit -a -m "Initial."' |
15 | ||
57cd35e6 | 16 | test_expect_success $PREREQ \ |
ce903018 | 17 | 'Setup helper tool' \ |
bb3e4f03 | 18 | '(echo "#!$SHELL_PATH" |
2186d566 | 19 | echo shift |
6d34a2ba JK |
20 | echo output=1 |
21 | echo "while test -f commandline\$output; do output=\$((\$output+1)); done" | |
2186d566 JH |
22 | echo for a |
23 | echo do | |
24 | echo " echo \"!\$a!\"" | |
6d34a2ba JK |
25 | echo "done >commandline\$output" |
26 | echo "cat > msgtxt\$output" | |
c0d45281 JK |
27 | ) >fake.sendmail && |
28 | chmod +x ./fake.sendmail && | |
29 | git add fake.sendmail && | |
ce903018 RA |
30 | GIT_AUTHOR_NAME="A" git commit -a -m "Second."' |
31 | ||
6d34a2ba JK |
32 | clean_fake_sendmail() { |
33 | rm -f commandline* msgtxt* | |
34 | } | |
35 | ||
57cd35e6 | 36 | test_expect_success $PREREQ 'Extract patches' ' |
3531e270 | 37 | patches=`git format-patch -s --cc="One <one@example.com>" --cc=two@example.com -n HEAD^1` |
280242d1 JH |
38 | ' |
39 | ||
c1f2aa45 JS |
40 | # Test no confirm early to ensure remaining tests will not hang |
41 | test_no_confirm () { | |
42 | rm -f no_confirm_okay | |
43 | echo n | \ | |
44 | GIT_SEND_EMAIL_NOTTY=1 \ | |
45 | git send-email \ | |
46 | --from="Example <from@example.com>" \ | |
47 | --to=nobody@example.com \ | |
48 | --smtp-server="$(pwd)/fake.sendmail" \ | |
49 | $@ \ | |
50 | $patches > stdout && | |
51 | test_must_fail grep "Send this email" stdout && | |
52 | > no_confirm_okay | |
53 | } | |
54 | ||
55 | # Exit immediately to prevent hang if a no-confirm test fails | |
56 | check_no_confirm () { | |
57cd35e6 ÆAB |
57 | if ! test -f no_confirm_okay |
58 | then | |
59 | say 'confirm test failed; skipping remaining tests to prevent hanging' | |
60 | PREREQ="$PREREQ,CHECK_NO_CONFIRM" | |
61 | fi | |
62 | return 0 | |
c1f2aa45 JS |
63 | } |
64 | ||
57cd35e6 ÆAB |
65 | test_expect_success $PREREQ 'No confirm with --suppress-cc' ' |
66 | test_no_confirm --suppress-cc=sob && | |
67 | check_no_confirm | |
c1f2aa45 | 68 | ' |
c1f2aa45 | 69 | |
57cd35e6 ÆAB |
70 | |
71 | test_expect_success $PREREQ 'No confirm with --confirm=never' ' | |
72 | test_no_confirm --confirm=never && | |
73 | check_no_confirm | |
c1f2aa45 | 74 | ' |
c1f2aa45 JS |
75 | |
76 | # leave sendemail.confirm set to never after this so that none of the | |
77 | # remaining tests prompt unintentionally. | |
57cd35e6 | 78 | test_expect_success $PREREQ 'No confirm with sendemail.confirm=never' ' |
c1f2aa45 | 79 | git config sendemail.confirm never && |
57cd35e6 ÆAB |
80 | test_no_confirm --compose --subject=foo && |
81 | check_no_confirm | |
c1f2aa45 | 82 | ' |
c1f2aa45 | 83 | |
57cd35e6 | 84 | test_expect_success $PREREQ 'Send patches' ' |
3531e270 | 85 | git send-email --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors |
280242d1 | 86 | ' |
ce903018 | 87 | |
f9444147 | 88 | test_expect_success $PREREQ 'setup expect' ' |
2186d566 JH |
89 | cat >expected <<\EOF |
90 | !nobody@example.com! | |
91 | !author@example.com! | |
5012699d JS |
92 | !one@example.com! |
93 | !two@example.com! | |
2186d566 | 94 | EOF |
f9444147 ÆAB |
95 | ' |
96 | ||
57cd35e6 | 97 | test_expect_success $PREREQ \ |
ce903018 | 98 | 'Verify commandline' \ |
188c3827 | 99 | 'test_cmp expected commandline1' |
ce903018 | 100 | |
57cd35e6 | 101 | test_expect_success $PREREQ 'Send patches with --envelope-sender' ' |
4f333bc1 JH |
102 | clean_fake_sendmail && |
103 | git send-email --envelope-sender="Patch Contributer <patch@example.com>" --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors | |
104 | ' | |
105 | ||
f9444147 | 106 | test_expect_success $PREREQ 'setup expect' ' |
4f333bc1 JH |
107 | cat >expected <<\EOF |
108 | !patch@example.com! | |
109 | !-i! | |
110 | !nobody@example.com! | |
111 | !author@example.com! | |
112 | !one@example.com! | |
113 | !two@example.com! | |
114 | EOF | |
f9444147 ÆAB |
115 | ' |
116 | ||
57cd35e6 | 117 | test_expect_success $PREREQ \ |
4f333bc1 JH |
118 | 'Verify commandline' \ |
119 | 'test_cmp expected commandline1' | |
120 | ||
57cd35e6 | 121 | test_expect_success $PREREQ 'Send patches with --envelope-sender=auto' ' |
c89e3241 FC |
122 | clean_fake_sendmail && |
123 | 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 | |
124 | ' | |
125 | ||
f9444147 | 126 | test_expect_success $PREREQ 'setup expect' ' |
c89e3241 FC |
127 | cat >expected <<\EOF |
128 | !nobody@example.com! | |
129 | !-i! | |
130 | !nobody@example.com! | |
131 | !author@example.com! | |
132 | !one@example.com! | |
133 | !two@example.com! | |
134 | EOF | |
f9444147 ÆAB |
135 | ' |
136 | ||
57cd35e6 | 137 | test_expect_success $PREREQ \ |
c89e3241 FC |
138 | 'Verify commandline' \ |
139 | 'test_cmp expected commandline1' | |
140 | ||
f9444147 | 141 | test_expect_success $PREREQ 'setup expect' " |
b7f30e0a DK |
142 | cat >expected-show-all-headers <<\EOF |
143 | 0001-Second.patch | |
144 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
5012699d JS |
145 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' |
146 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
b7f30e0a DK |
147 | Dry-OK. Log says: |
148 | Server: relay.example.com | |
149 | MAIL FROM:<from@example.com> | |
02461e0e JP |
150 | RCPT TO:<to@example.com> |
151 | RCPT TO:<cc@example.com> | |
152 | RCPT TO:<author@example.com> | |
153 | RCPT TO:<one@example.com> | |
154 | RCPT TO:<two@example.com> | |
155 | RCPT TO:<bcc@example.com> | |
b7f30e0a DK |
156 | From: Example <from@example.com> |
157 | To: to@example.com | |
02461e0e JP |
158 | Cc: cc@example.com, |
159 | A <author@example.com>, | |
160 | One <one@example.com>, | |
161 | two@example.com | |
b7f30e0a DK |
162 | Subject: [PATCH 1/1] Second. |
163 | Date: DATE-STRING | |
164 | Message-Id: MESSAGE-ID-STRING | |
165 | X-Mailer: X-MAILER-STRING | |
166 | In-Reply-To: <unique-message-id@example.com> | |
167 | References: <unique-message-id@example.com> | |
168 | ||
169 | Result: OK | |
170 | EOF | |
f9444147 | 171 | " |
b7f30e0a | 172 | |
57cd35e6 | 173 | test_expect_success $PREREQ 'Show all headers' ' |
b7f30e0a DK |
174 | git send-email \ |
175 | --dry-run \ | |
3531e270 | 176 | --suppress-cc=sob \ |
b7f30e0a DK |
177 | --from="Example <from@example.com>" \ |
178 | --to=to@example.com \ | |
179 | --cc=cc@example.com \ | |
180 | --bcc=bcc@example.com \ | |
181 | --in-reply-to="<unique-message-id@example.com>" \ | |
182 | --smtp-server relay.example.com \ | |
183 | $patches | | |
184 | sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \ | |
185 | -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \ | |
186 | -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \ | |
187 | >actual-show-all-headers && | |
82ebb0b6 | 188 | test_cmp expected-show-all-headers actual-show-all-headers |
b7f30e0a DK |
189 | ' |
190 | ||
57cd35e6 | 191 | test_expect_success $PREREQ 'Prompting works' ' |
0da43a68 JS |
192 | clean_fake_sendmail && |
193 | (echo "Example <from@example.com>" | |
194 | echo "to@example.com" | |
195 | echo "" | |
196 | ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \ | |
197 | --smtp-server="$(pwd)/fake.sendmail" \ | |
198 | $patches \ | |
199 | 2>errors && | |
9524cf29 SB |
200 | grep "^From: Example <from@example.com>\$" msgtxt1 && |
201 | grep "^To: to@example.com\$" msgtxt1 | |
0da43a68 JS |
202 | ' |
203 | ||
57cd35e6 | 204 | test_expect_success $PREREQ 'cccmd works' ' |
cb8a9bd5 PB |
205 | clean_fake_sendmail && |
206 | cp $patches cccmd.patch && | |
207 | echo cccmd--cccmd@example.com >>cccmd.patch && | |
977e289e BC |
208 | { |
209 | echo "#!$SHELL_PATH" | |
210 | echo sed -n -e s/^cccmd--//p \"\$1\" | |
211 | } > cccmd-sed && | |
cb8a9bd5 PB |
212 | chmod +x cccmd-sed && |
213 | git send-email \ | |
214 | --from="Example <nobody@example.com>" \ | |
215 | --to=nobody@example.com \ | |
216 | --cc-cmd=./cccmd-sed \ | |
217 | --smtp-server="$(pwd)/fake.sendmail" \ | |
218 | cccmd.patch \ | |
219 | && | |
02461e0e | 220 | grep "^ cccmd@example.com" msgtxt1 |
cb8a9bd5 PB |
221 | ' |
222 | ||
57cd35e6 | 223 | test_expect_success $PREREQ 'reject long lines' ' |
f9444147 ÆAB |
224 | z8=zzzzzzzz && |
225 | z64=$z8$z8$z8$z8$z8$z8$z8$z8 && | |
226 | z512=$z64$z64$z64$z64$z64$z64$z64$z64 && | |
6d34a2ba | 227 | clean_fake_sendmail && |
747bbff9 JK |
228 | cp $patches longline.patch && |
229 | echo $z512$z512 >>longline.patch && | |
d492b31c | 230 | test_must_fail git send-email \ |
747bbff9 JK |
231 | --from="Example <nobody@example.com>" \ |
232 | --to=nobody@example.com \ | |
233 | --smtp-server="$(pwd)/fake.sendmail" \ | |
234 | $patches longline.patch \ | |
235 | 2>errors && | |
236 | grep longline.patch errors | |
237 | ' | |
238 | ||
57cd35e6 | 239 | test_expect_success $PREREQ 'no patch was sent' ' |
6d34a2ba | 240 | ! test -e commandline1 |
747bbff9 JK |
241 | ' |
242 | ||
57cd35e6 | 243 | test_expect_success $PREREQ 'Author From: in message body' ' |
5012699d JS |
244 | clean_fake_sendmail && |
245 | git send-email \ | |
246 | --from="Example <nobody@example.com>" \ | |
247 | --to=nobody@example.com \ | |
248 | --smtp-server="$(pwd)/fake.sendmail" \ | |
249 | $patches && | |
9524cf29 | 250 | sed "1,/^\$/d" < msgtxt1 > msgbody1 |
5012699d JS |
251 | grep "From: A <author@example.com>" msgbody1 |
252 | ' | |
253 | ||
57cd35e6 | 254 | test_expect_success $PREREQ 'Author From: not in message body' ' |
5012699d JS |
255 | clean_fake_sendmail && |
256 | git send-email \ | |
257 | --from="A <author@example.com>" \ | |
258 | --to=nobody@example.com \ | |
259 | --smtp-server="$(pwd)/fake.sendmail" \ | |
260 | $patches && | |
9524cf29 | 261 | sed "1,/^\$/d" < msgtxt1 > msgbody1 |
5012699d JS |
262 | ! grep "From: A <author@example.com>" msgbody1 |
263 | ' | |
264 | ||
57cd35e6 | 265 | test_expect_success $PREREQ 'allow long lines with --no-validate' ' |
c764a0c2 JK |
266 | git send-email \ |
267 | --from="Example <nobody@example.com>" \ | |
268 | --to=nobody@example.com \ | |
269 | --smtp-server="$(pwd)/fake.sendmail" \ | |
3fee1fe8 | 270 | --novalidate \ |
c764a0c2 JK |
271 | $patches longline.patch \ |
272 | 2>errors | |
273 | ' | |
274 | ||
57cd35e6 | 275 | test_expect_success $PREREQ 'Invalid In-Reply-To' ' |
6d34a2ba | 276 | clean_fake_sendmail && |
0fb7fc75 JS |
277 | git send-email \ |
278 | --from="Example <nobody@example.com>" \ | |
279 | --to=nobody@example.com \ | |
280 | --in-reply-to=" " \ | |
281 | --smtp-server="$(pwd)/fake.sendmail" \ | |
5b57413c | 282 | $patches \ |
0fb7fc75 | 283 | 2>errors |
6d34a2ba | 284 | ! grep "^In-Reply-To: < *>" msgtxt1 |
0fb7fc75 JS |
285 | ' |
286 | ||
57cd35e6 | 287 | test_expect_success $PREREQ 'Valid In-Reply-To when prompting' ' |
6d34a2ba | 288 | clean_fake_sendmail && |
0fb7fc75 JS |
289 | (echo "From Example <from@example.com>" |
290 | echo "To Example <to@example.com>" | |
291 | echo "" | |
292 | ) | env GIT_SEND_EMAIL_NOTTY=1 git send-email \ | |
293 | --smtp-server="$(pwd)/fake.sendmail" \ | |
294 | $patches 2>errors && | |
6d34a2ba | 295 | ! grep "^In-Reply-To: < *>" msgtxt1 |
0fb7fc75 JS |
296 | ' |
297 | ||
57cd35e6 | 298 | test_expect_success $PREREQ 'setup fake editor' ' |
bb3e4f03 | 299 | (echo "#!$SHELL_PATH" && |
065096c2 | 300 | echo "echo fake edit >>\"\$1\"" |
8a8bf469 JK |
301 | ) >fake-editor && |
302 | chmod +x fake-editor | |
303 | ' | |
304 | ||
7f0475c3 | 305 | test_set_editor "$(pwd)/fake-editor" |
065096c2 | 306 | |
57cd35e6 | 307 | test_expect_success $PREREQ '--compose works' ' |
8a8bf469 | 308 | clean_fake_sendmail && |
c1f2aa45 JS |
309 | git send-email \ |
310 | --compose --subject foo \ | |
311 | --from="Example <nobody@example.com>" \ | |
312 | --to=nobody@example.com \ | |
313 | --smtp-server="$(pwd)/fake.sendmail" \ | |
314 | $patches \ | |
315 | 2>errors | |
8a8bf469 JK |
316 | ' |
317 | ||
57cd35e6 | 318 | test_expect_success $PREREQ 'first message is compose text' ' |
8a8bf469 JK |
319 | grep "^fake edit" msgtxt1 |
320 | ' | |
321 | ||
57cd35e6 | 322 | test_expect_success $PREREQ 'second message is patch' ' |
8a8bf469 JK |
323 | grep "Subject:.*Second" msgtxt2 |
324 | ' | |
325 | ||
f9444147 | 326 | test_expect_success $PREREQ 'setup expect' " |
3531e270 | 327 | cat >expected-suppress-sob <<\EOF |
33c592dd MV |
328 | 0001-Second.patch |
329 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
5012699d JS |
330 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' |
331 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
33c592dd MV |
332 | Dry-OK. Log says: |
333 | Server: relay.example.com | |
334 | MAIL FROM:<from@example.com> | |
02461e0e JP |
335 | RCPT TO:<to@example.com> |
336 | RCPT TO:<cc@example.com> | |
337 | RCPT TO:<author@example.com> | |
338 | RCPT TO:<one@example.com> | |
339 | RCPT TO:<two@example.com> | |
33c592dd MV |
340 | From: Example <from@example.com> |
341 | To: to@example.com | |
02461e0e JP |
342 | Cc: cc@example.com, |
343 | A <author@example.com>, | |
344 | One <one@example.com>, | |
345 | two@example.com | |
33c592dd MV |
346 | Subject: [PATCH 1/1] Second. |
347 | Date: DATE-STRING | |
348 | Message-Id: MESSAGE-ID-STRING | |
349 | X-Mailer: X-MAILER-STRING | |
350 | ||
351 | Result: OK | |
352 | EOF | |
f9444147 | 353 | " |
33c592dd | 354 | |
3531e270 | 355 | test_suppression () { |
33c592dd MV |
356 | git send-email \ |
357 | --dry-run \ | |
cb8a9bd5 | 358 | --suppress-cc=$1 ${2+"--suppress-cc=$2"} \ |
33c592dd MV |
359 | --from="Example <from@example.com>" \ |
360 | --to=to@example.com \ | |
361 | --smtp-server relay.example.com \ | |
362 | $patches | | |
363 | sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \ | |
364 | -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \ | |
365 | -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \ | |
cb8a9bd5 PB |
366 | >actual-suppress-$1${2+"-$2"} && |
367 | test_cmp expected-suppress-$1${2+"-$2"} actual-suppress-$1${2+"-$2"} | |
3531e270 JS |
368 | } |
369 | ||
57cd35e6 | 370 | test_expect_success $PREREQ 'sendemail.cc set' ' |
3531e270 JS |
371 | git config sendemail.cc cc@example.com && |
372 | test_suppression sob | |
33c592dd MV |
373 | ' |
374 | ||
f9444147 | 375 | test_expect_success $PREREQ 'setup expect' " |
3531e270 | 376 | cat >expected-suppress-sob <<\EOF |
33c592dd MV |
377 | 0001-Second.patch |
378 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
5012699d JS |
379 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' |
380 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
33c592dd MV |
381 | Dry-OK. Log says: |
382 | Server: relay.example.com | |
383 | MAIL FROM:<from@example.com> | |
02461e0e JP |
384 | RCPT TO:<to@example.com> |
385 | RCPT TO:<author@example.com> | |
386 | RCPT TO:<one@example.com> | |
387 | RCPT TO:<two@example.com> | |
33c592dd MV |
388 | From: Example <from@example.com> |
389 | To: to@example.com | |
02461e0e JP |
390 | Cc: A <author@example.com>, |
391 | One <one@example.com>, | |
392 | two@example.com | |
33c592dd MV |
393 | Subject: [PATCH 1/1] Second. |
394 | Date: DATE-STRING | |
395 | Message-Id: MESSAGE-ID-STRING | |
396 | X-Mailer: X-MAILER-STRING | |
397 | ||
398 | Result: OK | |
399 | EOF | |
f9444147 | 400 | " |
33c592dd | 401 | |
57cd35e6 | 402 | test_expect_success $PREREQ 'sendemail.cc unset' ' |
33c592dd | 403 | git config --unset sendemail.cc && |
3531e270 JS |
404 | test_suppression sob |
405 | ' | |
406 | ||
f9444147 | 407 | test_expect_success $PREREQ 'setup expect' " |
cb8a9bd5 PB |
408 | cat >expected-suppress-cccmd <<\EOF |
409 | 0001-Second.patch | |
410 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
411 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' | |
412 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
413 | (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>' | |
414 | Dry-OK. Log says: | |
415 | Server: relay.example.com | |
416 | MAIL FROM:<from@example.com> | |
02461e0e JP |
417 | RCPT TO:<to@example.com> |
418 | RCPT TO:<author@example.com> | |
419 | RCPT TO:<one@example.com> | |
420 | RCPT TO:<two@example.com> | |
421 | RCPT TO:<committer@example.com> | |
cb8a9bd5 PB |
422 | From: Example <from@example.com> |
423 | To: to@example.com | |
02461e0e JP |
424 | Cc: A <author@example.com>, |
425 | One <one@example.com>, | |
426 | two@example.com, | |
427 | C O Mitter <committer@example.com> | |
cb8a9bd5 PB |
428 | Subject: [PATCH 1/1] Second. |
429 | Date: DATE-STRING | |
430 | Message-Id: MESSAGE-ID-STRING | |
431 | X-Mailer: X-MAILER-STRING | |
432 | ||
433 | Result: OK | |
434 | EOF | |
f9444147 | 435 | " |
cb8a9bd5 | 436 | |
57cd35e6 | 437 | test_expect_success $PREREQ 'sendemail.cccmd' ' |
cb8a9bd5 PB |
438 | echo echo cc-cmd@example.com > cccmd && |
439 | chmod +x cccmd && | |
440 | git config sendemail.cccmd ./cccmd && | |
441 | test_suppression cccmd | |
442 | ' | |
443 | ||
f9444147 | 444 | test_expect_success $PREREQ 'setup expect' ' |
3531e270 JS |
445 | cat >expected-suppress-all <<\EOF |
446 | 0001-Second.patch | |
447 | Dry-OK. Log says: | |
448 | Server: relay.example.com | |
449 | MAIL FROM:<from@example.com> | |
450 | RCPT TO:<to@example.com> | |
451 | From: Example <from@example.com> | |
452 | To: to@example.com | |
453 | Subject: [PATCH 1/1] Second. | |
454 | Date: DATE-STRING | |
455 | Message-Id: MESSAGE-ID-STRING | |
456 | X-Mailer: X-MAILER-STRING | |
457 | ||
458 | Result: OK | |
459 | EOF | |
f9444147 | 460 | ' |
3531e270 | 461 | |
57cd35e6 | 462 | test_expect_success $PREREQ '--suppress-cc=all' ' |
3531e270 JS |
463 | test_suppression all |
464 | ' | |
465 | ||
f9444147 | 466 | test_expect_success $PREREQ 'setup expect' " |
3531e270 JS |
467 | cat >expected-suppress-body <<\EOF |
468 | 0001-Second.patch | |
469 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
470 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' | |
471 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
cb8a9bd5 | 472 | (cc-cmd) Adding cc: cc-cmd@example.com from: './cccmd' |
3531e270 JS |
473 | Dry-OK. Log says: |
474 | Server: relay.example.com | |
475 | MAIL FROM:<from@example.com> | |
02461e0e JP |
476 | RCPT TO:<to@example.com> |
477 | RCPT TO:<author@example.com> | |
478 | RCPT TO:<one@example.com> | |
479 | RCPT TO:<two@example.com> | |
480 | RCPT TO:<cc-cmd@example.com> | |
3531e270 JS |
481 | From: Example <from@example.com> |
482 | To: to@example.com | |
02461e0e JP |
483 | Cc: A <author@example.com>, |
484 | One <one@example.com>, | |
485 | two@example.com, | |
486 | cc-cmd@example.com | |
3531e270 JS |
487 | Subject: [PATCH 1/1] Second. |
488 | Date: DATE-STRING | |
489 | Message-Id: MESSAGE-ID-STRING | |
490 | X-Mailer: X-MAILER-STRING | |
491 | ||
492 | Result: OK | |
493 | EOF | |
f9444147 | 494 | " |
3531e270 | 495 | |
57cd35e6 | 496 | test_expect_success $PREREQ '--suppress-cc=body' ' |
3531e270 JS |
497 | test_suppression body |
498 | ' | |
499 | ||
f9444147 | 500 | test_expect_success $PREREQ 'setup expect' " |
cb8a9bd5 PB |
501 | cat >expected-suppress-body-cccmd <<\EOF |
502 | 0001-Second.patch | |
503 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
504 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' | |
505 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
506 | Dry-OK. Log says: | |
507 | Server: relay.example.com | |
508 | MAIL FROM:<from@example.com> | |
02461e0e JP |
509 | RCPT TO:<to@example.com> |
510 | RCPT TO:<author@example.com> | |
511 | RCPT TO:<one@example.com> | |
512 | RCPT TO:<two@example.com> | |
cb8a9bd5 PB |
513 | From: Example <from@example.com> |
514 | To: to@example.com | |
02461e0e JP |
515 | Cc: A <author@example.com>, |
516 | One <one@example.com>, | |
517 | two@example.com | |
cb8a9bd5 PB |
518 | Subject: [PATCH 1/1] Second. |
519 | Date: DATE-STRING | |
520 | Message-Id: MESSAGE-ID-STRING | |
521 | X-Mailer: X-MAILER-STRING | |
522 | ||
523 | Result: OK | |
524 | EOF | |
f9444147 | 525 | " |
cb8a9bd5 | 526 | |
57cd35e6 | 527 | test_expect_success $PREREQ '--suppress-cc=body --suppress-cc=cccmd' ' |
cb8a9bd5 PB |
528 | test_suppression body cccmd |
529 | ' | |
530 | ||
f9444147 | 531 | test_expect_success $PREREQ 'setup expect' " |
3531e270 JS |
532 | cat >expected-suppress-sob <<\EOF |
533 | 0001-Second.patch | |
534 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
535 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' | |
536 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
537 | Dry-OK. Log says: | |
538 | Server: relay.example.com | |
539 | MAIL FROM:<from@example.com> | |
02461e0e JP |
540 | RCPT TO:<to@example.com> |
541 | RCPT TO:<author@example.com> | |
542 | RCPT TO:<one@example.com> | |
543 | RCPT TO:<two@example.com> | |
3531e270 JS |
544 | From: Example <from@example.com> |
545 | To: to@example.com | |
02461e0e JP |
546 | Cc: A <author@example.com>, |
547 | One <one@example.com>, | |
548 | two@example.com | |
3531e270 JS |
549 | Subject: [PATCH 1/1] Second. |
550 | Date: DATE-STRING | |
551 | Message-Id: MESSAGE-ID-STRING | |
552 | X-Mailer: X-MAILER-STRING | |
553 | ||
554 | Result: OK | |
555 | EOF | |
f9444147 | 556 | " |
3531e270 | 557 | |
57cd35e6 | 558 | test_expect_success $PREREQ '--suppress-cc=sob' ' |
cb8a9bd5 | 559 | git config --unset sendemail.cccmd |
3531e270 JS |
560 | test_suppression sob |
561 | ' | |
562 | ||
f9444147 | 563 | test_expect_success $PREREQ 'setup expect' " |
3531e270 JS |
564 | cat >expected-suppress-bodycc <<\EOF |
565 | 0001-Second.patch | |
566 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
567 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' | |
568 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' | |
569 | (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>' | |
570 | Dry-OK. Log says: | |
571 | Server: relay.example.com | |
572 | MAIL FROM:<from@example.com> | |
02461e0e JP |
573 | RCPT TO:<to@example.com> |
574 | RCPT TO:<author@example.com> | |
575 | RCPT TO:<one@example.com> | |
576 | RCPT TO:<two@example.com> | |
577 | RCPT TO:<committer@example.com> | |
3531e270 JS |
578 | From: Example <from@example.com> |
579 | To: to@example.com | |
02461e0e JP |
580 | Cc: A <author@example.com>, |
581 | One <one@example.com>, | |
582 | two@example.com, | |
583 | C O Mitter <committer@example.com> | |
3531e270 JS |
584 | Subject: [PATCH 1/1] Second. |
585 | Date: DATE-STRING | |
586 | Message-Id: MESSAGE-ID-STRING | |
587 | X-Mailer: X-MAILER-STRING | |
588 | ||
589 | Result: OK | |
590 | EOF | |
f9444147 | 591 | " |
3531e270 | 592 | |
57cd35e6 | 593 | test_expect_success $PREREQ '--suppress-cc=bodycc' ' |
3531e270 JS |
594 | test_suppression bodycc |
595 | ' | |
596 | ||
f9444147 | 597 | test_expect_success $PREREQ 'setup expect' " |
3531e270 JS |
598 | cat >expected-suppress-cc <<\EOF |
599 | 0001-Second.patch | |
600 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' | |
601 | (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>' | |
602 | Dry-OK. Log says: | |
603 | Server: relay.example.com | |
604 | MAIL FROM:<from@example.com> | |
02461e0e JP |
605 | RCPT TO:<to@example.com> |
606 | RCPT TO:<author@example.com> | |
607 | RCPT TO:<committer@example.com> | |
3531e270 JS |
608 | From: Example <from@example.com> |
609 | To: to@example.com | |
02461e0e JP |
610 | Cc: A <author@example.com>, |
611 | C O Mitter <committer@example.com> | |
3531e270 JS |
612 | Subject: [PATCH 1/1] Second. |
613 | Date: DATE-STRING | |
614 | Message-Id: MESSAGE-ID-STRING | |
615 | X-Mailer: X-MAILER-STRING | |
616 | ||
617 | Result: OK | |
618 | EOF | |
f9444147 | 619 | " |
3531e270 | 620 | |
57cd35e6 | 621 | test_expect_success $PREREQ '--suppress-cc=cc' ' |
3531e270 | 622 | test_suppression cc |
33c592dd MV |
623 | ' |
624 | ||
c1f2aa45 JS |
625 | test_confirm () { |
626 | echo y | \ | |
627 | GIT_SEND_EMAIL_NOTTY=1 \ | |
628 | git send-email \ | |
629 | --from="Example <nobody@example.com>" \ | |
630 | --to=nobody@example.com \ | |
631 | --smtp-server="$(pwd)/fake.sendmail" \ | |
c18f75a1 JS |
632 | $@ $patches > stdout && |
633 | grep "Send this email" stdout | |
c1f2aa45 JS |
634 | } |
635 | ||
57cd35e6 | 636 | test_expect_success $PREREQ '--confirm=always' ' |
c1f2aa45 JS |
637 | test_confirm --confirm=always --suppress-cc=all |
638 | ' | |
639 | ||
57cd35e6 | 640 | test_expect_success $PREREQ '--confirm=auto' ' |
c1f2aa45 JS |
641 | test_confirm --confirm=auto |
642 | ' | |
643 | ||
57cd35e6 | 644 | test_expect_success $PREREQ '--confirm=cc' ' |
c1f2aa45 JS |
645 | test_confirm --confirm=cc |
646 | ' | |
647 | ||
57cd35e6 | 648 | test_expect_success $PREREQ '--confirm=compose' ' |
c1f2aa45 JS |
649 | test_confirm --confirm=compose --compose |
650 | ' | |
651 | ||
57cd35e6 | 652 | test_expect_success $PREREQ 'confirm by default (due to cc)' ' |
c1f2aa45 JS |
653 | CONFIRM=$(git config --get sendemail.confirm) && |
654 | git config --unset sendemail.confirm && | |
c18f75a1 JS |
655 | test_confirm |
656 | ret="$?" | |
657 | git config sendemail.confirm ${CONFIRM:-never} | |
658 | test $ret = "0" | |
c1f2aa45 JS |
659 | ' |
660 | ||
57cd35e6 | 661 | test_expect_success $PREREQ 'confirm by default (due to --compose)' ' |
c1f2aa45 JS |
662 | CONFIRM=$(git config --get sendemail.confirm) && |
663 | git config --unset sendemail.confirm && | |
664 | test_confirm --suppress-cc=all --compose | |
665 | ret="$?" | |
666 | git config sendemail.confirm ${CONFIRM:-never} | |
667 | test $ret = "0" | |
668 | ' | |
669 | ||
57cd35e6 | 670 | test_expect_success $PREREQ 'confirm detects EOF (inform assumes y)' ' |
c18f75a1 JS |
671 | CONFIRM=$(git config --get sendemail.confirm) && |
672 | git config --unset sendemail.confirm && | |
dc1460aa JS |
673 | rm -fr outdir && |
674 | git format-patch -2 -o outdir && | |
c18f75a1 JS |
675 | GIT_SEND_EMAIL_NOTTY=1 \ |
676 | git send-email \ | |
677 | --from="Example <nobody@example.com>" \ | |
678 | --to=nobody@example.com \ | |
679 | --smtp-server="$(pwd)/fake.sendmail" \ | |
dc1460aa | 680 | outdir/*.patch < /dev/null |
c18f75a1 JS |
681 | ret="$?" |
682 | git config sendemail.confirm ${CONFIRM:-never} | |
683 | test $ret = "0" | |
684 | ' | |
685 | ||
57cd35e6 | 686 | test_expect_success $PREREQ 'confirm detects EOF (auto causes failure)' ' |
c18f75a1 JS |
687 | CONFIRM=$(git config --get sendemail.confirm) && |
688 | git config sendemail.confirm auto && | |
3b3637c3 JS |
689 | GIT_SEND_EMAIL_NOTTY=1 && |
690 | export GIT_SEND_EMAIL_NOTTY && | |
c18f75a1 JS |
691 | test_must_fail git send-email \ |
692 | --from="Example <nobody@example.com>" \ | |
693 | --to=nobody@example.com \ | |
694 | --smtp-server="$(pwd)/fake.sendmail" \ | |
695 | $patches < /dev/null | |
696 | ret="$?" | |
697 | git config sendemail.confirm ${CONFIRM:-never} | |
698 | test $ret = "0" | |
699 | ' | |
700 | ||
57cd35e6 | 701 | test_expect_success $PREREQ 'confirm doesnt loop forever' ' |
c18f75a1 JS |
702 | CONFIRM=$(git config --get sendemail.confirm) && |
703 | git config sendemail.confirm auto && | |
3b3637c3 JS |
704 | GIT_SEND_EMAIL_NOTTY=1 && |
705 | export GIT_SEND_EMAIL_NOTTY && | |
706 | yes "bogus" | test_must_fail git send-email \ | |
c18f75a1 JS |
707 | --from="Example <nobody@example.com>" \ |
708 | --to=nobody@example.com \ | |
709 | --smtp-server="$(pwd)/fake.sendmail" \ | |
710 | $patches | |
711 | ret="$?" | |
712 | git config sendemail.confirm ${CONFIRM:-never} | |
713 | test $ret = "0" | |
714 | ' | |
715 | ||
57cd35e6 | 716 | test_expect_success $PREREQ 'utf8 Cc is rfc2047 encoded' ' |
a61c0ffa JS |
717 | clean_fake_sendmail && |
718 | rm -fr outdir && | |
719 | git format-patch -1 -o outdir --cc="àéìöú <utf8@example.com>" && | |
720 | git send-email \ | |
721 | --from="Example <nobody@example.com>" \ | |
722 | --to=nobody@example.com \ | |
723 | --smtp-server="$(pwd)/fake.sendmail" \ | |
724 | outdir/*.patch && | |
02461e0e | 725 | grep "^ " msgtxt1 | |
d1fff6fc | 726 | grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>" |
a61c0ffa JS |
727 | ' |
728 | ||
57cd35e6 | 729 | test_expect_success $PREREQ '--compose adds MIME for utf8 body' ' |
0706bd19 | 730 | clean_fake_sendmail && |
bb3e4f03 | 731 | (echo "#!$SHELL_PATH" && |
c01cdde1 | 732 | echo "echo utf8 body: àéìöú >>\"\$1\"" |
0706bd19 JK |
733 | ) >fake-editor-utf8 && |
734 | chmod +x fake-editor-utf8 && | |
c01cdde1 | 735 | GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \ |
0706bd19 JK |
736 | git send-email \ |
737 | --compose --subject foo \ | |
738 | --from="Example <nobody@example.com>" \ | |
739 | --to=nobody@example.com \ | |
740 | --smtp-server="$(pwd)/fake.sendmail" \ | |
741 | $patches && | |
742 | grep "^utf8 body" msgtxt1 && | |
d1fff6fc | 743 | grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1 |
0706bd19 JK |
744 | ' |
745 | ||
57cd35e6 | 746 | test_expect_success $PREREQ '--compose respects user mime type' ' |
0706bd19 | 747 | clean_fake_sendmail && |
bb3e4f03 | 748 | (echo "#!$SHELL_PATH" && |
0706bd19 JK |
749 | echo "(echo MIME-Version: 1.0" |
750 | echo " echo Content-Type: text/plain\\; charset=iso-8859-1" | |
751 | echo " echo Content-Transfer-Encoding: 8bit" | |
752 | echo " echo Subject: foo" | |
753 | echo " echo " | |
c01cdde1 | 754 | echo " echo utf8 body: àéìöú) >\"\$1\"" |
0706bd19 JK |
755 | ) >fake-editor-utf8-mime && |
756 | chmod +x fake-editor-utf8-mime && | |
c01cdde1 | 757 | GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \ |
0706bd19 JK |
758 | git send-email \ |
759 | --compose --subject foo \ | |
760 | --from="Example <nobody@example.com>" \ | |
761 | --to=nobody@example.com \ | |
762 | --smtp-server="$(pwd)/fake.sendmail" \ | |
763 | $patches && | |
764 | grep "^utf8 body" msgtxt1 && | |
765 | grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 && | |
d1fff6fc | 766 | ! grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1 |
0706bd19 JK |
767 | ' |
768 | ||
57cd35e6 | 769 | test_expect_success $PREREQ '--compose adds MIME for utf8 subject' ' |
d54eaaa2 | 770 | clean_fake_sendmail && |
c01cdde1 | 771 | GIT_EDITOR="\"$(pwd)/fake-editor\"" \ |
d54eaaa2 JK |
772 | git send-email \ |
773 | --compose --subject utf8-sübjëct \ | |
774 | --from="Example <nobody@example.com>" \ | |
775 | --to=nobody@example.com \ | |
776 | --smtp-server="$(pwd)/fake.sendmail" \ | |
777 | $patches && | |
778 | grep "^fake edit" msgtxt1 && | |
d1fff6fc | 779 | grep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1 |
d54eaaa2 JK |
780 | ' |
781 | ||
57cd35e6 | 782 | test_expect_success $PREREQ 'detects ambiguous reference/file conflict' ' |
5df9fcf6 PH |
783 | echo master > master && |
784 | git add master && | |
785 | git commit -m"add master" && | |
786 | test_must_fail git send-email --dry-run master 2>errors && | |
787 | grep disambiguate errors | |
788 | ' | |
789 | ||
57cd35e6 | 790 | test_expect_success $PREREQ 'feed two files' ' |
69f4ce55 JH |
791 | rm -fr outdir && |
792 | git format-patch -2 -o outdir && | |
c1f2aa45 | 793 | git send-email \ |
69f4ce55 JH |
794 | --dry-run \ |
795 | --from="Example <nobody@example.com>" \ | |
796 | --to=nobody@example.com \ | |
797 | outdir/000?-*.patch 2>errors >out && | |
798 | grep "^Subject: " out >subjects && | |
799 | test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." && | |
800 | test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add master" | |
801 | ' | |
802 | ||
57cd35e6 | 803 | test_expect_success $PREREQ 'in-reply-to but no threading' ' |
aaab4b9f TR |
804 | git send-email \ |
805 | --dry-run \ | |
806 | --from="Example <nobody@example.com>" \ | |
807 | --to=nobody@example.com \ | |
808 | --in-reply-to="<in-reply-id@example.com>" \ | |
84eeb687 | 809 | --nothread \ |
aaab4b9f TR |
810 | $patches | |
811 | grep "In-Reply-To: <in-reply-id@example.com>" | |
812 | ' | |
813 | ||
57cd35e6 | 814 | test_expect_success $PREREQ 'no in-reply-to and no threading' ' |
32ae8319 MH |
815 | git send-email \ |
816 | --dry-run \ | |
817 | --from="Example <nobody@example.com>" \ | |
818 | --to=nobody@example.com \ | |
819 | --nothread \ | |
820 | $patches $patches >stdout && | |
821 | ! grep "In-Reply-To: " stdout | |
822 | ' | |
823 | ||
57cd35e6 | 824 | test_expect_success $PREREQ 'threading but no chain-reply-to' ' |
d67114a5 MH |
825 | git send-email \ |
826 | --dry-run \ | |
827 | --from="Example <nobody@example.com>" \ | |
828 | --to=nobody@example.com \ | |
829 | --thread \ | |
830 | --nochain-reply-to \ | |
831 | $patches $patches >stdout && | |
832 | grep "In-Reply-To: " stdout | |
833 | ' | |
834 | ||
57cd35e6 | 835 | test_expect_success $PREREQ 'warning with an implicit --chain-reply-to' ' |
528fb087 NS |
836 | git send-email \ |
837 | --dry-run \ | |
838 | --from="Example <nobody@example.com>" \ | |
839 | --to=nobody@example.com \ | |
840 | outdir/000?-*.patch 2>errors >out && | |
841 | grep "no-chain-reply-to" errors | |
842 | ' | |
843 | ||
57cd35e6 | 844 | test_expect_success $PREREQ 'no warning with an explicit --chain-reply-to' ' |
528fb087 NS |
845 | git send-email \ |
846 | --dry-run \ | |
847 | --from="Example <nobody@example.com>" \ | |
848 | --to=nobody@example.com \ | |
849 | --chain-reply-to \ | |
850 | outdir/000?-*.patch 2>errors >out && | |
851 | ! grep "no-chain-reply-to" errors | |
852 | ' | |
853 | ||
57cd35e6 | 854 | test_expect_success $PREREQ 'no warning with an explicit --no-chain-reply-to' ' |
528fb087 NS |
855 | git send-email \ |
856 | --dry-run \ | |
857 | --from="Example <nobody@example.com>" \ | |
858 | --to=nobody@example.com \ | |
907a0b1e | 859 | --nochain-reply-to \ |
528fb087 NS |
860 | outdir/000?-*.patch 2>errors >out && |
861 | ! grep "no-chain-reply-to" errors | |
862 | ' | |
863 | ||
57cd35e6 | 864 | test_expect_success $PREREQ 'no warning with sendemail.chainreplyto = false' ' |
528fb087 NS |
865 | git config sendemail.chainreplyto false && |
866 | git send-email \ | |
867 | --dry-run \ | |
868 | --from="Example <nobody@example.com>" \ | |
869 | --to=nobody@example.com \ | |
870 | outdir/000?-*.patch 2>errors >out && | |
871 | ! grep "no-chain-reply-to" errors | |
872 | ' | |
873 | ||
57cd35e6 | 874 | test_expect_success $PREREQ 'no warning with sendemail.chainreplyto = true' ' |
528fb087 NS |
875 | git config sendemail.chainreplyto true && |
876 | git send-email \ | |
877 | --dry-run \ | |
878 | --from="Example <nobody@example.com>" \ | |
879 | --to=nobody@example.com \ | |
880 | outdir/000?-*.patch 2>errors >out && | |
881 | ! grep "no-chain-reply-to" errors | |
882 | ' | |
883 | ||
57cd35e6 | 884 | test_expect_success $PREREQ 'sendemail.to works' ' |
f434c083 SB |
885 | git config --replace-all sendemail.to "Somebody <somebody@ex.com>" && |
886 | git send-email \ | |
887 | --dry-run \ | |
888 | --from="Example <nobody@example.com>" \ | |
889 | $patches $patches >stdout && | |
890 | grep "To: Somebody <somebody@ex.com>" stdout | |
891 | ' | |
892 | ||
57cd35e6 | 893 | test_expect_success $PREREQ '--no-to overrides sendemail.to' ' |
f434c083 SB |
894 | git send-email \ |
895 | --dry-run \ | |
896 | --from="Example <nobody@example.com>" \ | |
897 | --no-to \ | |
898 | --to=nobody@example.com \ | |
899 | $patches $patches >stdout && | |
900 | grep "To: nobody@example.com" stdout && | |
901 | ! grep "To: Somebody <somebody@ex.com>" stdout | |
902 | ' | |
903 | ||
57cd35e6 | 904 | test_expect_success $PREREQ 'sendemail.cc works' ' |
f434c083 SB |
905 | git config --replace-all sendemail.cc "Somebody <somebody@ex.com>" && |
906 | git send-email \ | |
907 | --dry-run \ | |
908 | --from="Example <nobody@example.com>" \ | |
909 | --to=nobody@example.com \ | |
910 | $patches $patches >stdout && | |
911 | grep "Cc: Somebody <somebody@ex.com>" stdout | |
912 | ' | |
913 | ||
57cd35e6 | 914 | test_expect_success $PREREQ '--no-cc overrides sendemail.cc' ' |
f434c083 SB |
915 | git send-email \ |
916 | --dry-run \ | |
917 | --from="Example <nobody@example.com>" \ | |
918 | --no-cc \ | |
919 | --cc=bodies@example.com \ | |
920 | --to=nobody@example.com \ | |
921 | $patches $patches >stdout && | |
922 | grep "Cc: bodies@example.com" stdout && | |
923 | ! grep "Cc: Somebody <somebody@ex.com>" stdout | |
924 | ' | |
925 | ||
57cd35e6 | 926 | test_expect_success $PREREQ 'sendemail.bcc works' ' |
f434c083 SB |
927 | git config --replace-all sendemail.bcc "Other <other@ex.com>" && |
928 | git send-email \ | |
929 | --dry-run \ | |
930 | --from="Example <nobody@example.com>" \ | |
931 | --to=nobody@example.com \ | |
932 | --smtp-server relay.example.com \ | |
933 | $patches $patches >stdout && | |
934 | grep "RCPT TO:<other@ex.com>" stdout | |
935 | ' | |
936 | ||
57cd35e6 | 937 | test_expect_success $PREREQ '--no-bcc overrides sendemail.bcc' ' |
f434c083 SB |
938 | git send-email \ |
939 | --dry-run \ | |
940 | --from="Example <nobody@example.com>" \ | |
941 | --no-bcc \ | |
942 | --bcc=bodies@example.com \ | |
943 | --to=nobody@example.com \ | |
944 | --smtp-server relay.example.com \ | |
945 | $patches $patches >stdout && | |
946 | grep "RCPT TO:<bodies@example.com>" stdout && | |
947 | ! grep "RCPT TO:<other@ex.com>" stdout | |
948 | ' | |
949 | ||
f9444147 | 950 | test_expect_success $PREREQ 'setup expect' ' |
3cae7e5b TR |
951 | cat >email-using-8bit <<EOF |
952 | From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001 | |
953 | Message-Id: <bogus-message-id@example.com> | |
954 | From: author@example.com | |
955 | Date: Sat, 12 Jun 2010 15:53:58 +0200 | |
956 | Subject: subject goes here | |
957 | ||
958 | Dieser deutsche Text enthält einen Umlaut! | |
959 | EOF | |
f9444147 | 960 | ' |
3cae7e5b | 961 | |
f9444147 | 962 | test_expect_success $PREREQ 'setup expect' ' |
3cae7e5b TR |
963 | cat >content-type-decl <<EOF |
964 | MIME-Version: 1.0 | |
965 | Content-Type: text/plain; charset=UTF-8 | |
966 | Content-Transfer-Encoding: 8bit | |
967 | EOF | |
f9444147 | 968 | ' |
3cae7e5b | 969 | |
57cd35e6 | 970 | test_expect_success $PREREQ 'asks about and fixes 8bit encodings' ' |
3cae7e5b TR |
971 | clean_fake_sendmail && |
972 | echo | | |
973 | git send-email --from=author@example.com --to=nobody@example.com \ | |
974 | --smtp-server="$(pwd)/fake.sendmail" \ | |
975 | email-using-8bit >stdout && | |
976 | grep "do not declare a Content-Transfer-Encoding" stdout && | |
977 | grep email-using-8bit stdout && | |
978 | grep "Which 8bit encoding" stdout && | |
31832862 | 979 | egrep "Content|MIME" msgtxt1 >actual && |
3cae7e5b TR |
980 | test_cmp actual content-type-decl |
981 | ' | |
982 | ||
57cd35e6 | 983 | test_expect_success $PREREQ 'sendemail.8bitEncoding works' ' |
3cae7e5b TR |
984 | clean_fake_sendmail && |
985 | git config sendemail.assume8bitEncoding UTF-8 && | |
986 | echo bogus | | |
987 | git send-email --from=author@example.com --to=nobody@example.com \ | |
988 | --smtp-server="$(pwd)/fake.sendmail" \ | |
989 | email-using-8bit >stdout && | |
31832862 | 990 | egrep "Content|MIME" msgtxt1 >actual && |
3cae7e5b TR |
991 | test_cmp actual content-type-decl |
992 | ' | |
993 | ||
57cd35e6 | 994 | test_expect_success $PREREQ '--8bit-encoding overrides sendemail.8bitEncoding' ' |
3cae7e5b TR |
995 | clean_fake_sendmail && |
996 | git config sendemail.assume8bitEncoding "bogus too" && | |
997 | echo bogus | | |
998 | git send-email --from=author@example.com --to=nobody@example.com \ | |
999 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1000 | --8bit-encoding=UTF-8 \ | |
1001 | email-using-8bit >stdout && | |
31832862 | 1002 | egrep "Content|MIME" msgtxt1 >actual && |
3cae7e5b TR |
1003 | test_cmp actual content-type-decl |
1004 | ' | |
1005 | ||
f9444147 | 1006 | test_expect_success $PREREQ 'setup expect' ' |
3cae7e5b TR |
1007 | cat >email-using-8bit <<EOF |
1008 | From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001 | |
1009 | Message-Id: <bogus-message-id@example.com> | |
1010 | From: author@example.com | |
1011 | Date: Sat, 12 Jun 2010 15:53:58 +0200 | |
1012 | Subject: Dieser Betreff enthält auch einen Umlaut! | |
1013 | ||
1014 | Nothing to see here. | |
1015 | EOF | |
f9444147 | 1016 | ' |
3cae7e5b | 1017 | |
f9444147 | 1018 | test_expect_success $PREREQ 'setup expect' ' |
3cae7e5b TR |
1019 | cat >expected <<EOF |
1020 | Subject: =?UTF-8?q?Dieser=20Betreff=20enth=C3=A4lt=20auch=20einen=20Umlaut!?= | |
1021 | EOF | |
f9444147 | 1022 | ' |
3cae7e5b | 1023 | |
57cd35e6 | 1024 | test_expect_success $PREREQ '--8bit-encoding also treats subject' ' |
3cae7e5b TR |
1025 | clean_fake_sendmail && |
1026 | echo bogus | | |
1027 | git send-email --from=author@example.com --to=nobody@example.com \ | |
1028 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1029 | --8bit-encoding=UTF-8 \ | |
1030 | email-using-8bit >stdout && | |
1031 | grep "Subject" msgtxt1 >actual && | |
1032 | test_cmp expected actual | |
1033 | ' | |
1034 | ||
a03bc5b6 TR |
1035 | # Note that the patches in this test are deliberately out of order; we |
1036 | # want to make sure it works even if the cover-letter is not in the | |
1037 | # first mail. | |
57da2042 | 1038 | test_expect_success $PREREQ 'refusing to send cover letter template' ' |
a03bc5b6 TR |
1039 | clean_fake_sendmail && |
1040 | rm -fr outdir && | |
1041 | git format-patch --cover-letter -2 -o outdir && | |
1042 | test_must_fail git send-email \ | |
1043 | --from="Example <nobody@example.com>" \ | |
1044 | --to=nobody@example.com \ | |
1045 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1046 | outdir/0002-*.patch \ | |
1047 | outdir/0000-*.patch \ | |
1048 | outdir/0001-*.patch \ | |
1049 | 2>errors >out && | |
1050 | grep "SUBJECT HERE" errors && | |
1051 | test -z "$(ls msgtxt*)" | |
1052 | ' | |
1053 | ||
57da2042 | 1054 | test_expect_success $PREREQ '--force sends cover letter template anyway' ' |
a03bc5b6 TR |
1055 | clean_fake_sendmail && |
1056 | rm -fr outdir && | |
1057 | git format-patch --cover-letter -2 -o outdir && | |
1058 | git send-email \ | |
1059 | --force \ | |
1060 | --from="Example <nobody@example.com>" \ | |
1061 | --to=nobody@example.com \ | |
1062 | --smtp-server="$(pwd)/fake.sendmail" \ | |
1063 | outdir/0002-*.patch \ | |
1064 | outdir/0000-*.patch \ | |
1065 | outdir/0001-*.patch \ | |
1066 | 2>errors >out && | |
1067 | ! grep "SUBJECT HERE" errors && | |
1068 | test -n "$(ls msgtxt*)" | |
1069 | ' | |
1070 | ||
ce903018 | 1071 | test_done |