Re: [PATCH v4] git-send-email: use ! to indicate relative path to command
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 11, 2021, 23:09 UTC
- Message-ID
- <xmqqk0o4j2ax.fsf@gitster.g>
- In-Reply-To
- <20210511204044.69047-1-greg@gpanders.com>
Gregory Anders <greg@gpanders.com> writes:
> Presently, the smtpServer config option can use a sendmail-like program
s/Presently, t/T/; Also if I understand it correctly this is not just about configuration varible but equally applies to the command line option --smtp-server, so mention both of them in their full name, i.e.
The sendemail.smtpServer configuration variable and the
"--smtp-server" command line option can name a program to use by
providing ...Show 14 quoted lines
> by providing an absolute path to the program as the value for this > option. However, an absolute path is not always portable and it is often > preferable to simply specify a program name and have `git-send-email` > find that program on $PATH. > > For example, if a user wishes to use msmtp to send emails, they might > be able to simply use > > [sendemail] > smtpServer = !msmtp > > instead of using the full path. This is particularly useful when a > common git config file is used across multiple systems where the > absolute path to a given program may differ.
Nicely explained.
> To that end, this patch allows the smtpServer config option to be > prefixed with a ! character that implements the above behavior; namely, > the specified value (sans the ! character) is used as if the user had > entered it directly on the command line.
Allow the value of the configuration variable and the command line option to be prefixed with a '!' to signal that the specified command needs to be looked up on $PATH.
> See also https://lore.kernel.org/git/YJrH8uqzapnpNEsb@gpanders.com/.
You summarised the problem description in that message pretty well in the proposed log message (which is much better than leaving only a URL and forcing readers to go there), and I suspect there aren't much readers can learn from by seeing also the article, though.
Show 10 quoted lines
> + } elsif (file_name_is_absolute($smtp_server) || $smtp_server =~ /^!/) {
> + my $prog = $smtp_server;
> + $prog =~ s/^!//;
> +
> my $pid = open my $sm, '|-';
> defined $pid or die $!;
> if (!$pid) {
> - exec($smtp_server, @sendmail_parameters) or die $!;
> + exec($prog, @sendmail_parameters) or die $!;
> }Looking good.
Thanks.