Merge branch 'fk/sendmail-from-path'
authorJunio C Hamano <gitster@pobox.com>
Wed, 13 Dec 2017 21:28:56 +0000 (13:28 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 13 Dec 2017 21:28:56 +0000 (13:28 -0800)
"git send-email" tries to see if the sendmail program is available
in /usr/lib and /usr/sbin; extend the list of locations to be
checked to also include directories on $PATH.

* fk/sendmail-from-path:
git-send-email: honor $PATH for sendmail binary

Documentation/git-send-email.txt
git-send-email.perl
index bac9014ac71775e5116ad7686af697eb22286ee2..8060ea35c5f932c1e4328f000a501ff399418f27 100644 (file)
@@ -203,9 +203,9 @@ a password is obtained using 'git-credential'.
        specify a full pathname of a sendmail-like program instead;
        the program must support the `-i` option.  Default value can
        be specified by the `sendemail.smtpServer` configuration
-       option; the built-in default is `/usr/sbin/sendmail` or
-       `/usr/lib/sendmail` if such program is available, or
-       `localhost` otherwise.
+       option; the built-in default is to search for `sendmail` in
+       `/usr/sbin`, `/usr/lib` and $PATH if such program is
+       available, falling back to `localhost` otherwise.
 
 --smtp-server-port=<port>::
        Specifies a port different from the default port (SMTP
index 2208dcc2139be7130749fd3bae462320f17d3b21..edcc6d34692b28575d9728c25a407782310a39fb 100755 (executable)
@@ -885,7 +885,9 @@ sub expand_one_alias {
 }
 
 if (!defined $smtp_server) {
-       foreach (qw( /usr/sbin/sendmail /usr/lib/sendmail )) {
+       my @sendmail_paths = qw( /usr/sbin/sendmail /usr/lib/sendmail );
+       push @sendmail_paths, map {"$_/sendmail"} split /:/, $ENV{PATH};
+       foreach (@sendmail_paths) {
                if (-x $_) {
                        $smtp_server = $_;
                        last;