git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
* Syntax for specifying a command in git config
@ 2021-05-11 18:07 Gregory Anders
  2021-05-11 18:17 ` Jeff King
  0 siblings, 1 reply; 5+ messages in thread
From: Gregory Anders @ 2021-05-11 18:07 UTC (permalink / raw)
  To: git

Hi all,

Certain git config parameters (notably sendemail.smtpServer) expect an 
absolute path in order to use a command. If the value begins with a / 
git interprets it as a command; otherwise, it's interpreted it as a 
server hostname.

Using an absolute path is not very portable, however. If I want to have 
a common shared config file across multiple machines, each of which uses 
a command for smtpServer (e.g. msmtp) but installed at different 
locations, I have to modify the config file on each machine to update 
the absolute path.

Obviously this is not a *huge* deal, but it is a minor annoyance. I'm 
wondering if it would be possible to add a new syntax to config options 
like this. For example,

     [sendemail]
             smtpServer = !msmtp

The leading ! character says "the following value is a command that 
should be looked up in PATH". This is congruent with alias definitions, 
where the leading ! means to run the following value as a command 
directly instead of as a git subcommand.

This also is unambiguous since server hostnames will never begin with a 
! character.

I would be happy to attempt a patch at this change if it's something the 
git maintainers are open to. And if there are any other options that 
this would make sense for, I can add those too.

Thanks,

Greg

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Syntax for specifying a command in git config
  2021-05-11 18:07 Syntax for specifying a command in git config Gregory Anders
@ 2021-05-11 18:17 ` Jeff King
  2021-05-11 22:56   ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff King @ 2021-05-11 18:17 UTC (permalink / raw)
  To: Gregory Anders; +Cc: Junio C Hamano, git

On Tue, May 11, 2021 at 12:07:46PM -0600, Gregory Anders wrote:

> Certain git config parameters (notably sendemail.smtpServer) expect an
> absolute path in order to use a command. If the value begins with a / git
> interprets it as a command; otherwise, it's interpreted it as a server
> hostname.
> 
> Using an absolute path is not very portable, however. If I want to have a
> common shared config file across multiple machines, each of which uses a
> command for smtpServer (e.g. msmtp) but installed at different locations, I
> have to modify the config file on each machine to update the absolute path.
> 
> Obviously this is not a *huge* deal, but it is a minor annoyance. I'm
> wondering if it would be possible to add a new syntax to config options like
> this. For example,
> 
>     [sendemail]
>             smtpServer = !msmtp
> 
> The leading ! character says "the following value is a command that should
> be looked up in PATH". This is congruent with alias definitions, where the
> leading ! means to run the following value as a command directly instead of
> as a git subcommand.
> 
> This also is unambiguous since server hostnames will never begin with a !
> character.

IMHO this is a good path forward. There's a thread from a few months ago
which talks about this idea:

  https://lore.kernel.org/git/YCvotU6KVruFuf9%2F@coredump.intra.peff.net/

There's some back and forth, and I'm not sure if I convinced Junio in
the end. But certainly a patch would be a good way to restart the
conversation. :)

-Peff

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Syntax for specifying a command in git config
  2021-05-11 18:17 ` Jeff King
@ 2021-05-11 22:56   ` Junio C Hamano
  2021-05-12  0:32     ` Jeff King
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2021-05-11 22:56 UTC (permalink / raw)
  To: Jeff King; +Cc: Gregory Anders, git

Jeff King <peff@peff.net> writes:

>> Obviously this is not a *huge* deal, but it is a minor annoyance. I'm
>> wondering if it would be possible to add a new syntax to config options like
>> this. For example,
>> 
>>     [sendemail]
>>             smtpServer = !msmtp
>> 
>> The leading ! character says "the following value is a command that should
>> be looked up in PATH". This is congruent with alias definitions, where the
>> leading ! means to run the following value as a command directly instead of
>> as a git subcommand.
>> 
>> This also is unambiguous since server hostnames will never begin with a !
>> character.
>
> IMHO this is a good path forward. There's a thread from a few months ago
> which talks about this idea:
>
>   https://lore.kernel.org/git/YCvotU6KVruFuf9%2F@coredump.intra.peff.net/
>
> There's some back and forth, and I'm not sure if I convinced Junio in
> the end. But certainly a patch would be a good way to restart the
> conversation. :)

The argument is not just about configuration but applies equally to
its command line argument "--smtp-server=<what>", right?  I think it
makes sense in both of these places.  I further wonder if we should
allow not just a single token, but supplying an initial few arguments,
too, e.g.

	git send-email --smtp-server="/usr/bin/env msmtp"
	git send-email --smtp-server="!my-msa --emulate-sendmail"

Thanks.




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Syntax for specifying a command in git config
  2021-05-11 22:56   ` Junio C Hamano
