Re: How can I specify the "sendmail" program for git-send-email?
On Mon, Jun 11, 2012 at 11:04 AM, Richard Yang <weiyang@linux.vnet.ibm.com> wrote:
Show 26 quoted lines
> On Mon, Jun 11, 2012 at 10:23:21AM +0200, Erik Faye-Lund wrote:
>>On Mon, Jun 11, 2012 at 9:32 AM, Richard Yang
>><weiyang@linux.vnet.ibm.com> wrote:
>>> Hi, experts
>>>
>>> I read the git-send-email manual and find the --smtp-server option can
>>> specify the sendmail-like program to send mail.
>>>
>>> Then I use this option in command line
>>> --smtp-server=/usr/bin/msmtp
>>> This works.
>>>
>>> While I found it not very convenient to write the option on command line
>>> every time, then I wrote it in the .gitconfig file in my home directory.
>>>
>>> [sendmail]
>>> smtpserver = /usr/bin/msmtp
>>> smtppass = 123456
>>> smtpuser = weiyang@linux.vnet.ibm.com
>>> smtpserverport = 143
>>
>>The configuration-section for git send-mail is actually spelled
>>"sendemail", and not "sendmail". Notice the additional 'e'.
> Oops, a stupid mistake.
>
> Thanks all :)
Well, I've always been slightly annoyed by the "send-mail" vs "sendemail" inconsistency. Perhaps we could do something along these lines (plus all documentation-updates, omitted for clarity) to reduce the risk of confusion?
Yeah, the leaking of $identity between different sections is a bit suboptimal, but as a fallback-mechanism I don't think it actually matters much.
diff --git a/git-send-email.perl b/git-send-email.perl
index 03292fd..d167d96 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -375,7 +375,11 @@ sub read_config {
}
}
-# read configuration from [sendemail "$identity"], fall back on [sendemail]
+# read configuration from [sendmail "$identity"], fall back on [sendmail]
+$identity = Git::config(@repo, "sendmail.identity") unless (defined $identity);
+read_config("sendmail.$identity") if (defined $identity);
+read_config("sendmail");
+# same as above, but with legacy "sendemail"
$identity = Git::config(@repo, "sendemail.identity") unless (defined
$identity);
read_config("sendemail.$identity") if (defined $identity);
read_config("sendemail");