Re: [PATCH] send-email: add proper default sender
From: Jeff King <hidden>
Date: 2016-06-15 22:55:15
On Sun, Nov 11, 2012 at 06:06:50PM +0100, Felipe Contreras wrote:
There's no point in asking this over and over if the user already properly configured his/her name and email. Signed-off-by: Felipe Contreras <redacted> --- I got really tired of 'git send-email' always asking me from which address to send mails... that's already configured.
It should be defaulting to your regular git ident, and you just have to hit enter, right? I think it's probably reasonable to skip that "enter" in most cases. But I'm not sure why we ever asked in the first place. What do people input there if they are not taking the default?
quoted hunk ↗ jump to hunk
diff --git a/git-send-email.perl b/git-send-email.perl index aea66a0..65b8328 100755 --- a/git-send-email.perl +++ b/git-send-email.perl@@ -748,6 +748,17 @@ if (!$force) { } } +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; + } +}
Why not use Git::ident_person() here? It saves some code, and would also respect environment variables. Or better yet...
my $prompting = 0;
if (!defined $sender) {
$sender = $repoauthor || $repocommitter || '';Why not just use $repoauthor or $repocommitter, as the prompt default already does? -Peff