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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 23, 2021, 16:35 UTC
Message-ID
<xmqqo89oqfuu.fsf@gitster.g>
In-Reply-To
<YSLKrX/QTZtxBGDz@camp.crustytoothpaste.net>
"brian m. carlson" <sandals@crustytoothpaste.net> writes:
Show 5 quoted lines
> 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.

When we start defining our hooks in the configuration, this may fit with the conditional inclusion of configuration files. Current conditions only can depend on where the repository is, but it is easy to imagine that a conditional inclusion based on the value of the configuration variable, so

	[includeIf "var:dev.host=mac"]
		path = ...
	[includeIf "var:dev.host=win"]
		path = ...

might be a way to say "if the dev.host configuration (presumably set in somewhere like /etc/gitconfig or ~/.gitconfig) is set to this value, take the configuration from the specified path.

It is up to the project to define the variable they use to switch on; some project may ship with a set of hooks that can be used on both windows and cygwin at the same time, in which case they do not need the distinction between the two, and some other project may care about the distinction. Git does not have to impose or enforce any policy about the granularity of what "the platform" is, with such a scheme.

Previous: Jeff King
Message 9 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.