Re: Syntax for specifying a command in git config

2 messages, 2 authors, 2021-05-12 · open the first message on its own page

Re: Syntax for specifying a command in git config

From: Junio C Hamano <hidden>
Date: 2021-05-11 22:56:54

Jeff King [off-list ref] writes:
quoted
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.


Re: Syntax for specifying a command in git config

From: Jeff King <hidden>
Date: 2021-05-12 00:32:44

On Wed, May 12, 2021 at 07:56:47AM +0900, Junio C Hamano wrote:
quoted
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help