Re: [PATCH v2] checkout & worktree: introduce checkout.implicitRemote
From: Duy Nguyen <hidden>
Date: 2018-05-04 14:59:17
On Fri, May 4, 2018 at 9:54 AM, Ævar Arnfjörð Bjarmason [off-list ref] wrote:
Realistically the way we do hooks now would make the UI of this suck, i.e. you couldn't configure it globally or system-wide easily. Something like what I noted in https://public-inbox.org/git/871sf3el01.fsf@evledraar.gmail.com/ would make it suck less, but that's a much bigger task.
I thought you would bring this up :) I've given some more thoughts on
this topic and am willing to implement something like below, in a week
or two. Would that help change your mind?
I proposed hooks.* config space in that same thread. Here is the
extension to make it cover both of your points.
hooks.* can have multiple values. So you can specify
hooks.post-checkout multiple times and all those scripts will run (in
the same order you specified). Since we already have a search path for
config (/etc/gitconfig -> $HOME/.gitconfig -> $REPO/config) this helps
hooks management as well. Execution order is still the same: if you
specify hooks.post-checkout in both /etc/gitconfig and .git/config,
then the one in /etc/gitconfig is executed first, the one in .git
second.
And here's something extra to make it possible to override the search
order: if you specify hooks.post-checkout = reset (reset is a random
keyword) then _all_ post-checkout hooks before this point are ignored.
So you can put this in .git/config
[hooks]
post-checkout = reset
post-checkout = ~/some-hook
and can be sure that post-checkout specified in $HOME and /etc will
not affect you, only ~/some-hook will run. If you drop the second line
then you have no post-checkout hooks. This is a workaround for a
bigger problem (not being able to unset a config entry) but I think
it's sufficient for this use case.
--
Duy