Re: [PATCH] send-email: add proper default sender
From: Felipe Contreras <hidden>
Date: 2016-06-15 22:55:14
On Sun, Nov 11, 2012 at 6:12 PM, Ramkumar Ramachandra [off-list ref] wrote:
Felipe Contreras wrote:quoted
I got really tired of 'git send-email' always asking me from which address to send mails... that's already configured.Use sendemail.from. The email sender doesn't necessarily have to be the author.
And when it's not the author, then sendemail.from would be used.
% git config user.email felipe.contreras@nokia.com
% git send-email master
From: Felipe Contreras <redacted>
% git config user.email felipe.contreras@gmail.com
% git send-email.perl master
From: Felipe Contreras <redacted>
% git send-email --from=foo@bar.com master
From: foo@bar.com
% git config sendemail.from test@example.com
% git send-email master
From: test@example.com
What do you loose with this code? Nothing. What do you gain by asking
the user every time: "Who should the emails appear to be from?", when
the default GIT_AUTHOR_IDENT is already fine? Nothing.
The problem with sendemail.from, is that each time the user needs to
change email address, it has to be done in multiple places:
user.email, and sendemail.from. There's no need for that.
But I screwed the patch, it should be:
+if (!defined $sender) {
+ my $name = Git::config('user.name');
+ my $email = Git::config('user.email');
+
+ if (defined $email) {
+ if (defined $name) {
+ $sender = sprintf("%s <%s>", $name, $email);
+ } else {
+ $sender = $email;
+ }
+ }
+}
Cheers.
--
Felipe Contreras