Re: [PATCH v2] checkout & worktree: introduce checkout.implicitRemote
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- May 4, 2018, 14:58 UTC
- Message-ID
- <CACsJy8D+k+9SNBq7SNFpUhhdZDH7QaZ3+_rXMrge+b5KF_j9xA@mail.gmail.com>
- In-Reply-To
- <87muxfyhy9.fsf@evledraar.gmail.com>
On Fri, May 4, 2018 at 9:54 AM, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
Show 5 quoted lines
> 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-hookand 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