git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: "brian m. carlson" <sandals@crustytoothpaste.net>,
	Rafael Santiago <voidbrainvoid@tutanota.com>,
	Rafael Santiago via GitGitGadget <gitgitgadget@gmail.com>,
	git@vger.kernel.org
Subject: Re: [PATCH] Give support for hooks based on platform
Date: Mon, 23 Aug 2021 14:32:41 -0400	[thread overview]
Message-ID: <YSPpySdd5qqDeNbm@coredump.intra.peff.net> (raw)
In-Reply-To: <xmqqfsv0qby7.fsf@gitster.g>

On Mon, Aug 23, 2021 at 10:59:28AM -0700, Junio C Hamano wrote:

> 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

  reply	other threads:[~2021-08-23 18:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-21 20:00 [PATCH] Give support for hooks based on platform Rafael Santiago via GitGitGadget
2021-08-21 21:50 ` brian m. carlson
2021-08-21 23:11   ` Rafael Santiago
2021-08-22 22:07     ` brian m. carlson
2021-08-23  1:07       ` Rafael Santiago
2021-08-23 16:23       ` Jeff King
2021-08-23 17:59         ` Junio C Hamano
2021-08-23 18:32           ` Jeff King [this message]
2021-08-23 16:35       ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YSPpySdd5qqDeNbm@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=gitster@pobox.com \
    --cc=sandals@crustytoothpaste.net \
    --cc=voidbrainvoid@tutanota.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).