send-email: automatic envelope sender
This adds the option to specify the envelope sender as "auto" which would pick the 'from' address. This is good because now we can specify the address only in one place in $HOME/.gitconfig and change it easily. [jc: added tests] Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Felipe Contreras committed
Nov 26, 2009 at 21:04 UTC
c89e32414516e906520e9bdd809560971eb52ef5
3 files changed
+24
-4
Documentation/git-send-email.txt
+4
-3
@@ -108,9 +108,10 @@ Sending
108
--envelope-sender=<address>::
109
Specify the envelope sender used to send the emails.
110
This is useful if your default address is not the address that is
111
- subscribed to a list. If you use the sendmail binary, you must have
112
- suitable privileges for the -f parameter. Default is the value of
113
- the 'sendemail.envelopesender' configuration variable; if that is
111
+ subscribed to a list. In order to use the 'From' address, set the
112
+ value to "auto". If you use the sendmail binary, you must have
113
+ suitable privileges for the -f parameter. Default is the value of the
114
+ 'sendemail.envelopesender' configuration variable; if that is
115
unspecified, choosing the envelope sender is left to your MTA.
116
117
--smtp-encryption=<encryption>::
git-send-email.perl
+3
-1
@@ -861,7 +861,9 @@ X-Mailer: git-send-email $gitversion
861
862
my @sendmail_parameters = ('-i', @recipients);
863
my $raw_from = $sanitized_sender;
864
- $raw_from = $envelope_sender if (defined $envelope_sender);
864
+ if (defined $envelope_sender && $envelope_sender ne "auto") {
865
+ $raw_from = $envelope_sender;
866
+ }
867
$raw_from = extract_valid_address($raw_from);
868
unshift (@sendmail_parameters,
869
'-f', $raw_from) if(defined $envelope_sender);
t/t9001-send-email.sh
+17
@@ -112,6 +112,23 @@ test_expect_success \
112
'Verify commandline' \
113
'test_cmp expected commandline1'
114
115
+test_expect_success 'Send patches with --envelope-sender=auto' '
116
+ clean_fake_sendmail &&
117
+ git send-email --envelope-sender=auto --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors
118
+'
119
+
120
+cat >expected <<\EOF
121
+!nobody@example.com!
122
+!-i!
123
+!nobody@example.com!
124
+!author@example.com!
125
+!one@example.com!
126
+!two@example.com!
127
+EOF
128
+test_expect_success \
129
+ 'Verify commandline' \
130
+ 'test_cmp expected commandline1'
131
+
132
cat >expected-show-all-headers <<\EOF
133
0001-Second.patch
134
(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'