Skip to content

Commit

Permalink
send-email: automatic envelope sender
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Felipe Contreras authored and Junio C Hamano committed Nov 28, 2009
1 parent 4f333bc commit c89e324
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
7 changes: 4 additions & 3 deletions Documentation/git-send-email.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,10 @@ Sending
--envelope-sender=<address>::
Specify the envelope sender used to send the emails.
This is useful if your default address is not the address that is
subscribed to a list. If you use the sendmail binary, you must have
suitable privileges for the -f parameter. Default is the value of
the 'sendemail.envelopesender' configuration variable; if that is
subscribed to a list. In order to use the 'From' address, set the
value to "auto". If you use the sendmail binary, you must have
suitable privileges for the -f parameter. Default is the value of the
'sendemail.envelopesender' configuration variable; if that is
unspecified, choosing the envelope sender is left to your MTA.

--smtp-encryption=<encryption>::
Expand Down
4 changes: 3 additions & 1 deletion git-send-email.perl
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,9 @@ sub send_message

my @sendmail_parameters = ('-i', @recipients);
my $raw_from = $sanitized_sender;
$raw_from = $envelope_sender if (defined $envelope_sender);
if (defined $envelope_sender && $envelope_sender ne "auto") {
$raw_from = $envelope_sender;
}
$raw_from = extract_valid_address($raw_from);
unshift (@sendmail_parameters,
'-f', $raw_from) if(defined $envelope_sender);
Expand Down
17 changes: 17 additions & 0 deletions t/t9001-send-email.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,23 @@ test_expect_success \
'Verify commandline' \
'test_cmp expected commandline1'

test_expect_success 'Send patches with --envelope-sender=auto' '
clean_fake_sendmail &&
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
'

cat >expected <<\EOF
!nobody@example.com!
!-i!
!nobody@example.com!
!author@example.com!
!one@example.com!
!two@example.com!
EOF
test_expect_success \
'Verify commandline' \
'test_cmp expected commandline1'

cat >expected-show-all-headers <<\EOF
0001-Second.patch
(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
Expand Down

0 comments on commit c89e324

Please sign in to comment.