]> git.ipfire.org Git - thirdparty/git.git/commitdiff
send-email: allow aliases in patch header and command script outputs
authorRemi Lespinet <remi.lespinet@ensimag.grenoble-inp.fr>
Tue, 30 Jun 2015 12:16:43 +0000 (14:16 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 30 Jun 2015 18:34:34 +0000 (11:34 -0700)
Interpret aliases in:

  -  Header fields of patches generated by git format-patch
     (using --to, --cc, --add-header for example) or
     manually modified. Example of fields in header:

      To: alias1
Cc: alias2
Cc: alias3
  -  Outputs of command scripts specified by --cc-cmd and
     --to-cmd. Example of script:

      #!/bin/sh
      echo alias1
      echo alias2

Signed-off-by: Remi Lespinet <remi.lespinet@ensimag.grenoble-inp.fr>
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-send-email.perl
t/t9001-send-email.sh

index e1e9b1460ced5f660b32796890df7336bc3d01af..0cac4b0077b9211d1759f4ba9a66dd98c716ebc5 100755 (executable)
@@ -1535,7 +1535,9 @@ foreach my $t (@files) {
                ($confirm =~ /^(?:auto|compose)$/ && $compose && $message_num == 1));
        $needs_confirm = "inform" if ($needs_confirm && $confirm_unconfigured && @cc);
 
+       @to = expand_aliases(@to);
        @to = validate_address_list(sanitize_address_list(@to));
+       @cc = expand_aliases(@cc);
        @cc = validate_address_list(sanitize_address_list(@cc));
 
        @to = (@initial_to, @to);
index e63fc8376be628572353499ae6b98161c2007ee6..062c703b28b7ae5cec1e64cc4477a8014423d5a9 100755 (executable)
@@ -1552,6 +1552,66 @@ test_expect_success $PREREQ 'sendemail.aliasfile=~/.mailrc' '
        grep "^!someone@example\.org!$" commandline1
 '
 
+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 &&