OSDN Git Service

Merge branch 'rl/send-email-aliases'
authorJunio C Hamano <gitster@pobox.com>
Mon, 3 Aug 2015 18:01:15 +0000 (11:01 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 3 Aug 2015 18:01:15 +0000 (11:01 -0700)
"git send-email" now performs alias-expansion on names that are
given via --cccmd, etc.

This round comes with a lot more enhanced e-mail address parser,
which makes it a bit scary, but as long as it works as designed, it
makes it wonderful ;-).

* rl/send-email-aliases:
  send-email: suppress meaningless whitespaces in from field
  send-email: allow multiple emails using --cc, --to and --bcc
  send-email: consider quote as delimiter instead of character
  send-email: reduce dependencies impact on parse_address_line
  send-email: minor code refactoring
  send-email: allow use of aliases in the From field of --compose mode
  send-email: refactor address list process
  t9001-send-email: refactor header variable fields replacement
  send-email: allow aliases in patch header and command script outputs
  t9001-send-email: move script creation in a setup test

1  2 
Documentation/git-send-email.txt
git-send-email.perl
t/t9001-send-email.sh

Simple merge
Simple merge
@@@ -1549,78 -1555,66 +1555,138 @@@ test_expect_success $PREREQ 'sendemail.
        grep "^!someone@example\.org!$" commandline1
  '
  
 +test_sendmail_aliases () {
 +      msg="$1" && shift &&
 +      expect="$@" &&
 +      cat >.tmp-email-aliases &&
 +
 +      test_expect_success $PREREQ "$msg" '
 +              clean_fake_sendmail && rm -fr outdir &&
 +              git format-patch -1 -o outdir &&
 +              git config --replace-all sendemail.aliasesfile \
 +                      "$(pwd)/.tmp-email-aliases" &&
 +              git config sendemail.aliasfiletype sendmail &&
 +              git send-email \
 +                      --from="Example <nobody@example.com>" \
 +                      --to=alice --to=bcgrp \
 +                      --smtp-server="$(pwd)/fake.sendmail" \
 +                      outdir/0001-*.patch \
 +                      2>errors >out &&
 +              for i in $expect
 +              do
 +                      grep "^!$i!$" commandline1 || return 1
 +              done
 +      '
 +}
 +
 +test_sendmail_aliases 'sendemail.aliasfiletype=sendmail' \
 +      'awol@example\.com' \
 +      'bob@example\.com' \
 +      'chloe@example\.com' \
 +      'o@example\.com' <<-\EOF
 +      alice: Alice W Land <awol@example.com>
 +      bob: Robert Bobbyton <bob@example.com>
 +      # this is a comment
 +         # this is also a comment
 +      chloe: chloe@example.com
 +      abgroup: alice, bob
 +      bcgrp: bob, chloe, Other <o@example.com>
 +      EOF
 +
 +test_sendmail_aliases 'sendmail aliases line folding' \
 +      alice1 \
 +      bob1 bob2 \
 +      chuck1 chuck2 \
 +      darla1 darla2 darla3 \
 +      elton1 elton2 elton3 \
 +      fred1 fred2 \
 +      greg1 <<-\EOF
 +      alice: alice1
 +      bob: bob1,\
 +      bob2
 +      chuck: chuck1,
 +          chuck2
 +      darla: darla1,\
 +      darla2,
 +          darla3
 +      elton: elton1,
 +          elton2,\
 +      elton3
 +      fred: fred1,\
 +          fred2
 +      greg: greg1
 +      bcgrp: bob, chuck, darla, elton, fred, greg
 +      EOF
 +
 +test_sendmail_aliases 'sendmail aliases tolerate bogus line folding' \
 +      alice1 bob1 <<-\EOF
 +          alice: alice1
 +      bcgrp: bob1\
 +      EOF
 +
 +test_sendmail_aliases 'sendmail aliases empty' alice bcgrp <<-\EOF
 +      EOF
 +
+ test_expect_success $PREREQ 'alias support in To header' '
+       clean_fake_sendmail &&
+       echo "alias sbd  someone@example.org" >.mailrc &&
+       test_config sendemail.aliasesfile ".mailrc" &&
+       test_config sendemail.aliasfiletype mailrc &&
+       git format-patch --stdout -1 --to=sbd >aliased.patch &&
+       git send-email \
+               --from="Example <nobody@example.com>" \
+               --smtp-server="$(pwd)/fake.sendmail" \
+               aliased.patch \
+               2>errors >out &&
+       grep "^!someone@example\.org!$" commandline1
+ '
+ test_expect_success $PREREQ 'alias support in Cc header' '
+       clean_fake_sendmail &&
+       echo "alias sbd  someone@example.org" >.mailrc &&
+       test_config sendemail.aliasesfile ".mailrc" &&
+       test_config sendemail.aliasfiletype mailrc &&
+       git format-patch --stdout -1 --cc=sbd >aliased.patch &&
+       git send-email \
+               --from="Example <nobody@example.com>" \
+               --smtp-server="$(pwd)/fake.sendmail" \
+               aliased.patch \
+               2>errors >out &&
+       grep "^!someone@example\.org!$" commandline1
+ '
+ test_expect_success $PREREQ 'tocmd works with aliases' '
+       clean_fake_sendmail &&
+       echo "alias sbd  someone@example.org" >.mailrc &&
+       test_config sendemail.aliasesfile ".mailrc" &&
+       test_config sendemail.aliasfiletype mailrc &&
+       git format-patch --stdout -1 >tocmd.patch &&
+       echo tocmd--sbd >>tocmd.patch &&
+       git send-email \
+               --from="Example <nobody@example.com>" \
+               --to-cmd=./tocmd-sed \
+               --smtp-server="$(pwd)/fake.sendmail" \
+               tocmd.patch \
+               2>errors >out &&
+       grep "^!someone@example\.org!$" commandline1
+ '
+ test_expect_success $PREREQ 'cccmd works with aliases' '
+       clean_fake_sendmail &&
+       echo "alias sbd  someone@example.org" >.mailrc &&
+       test_config sendemail.aliasesfile ".mailrc" &&
+       test_config sendemail.aliasfiletype mailrc &&
+       git format-patch --stdout -1 >cccmd.patch &&
+       echo cccmd--sbd >>cccmd.patch &&
+       git send-email \
+               --from="Example <nobody@example.com>" \
+               --cc-cmd=./cccmd-sed \
+               --smtp-server="$(pwd)/fake.sendmail" \
+               cccmd.patch \
+               2>errors >out &&
+       grep "^!someone@example\.org!$" commandline1
+ '
  do_xmailer_test () {
        expected=$1 params=$2 &&
        git format-patch -1 &&