@ 2021-05-12  0:32     ` Jeff King
  2021-05-12  3:25       ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff King @ 2021-05-12  0:32 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Gregory Anders, git

On Wed, May 12, 2021 at 07:56:47AM +0900, Junio C Hamano wrote:

> > IMHO this is a good path forward. There's a thread from a few months ago
> > which talks about this idea:
> >
> >   https://lore.kernel.org/git/YCvotU6KVruFuf9%2F@coredump.intra.peff.net/
> >
> > There's some back and forth, and I'm not sure if I convinced Junio in
> > the end. But certainly a patch would be a good way to restart the
> > conversation. :)
> 
> The argument is not just about configuration but applies equally to
> its command line argument "--smtp-server=<what>", right?  I think it
> makes sense in both of these places.  I further wonder if we should
> allow not just a single token, but supplying an initial few arguments,
> too, e.g.
> 
> 	git send-email --smtp-server="/usr/bin/env msmtp"
> 	git send-email --smtp-server="!my-msa --emulate-sendmail"

Yes, the patch under discussion does apply to both the command-line
option and the config option (and I agree it should).

I didn't think about arguments, but you're right that may be a useful
feature. And if done via the shell, as brian suggested elsewhere, would
be more consistent with other parts of Git using "!" syntax.

It does make things a little weird in that:

  git send-email --smtp-server='/path/to/my-sendmail foo'

and

  git send-email --smtp-server '!my-sendmail foo'

behave differently (the first does not work; it looks for an executable
with a space in the name).

-Peff

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Syntax for specifying a command in git config
  2021-05-12  0:32     ` Jeff King
@ 2021-05-12  3:25       ` Junio C Hamano
  0 siblings, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2021-05-12  3:25 UTC (permalink / raw)
  To: Jeff King; +Cc: Gregory Anders, git

Jeff King <peff@peff.net> writes:

>> 	git send-email --smtp-server="/usr/bin/env msmtp"
>> 	git send-email --smtp-server="!my-msa --emulate-sendmail"
>
> Yes, the patch under discussion does apply to both the command-line
> option and the config option (and I agree it should).
>
> I didn't think about arguments, but you're right that may be a useful
> feature. And if done via the shell, as brian suggested elsewhere, would
> be more consistent with other parts of Git using "!" syntax.

Heh, it was my tongue-in-cheek way to say we do not need this '!'
new feature, as long as everybody has 'env' in /usr/bin ;-)

> It does make things a little weird in that:
>
>   git send-email --smtp-server='/path/to/my-sendmail foo'
>
> and
>
>   git send-email --smtp-server '!my-sendmail foo'
>
> behave differently (the first does not work; it looks for an executable
> with a space in the name).

True.  Hopefully we do not have to worry about $IFS whitespaces in
an absolute path to the mail submission program?  ... Nah, that's a
wishful thinking.

But then nobody stops you from saying

	git send-email --smtp-server '!/path/to/my-sendmail foo'

so it probably is OK.  We can gradually deprecate the "absolute path"
form and standardise on the "!prefix" form.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-05-12  3:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-11 18:07 Syntax for specifying a command in git config Gregory Anders
2021-05-11 18:17 ` Jeff King
2021-05-11 22:56   ` Junio C Hamano
2021-05-12  0:32     ` Jeff King
2021-05-12  3:25       ` Junio C Hamano

Code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).