Skip to content

Commit f6f79e5

Browse files
Awaryngitster
authored andcommitted
send-email: allow aliases in patch header and command script outputs
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 <[email protected]> Signed-off-by: Matthieu Moy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 62089fb commit f6f79e5

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

git-send-email.perl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,7 +1535,9 @@ sub send_message {
15351535
($confirm =~ /^(?:auto|compose)$/ && $compose && $message_num == 1));
15361536
$needs_confirm = "inform" if ($needs_confirm && $confirm_unconfigured && @cc);
15371537

1538+
@to = expand_aliases(@to);
15381539
@to = validate_address_list(sanitize_address_list(@to));
1540+
@cc = expand_aliases(@cc);
15391541
@cc = validate_address_list(sanitize_address_list(@cc));
15401542

15411543
@to = (@initial_to, @to);

t/t9001-send-email.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,6 +1552,66 @@ test_expect_success $PREREQ 'sendemail.aliasfile=~/.mailrc' '
15521552
grep "^!someone@example\.org!$" commandline1
15531553
'
15541554

1555+
test_expect_success $PREREQ 'alias support in To header' '
1556+
clean_fake_sendmail &&
1557+
echo "alias sbd [email protected]" >.mailrc &&
1558+
test_config sendemail.aliasesfile ".mailrc" &&
1559+
test_config sendemail.aliasfiletype mailrc &&
1560+
git format-patch --stdout -1 --to=sbd >aliased.patch &&
1561+
git send-email \
1562+
--from="Example <[email protected]>" \
1563+
--smtp-server="$(pwd)/fake.sendmail" \
1564+
aliased.patch \
1565+
2>errors >out &&
1566+
grep "^!someone@example\.org!$" commandline1
1567+
'
1568+
1569+
test_expect_success $PREREQ 'alias support in Cc header' '
1570+
clean_fake_sendmail &&
1571+
echo "alias sbd [email protected]" >.mailrc &&
1572+
test_config sendemail.aliasesfile ".mailrc" &&
1573+
test_config sendemail.aliasfiletype mailrc &&
1574+
git format-patch --stdout -1 --cc=sbd >aliased.patch &&
1575+
git send-email \
1576+
--from="Example <[email protected]>" \
1577+
--smtp-server="$(pwd)/fake.sendmail" \
1578+
aliased.patch \
1579+
2>errors >out &&
1580+
grep "^!someone@example\.org!$" commandline1
1581+
'
1582+
1583+
test_expect_success $PREREQ 'tocmd works with aliases' '
1584+
clean_fake_sendmail &&
1585+
echo "alias sbd [email protected]" >.mailrc &&
1586+
test_config sendemail.aliasesfile ".mailrc" &&
1587+
test_config sendemail.aliasfiletype mailrc &&
1588+
git format-patch --stdout -1 >tocmd.patch &&
1589+
echo tocmd--sbd >>tocmd.patch &&
1590+
git send-email \
1591+
--from="Example <[email protected]>" \
1592+
--to-cmd=./tocmd-sed \
1593+
--smtp-server="$(pwd)/fake.sendmail" \
1594+
tocmd.patch \
1595+
2>errors >out &&
1596+
grep "^!someone@example\.org!$" commandline1
1597+
'
1598+
1599+
test_expect_success $PREREQ 'cccmd works with aliases' '
1600+
clean_fake_sendmail &&
1601+
echo "alias sbd [email protected]" >.mailrc &&
1602+
test_config sendemail.aliasesfile ".mailrc" &&
1603+
test_config sendemail.aliasfiletype mailrc &&
1604+
git format-patch --stdout -1 >cccmd.patch &&
1605+
echo cccmd--sbd >>cccmd.patch &&
1606+
git send-email \
1607+
--from="Example <[email protected]>" \
1608+
--cc-cmd=./cccmd-sed \
1609+
--smtp-server="$(pwd)/fake.sendmail" \
1610+
cccmd.patch \
1611+
2>errors >out &&
1612+
grep "^!someone@example\.org!$" commandline1
1613+
'
1614+
15551615
do_xmailer_test () {
15561616
expected=$1 params=$2 &&
15571617
git format-patch -1 &&

0 commit comments

Comments
 (0)