@matheusbsbs / matheus-bagliano / commits / cb8a9bd518
Fork 0

Test cccmd in t9001-send-email.sh and fix some bugs

For another patch series I'm working on I needed some tests for the cc-cmd feature of git-send-email. This patch adds 3 tests for the feature and for the possibility to specify --suppress-cc multiple times, and fixes two bugs. The first bug is that the --suppress-cc option for `cccmd' was misspelled as `ccmd' in the code. The second bug, which is actually found only with my other series, is that the argument to the cccmd is never quoted, so the cccmd would fail with patch file names containing a space. A third bug I fix (in the docs) is that the bodycc argument was actually spelled ccbody in the documentation and bash completion. Signed-off-by: Paolo Bonzini <bonzini@gnu.org> Cc: Markus Heidelberg <markus.heidelberg@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Paolo Bonzini committed Jun 18, 2009 at 14:31 UTC cb8a9bd518002dd4fb693df6230b4976bafc15e0
4 files changed +80 -10
Documentation/git-send-email.txt
+2 -2
@@ -193,12 +193,12 @@ Automating
193 - 'self' will avoid including the sender
194 - 'cc' will avoid including anyone mentioned in Cc lines in the patch header
195 except for self (use 'self' for that).
196 -- 'ccbody' will avoid including anyone mentioned in Cc lines in the
196 +- 'bodycc' will avoid including anyone mentioned in Cc lines in the
197 patch body (commit message) except for self (use 'self' for that).
198 - 'sob' will avoid including anyone mentioned in Signed-off-by lines except
199 for self (use 'self' for that).
200 - 'cccmd' will avoid running the --cc-cmd.
201 -- 'body' is equivalent to 'sob' + 'ccbody'
201 +- 'body' is equivalent to 'sob' + 'bodycc'
202 - 'all' will suppress all auto cc values.
203 --
204 +
contrib/completion/git-completion.bash
+1 -1
@@ -1299,7 +1299,7 @@ _git_rebase ()
1299 }
1300
1301 __git_send_email_confirm_options="always never auto cc compose"
1302 -__git_send_email_suppresscc_options="author self cc ccbody sob cccmd body all"
1302 +__git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all"
1303
1304 _git_send_email ()
1305 {
git-send-email.perl
+2 -2
@@ -334,7 +334,7 @@ if (@suppress_cc) {
334 }
335
336 if ($suppress_cc{'all'}) {
337 - foreach my $entry (qw (ccmd cc author self sob body bodycc)) {
337 + foreach my $entry (qw (cccmd cc author self sob body bodycc)) {
338 $suppress_cc{$entry} = 1;
339 }
340 delete $suppress_cc{'all'};
@@ -1104,7 +1104,7 @@ foreach my $t (@files) {
1104 close F;
1105
1106 if (defined $cc_cmd && !$suppress_cc{'cccmd'}) {
1107 - open(F, "$cc_cmd $t |")
1107 + open(F, "$cc_cmd \Q$t\E |")
1108 or die "(cc-cmd) Could not execute '$cc_cmd'";
1109 while(<F>) {
1110 my $c = $_;
t/t9001-send-email.sh
+75 -5
@@ -148,6 +148,22 @@ test_expect_success 'Prompting works' '
148 grep "^To: to@example.com$" msgtxt1
149 '
150
151 +test_expect_success 'cccmd works' '
152 + clean_fake_sendmail &&
153 + cp $patches cccmd.patch &&
154 + echo cccmd--cccmd@example.com >>cccmd.patch &&
155 + echo sed -n s/^cccmd--//p \"\$1\" > cccmd-sed &&
156 + chmod +x cccmd-sed &&
157 + git send-email \
158 + --from="Example <nobody@example.com>" \
159 + --to=nobody@example.com \
160 + --cc-cmd=./cccmd-sed \
161 + --smtp-server="$(pwd)/fake.sendmail" \
162 + cccmd.patch \
163 + &&
164 + grep ^Cc:.*cccmd@example.com msgtxt1
165 +'
166 +
167 z8=zzzzzzzz
168 z64=$z8$z8$z8$z8$z8$z8$z8$z8
169 z512=$z64$z64$z64$z64$z64$z64$z64$z64
@@ -274,7 +290,7 @@ EOF
290 test_suppression () {
291 git send-email \
292 --dry-run \
277 - --suppress-cc=$1 \
293 + --suppress-cc=$1 ${2+"--suppress-cc=$2"} \
294 --from="Example <from@example.com>" \
295 --to=to@example.com \
296 --smtp-server relay.example.com \
@@ -282,8 +298,8 @@ test_suppression () {
298 sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
299 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
300 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
285 - >actual-suppress-$1 &&
286 - test_cmp expected-suppress-$1 actual-suppress-$1
301 + >actual-suppress-$1${2+"-$2"} &&
302 + test_cmp expected-suppress-$1${2+"-$2"} actual-suppress-$1${2+"-$2"}
303 }
304
305 test_expect_success 'sendemail.cc set' '
@@ -316,6 +332,34 @@ test_expect_success 'sendemail.cc unset' '
332 test_suppression sob
333 '
334
335 +cat >expected-suppress-cccmd <<\EOF
336 +0001-Second.patch
337 +(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
338 +(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
339 +(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
340 +(body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
341 +Dry-OK. Log says:
342 +Server: relay.example.com
343 +MAIL FROM:<from@example.com>
344 +RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<committer@example.com>
345 +From: Example <from@example.com>
346 +To: to@example.com
347 +Cc: A <author@example.com>, One <one@example.com>, two@example.com, C O Mitter <committer@example.com>
348 +Subject: [PATCH 1/1] Second.
349 +Date: DATE-STRING
350 +Message-Id: MESSAGE-ID-STRING
351 +X-Mailer: X-MAILER-STRING
352 +
353 +Result: OK
354 +EOF
355 +
356 +test_expect_success 'sendemail.cccmd' '
357 + echo echo cc-cmd@example.com > cccmd &&
358 + chmod +x cccmd &&
359 + git config sendemail.cccmd ./cccmd &&
360 + test_suppression cccmd
361 +'
362 +
363 cat >expected-suppress-all <<\EOF
364 0001-Second.patch
365 Dry-OK. Log says:
@@ -341,13 +385,14 @@ cat >expected-suppress-body <<\EOF
385 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
386 (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
387 (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
388 +(cc-cmd) Adding cc: cc-cmd@example.com from: './cccmd'
389 Dry-OK. Log says:
390 Server: relay.example.com
391 MAIL FROM:<from@example.com>
347 -RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>
392 +RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<cc-cmd@example.com>
393 From: Example <from@example.com>
394 To: to@example.com
350 -Cc: A <author@example.com>, One <one@example.com>, two@example.com
395 +Cc: A <author@example.com>, One <one@example.com>, two@example.com, cc-cmd@example.com
396 Subject: [PATCH 1/1] Second.
397 Date: DATE-STRING
398 Message-Id: MESSAGE-ID-STRING
@@ -360,6 +405,30 @@ test_expect_success '--suppress-cc=body' '
405 test_suppression body
406 '
407
408 +cat >expected-suppress-body-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 +Dry-OK. Log says:
414 +Server: relay.example.com
415 +MAIL FROM:<from@example.com>
416 +RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>
417 +From: Example <from@example.com>
418 +To: to@example.com
419 +Cc: A <author@example.com>, One <one@example.com>, two@example.com
420 +Subject: [PATCH 1/1] Second.
421 +Date: DATE-STRING
422 +Message-Id: MESSAGE-ID-STRING
423 +X-Mailer: X-MAILER-STRING
424 +
425 +Result: OK
426 +EOF
427 +
428 +test_expect_success '--suppress-cc=body --suppress-cc=cccmd' '
429 + test_suppression body cccmd
430 +'
431 +
432 cat >expected-suppress-sob <<\EOF
433 0001-Second.patch
434 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
@@ -381,6 +450,7 @@ Result: OK
450 EOF
451
452 test_expect_success '--suppress-cc=sob' '
453 + git config --unset sendemail.cccmd
454 test_suppression sob
455 '
456