send-email: suppress meaningless whitespaces in from field

Remove leading and trailing whitespaces in from field before interepreting it to improve consistency with other options. The split_addrs function already take care of trailing and leading whitespaces for to, cc and bcc fields. The from option now: - has the same behavior when passing arguments like " jdoe@example.com ", "\t jdoe@example.com " or "jdoe@example.com". - interprets aliases in string containing leading and trailing whitespaces such as " alias" or "alias\t" like other options. 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>

Remi Lespinet committed Jun 30, 2015 at 14:16 UTC fa5b1aa9a1e1f0ad7b2728bec3712d3fab5fe734
2 files changed +25
git-send-email.perl
+1
@@ -761,6 +761,7 @@ if (!$force) {
761 }
762
763 if (defined $sender) {
764 + $sender =~ s/^\s+|\s+$//g;
765 ($sender) = expand_aliases($sender);
766 } else {
767 $sender = $repoauthor || $repocommitter || '';
t/t9001-send-email.sh
+24
@@ -1692,4 +1692,28 @@ test_expect_success $PREREQ 'aliases work with email list' '
1692 test_cmp expected-list actual-list
1693 '
1694
1695 +test_expect_success $PREREQ 'leading and trailing whitespaces are removed' '
1696 + echo "alias to2 to2@example.com" >.mutt &&
1697 + echo "alias cc1 Cc 1 <cc1@example.com>" >>.mutt &&
1698 + test_config sendemail.aliasesfile ".mutt" &&
1699 + test_config sendemail.aliasfiletype mutt &&
1700 + TO1=$(echo "QTo 1 <to1@example.com>" | q_to_tab) &&
1701 + TO2=$(echo "QZto2" | qz_to_tab_space) &&
1702 + CC1=$(echo "cc1" | append_cr) &&
1703 + BCC1=$(echo "Q bcc1@example.com Q" | q_to_nul) &&
1704 + git send-email \
1705 + --dry-run \
1706 + --from=" Example <from@example.com>" \
1707 + --to="$TO1" \
1708 + --to="$TO2" \
1709 + --to=" to3@example.com " \
1710 + --cc="$CC1" \
1711 + --cc="Cc2 <cc2@example.com>" \
1712 + --bcc="$BCC1" \
1713 + --bcc="bcc2@example.com" \
1714 + 0001-add-master.patch | replace_variable_fields \
1715 + >actual-list &&
1716 + test_cmp expected-list actual-list
1717 +'
1718 +
1719 test_done