Re: [PATCH] send-email: add proper default sender
- From
Felipe Contreras <felipe.contreras@gmail.com>
- Date
- Nov 11, 2012, 18:06 UTC
- Message-ID
- <CAMP44s1iNFcN6LFhpFTR0cuTcytOXDSof8H+bPN1_0ebGandBw@mail.gmail.com>
- In-Reply-To
- <CALkWK0kvScgtqwCLA2BPZxs5qc-ZVyZPiCu6BHrqjne-Yfr8-A@mail.gmail.com>
On Sun, Nov 11, 2012 at 6:12 PM, Ramkumar Ramachandra <artagnon@gmail.com> wrote:
> Felipe Contreras wrote: >> 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 <felipe.contreras@nokia.com>
% git config user.email felipe.contreras@gmail.com % git send-email.perl master From: Felipe Contreras <felipe.contreras@gmail.com>
% 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