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

Re: [PATCH] Give support for hooks based on platform

From
Jeff King <peff@peff.net>
Date
Aug 23, 2021, 18:32 UTC
Message-ID
<YSPpySdd5qqDeNbm@coredump.intra.peff.net>
In-Reply-To
<xmqqfsv0qby7.fsf@gitster.g>
On Mon, Aug 23, 2021 at 10:59:28AM -0700, Junio C Hamano wrote:
Show 32 quoted lines
> Jeff King <peff@peff.net> writes:
> 
> > On Sun, Aug 22, 2021 at 10:07:41PM +0000, brian m. carlson wrote:
> >
> >> > The point is that in many cases a dependency with a script language is
> >> > created only to make the hook actions portable from a platform to
> >> > other, but what this script in its essence does is a thing that could
> >> > be done with basic tools delivered with the current operating system.
> >> 
> >> Then, in general, it can be done in a shell script containing an if-then
> >> statement per platform using the native tools, so I'm not seeing the
> >> particular reason that this series is necessary if the hooks being
> >> executed aren't binaries.  All systems on which Git runs must contain a
> >> POSIX-compatible shell.
> >
> > This is my gut feeling, too (whether users know it or not, even on
> > Windows most programs specified by config are being run by the shell).
> >
> > However, I do think there is room for Git to make this case a bit
> > easier: conditional config includes. Once we are able to specify hooks
> > via config (which is being worked on elsewhere), then we ought to be
> > able to implement an includeIf like:
> >
> >   [includeIf "uname_s:linux"]
> >   path = linux-hooks.config
> >   [includeIf "uname_s:windows"]
> >   path = windows-hooks.config
> >
> > The advantage being that this could apply to _all_ config, and not just
> > hooks.
> 
> Heh, it seems great minds think alike.

One important distinction in what you wrote is that you're expecting the user to set dev.host once. That nicely sidesteps any question of "how does Git label each platform?", but it does mean the user has to do that setup manually (which maybe is amortized across many repos, but in practice for many people I suspect is no better than them setting up the correct "include" in the first place).

I hoped that by calling it "uname_s", it would be clear it was the same as "uname -s", and then we could blame any naming confusion on the OS. :)

But even if it is not used for this particular application, I think the [includeIf "var:..."] you proposed might be a reasonable thing to support.

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 8 of 9 in “Give support for hooks based on platform”
  1. Give support for hooks based on platformRafael Santiago via GitGitGadget, Aug 21, 2021
  2. brian m. carlsonAug 21, 2021
  3. Rafael SantiagoAug 21, 2021
  4. brian m. carlsonAug 22, 2021
  5. Rafael SantiagoAug 23, 2021
  6. Jeff KingAug 23, 2021
  7. Junio C HamanoAug 23, 2021
  8. Jeff KingAug 23, 2021
  9. Junio C HamanoAug 23, 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.