git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v5] git-send-email: use ! to indicate relative path to command

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
May 12, 2021, 00:51 UTC
Message-ID
<YJsmeOjxd5VIbjoM@camp.crustytoothpaste.net>
In-Reply-To
<YJsi1jbtNFDRKXmq@coredump.intra.peff.net>
On 2021-05-12 at 00:35:34, Jeff King wrote:
Show 22 quoted lines
> On Wed, May 12, 2021 at 12:00:51AM +0000, brian m. carlson wrote:
> 
> > > +	specify a sendmail-like program instead, either by a full
> > > +	path-name or by prefixing the program name with `!`.  The
> > > +	program must support the `-i` option.  Default value can be
> > > +	specified by the `sendemail.smtpServer` configuration 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.
> > 
> > Elsewhere we use the ! syntax we invoke the shell, and I would suggest
> > that we do the same here.  That means we'll get PATH functionality by
> > default and we'll let people do a modicum of scripting if they like.
> 
> Thanks for bringing that up. I agree it makes things more consistent
> with other uses of "!", and certainly it's more flexible. It does
> introduce an inconsistency with the absolute-path form, as I mentioned
> in https://lore.kernel.org/git/YJsiKDNbKclFU00b@coredump.intra.peff.net/.
> 
> I don't know if that's a show-stopper or not. Certainly the
> documentation can explain the difference, but it's nice to keep the
> rules as simple as possible.

I think the minor incompatibility here is okay. It would have been nicer to be able to avoid it, but hindsight is always 20/20.

> (My gut feeling is that consistency with other "!" places is more
> important than consistency with the absolute-path form).

Yeah, I think the shell here can be very useful, because it lets you configure something once in .gitconfig and handle system incompatibilities (a purely hypothetical example):

  !f() { if [ "$(uname -s)" = Darwin ]; then sendmail "$@"; else postfix "$@"; fi; };f

People use this functionality all the time in other places: credential helpers, editors (use a fancy graphical editor if supported, otherwise Vim), and various other places we allow this syntax.

-- 
brian m. carlson (he/him or they/them)
Houston, Texas, US
Previous: Junio C HamanoNext: Felipe Contreras
Message 13 of 23 in “git-send-email: use ! to indicate relative path to command”
  1. git-send-email: use ! to indicate relative path to commandGregory Anders, May 11, 2021
  2. Jeff KingMay 11, 2021
  3. git-send-email: use ! to indicate relative path to commandGregory Anders, May 11, 2021
  4. Jeff KingMay 11, 2021
  5. Gregory AndersMay 11, 2021
  6. Junio C HamanoMay 11, 2021
  7. git-send-email: use ! to indicate relative path to commandGregory Anders, May 11, 2021
  8. brian m. carlsonMay 12, 2021
  9. Jeff KingMay 12, 2021
  10. Gregory AndersMay 12, 2021
  11. Jeff KingMay 12, 2021
  12. Junio C HamanoMay 12, 2021
  13. brian m. carlsonMay 12, 2021
  14. Felipe ContrerasMay 11, 2021
  15. Gregory AndersMay 11, 2021
  16. Felipe ContrerasMay 11, 2021
  17. Gregory AndersMay 11, 2021
  18. Jeff KingMay 12, 2021
  19. Felipe ContrerasMay 12, 2021
  20. Jeff KingMay 12, 2021
  21. Felipe ContrerasMay 12, 2021
  22. Gregory AndersMay 12, 2021
  23. Felipe ContrerasMay 12, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.