Merge branch 'db/send-pack-user-signingkey'
[gitweb.git] / t / t9001-send-email.sh
index 9aee4747fe7e49a21118b2b3033090cf78b934ee..5b4a5ce06b94355725fafc84c31f9ed67b8b15ed 100755 (executable)
@@ -1543,7 +1543,7 @@ test_expect_success $PREREQ 'sendemail.aliasfiletype=mailrc' '
 
 test_expect_success $PREREQ 'sendemail.aliasfile=~/.mailrc' '
        clean_fake_sendmail &&
-       echo "alias sbd  someone@example.org" >~/.mailrc &&
+       echo "alias sbd  someone@example.org" >"$HOME/.mailrc" &&
        git config --replace-all sendemail.aliasesfile "~/.mailrc" &&
        git config sendemail.aliasfiletype mailrc &&
        git send-email \
@@ -1555,6 +1555,78 @@ test_expect_success $PREREQ 'sendemail.aliasfile=~/.mailrc' '
        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 &&
@@ -1692,4 +1764,28 @@ test_expect_success $PREREQ 'aliases work with email list' '
        test_cmp expected-list actual-list
 '
 
+test_expect_success $PREREQ 'leading and trailing whitespaces are removed' '
+       echo "alias to2 to2@example.com" >.mutt &&
+       echo "alias cc1 Cc 1 <cc1@example.com>" >>.mutt &&
+       test_config sendemail.aliasesfile ".mutt" &&
+       test_config sendemail.aliasfiletype mutt &&
+       TO1=$(echo "QTo 1 <to1@example.com>" | q_to_tab) &&
+       TO2=$(echo "QZto2" | qz_to_tab_space) &&
+       CC1=$(echo "cc1" | append_cr) &&
+       BCC1=$(echo "Q bcc1@example.com Q" | q_to_nul) &&
+       git send-email \
+       --dry-run \
+       --from="        Example <from@example.com>" \
+       --to="$TO1" \
+       --to="$TO2" \
+       --to="  to3@example.com   " \
+       --cc="$CC1" \
+       --cc="Cc2 <cc2@example.com>" \
+       --bcc="$BCC1" \
+       --bcc="bcc2@example.com" \
+       0001-add-master.patch | replace_variable_fields \
+       >actual-list &&
+       test_cmp expected-list actual-list
+'
+
 test_done