From: Derrick Stolee <stolee@gmail.com>
To: phillip.wood@dunelm.org.uk,
Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>,
git@vger.kernel.org
Cc: gitster@pobox.com, james@jamesliu.io,
"brian m. carlson" <sandals@crustytoothpaste.net>
Subject: Re: [PATCH] git: add --no-hooks global option
Date: Mon, 14 Apr 2025 06:59:34 -0400 [thread overview]
Message-ID: <cb3d080b-51a3-4096-9650-34ec4ed68f1d@gmail.com> (raw)
In-Reply-To: <2c7994bc-2be0-43a5-9627-0d530746b3ab@gmail.com>
On 4/4/2025 10:15 AM, Phillip Wood wrote:
> Hi Stolee
>
> On 03/04/2025 23:38, Derrick Stolee via GitGitGadget wrote:
>> From: Derrick Stolee <stolee@gmail.com>
>>
>> In some situations, these hooks have poor performance and expert users
>> may want to skip the hooks as they don't seem to affect the current
>> situation. One example is a pre-commit hook that checks for certain
>> structures in the local changes, but expert users are likely to have
>> done the right thing in advance.
>
> Next they'll be saying that they never make a mistake when writing a
> one line patch! More seriously I agree there are times when one may
> want to bypass the pre-commit hook but we already have "git commit
> --no-verify" to do that. In general hooks that are so slow that the
> user wants to bypass them are self-defeating and I'd argue that the
> solution is to fix the performance of the hook rather than make it
> easier to skip it.
Both can also be an option.
> One solution for speeding up pre-commit hooks is
> to process files in parallel. Unfortunately git does not provide
> support for that but there are hook frameworks that do.
>> I have come across users who have disabled hooks themselves either by
>> deleting hooks (supported, safe) or setting 'core.hooksPath' to some
>> bogus path (seems unsafe).
>
> I thought "git -c core.hooksPath=/dev/null" was a fairly standard
> way of disabling hooks on a one-off basis - what makes it unsafe?
You're right. I was thinking about setting it to a "directory that
doesn't exist" (but actually could be a path that exists accidentally
like "/bogus") but I forgot that we could use /dev/null.
I'll remove this "(seems unsafe)" wording.
>> The supported process is painful to swap
>> between the hook-enabled scenario and the hook-disabled scenario.
>>
>> To that end, add a new --no-hooks global option to allow users to
>> disable hooks quickly. This option is modeled similarly to the
>> --no-advice option in b79deeb554 (advice: add --no-advice global option,
>> 2024-05-03). This uses a GIT_HOOKS environment variable to communicate
>> to subprocesses as well as making this a backwards-compatible way for
>> tools to signal that they want to disable hooks.
>>
>> The critical piece is that all hooks pass through run_hooks_opt() where
>> a static int will evaluate the environment variable and store that the
>> variable is initialized for faster repeated runs.
>
> That certainly makes the implementation much more viable. However I'm
> not really convinced this is a good idea.
I don't read a strong reason in your message that this is a _bad_
idea either. As in, there's nothing that hints that this will cause
significant harm to users other than providing a new footgun (and we
have plenty of those for folks willing to look, including the
_existence_ of hooks).
Thanks,
-Stolee
next prev parent reply other threads:[~2025-04-14 10:59 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-03 22:38 [PATCH] git: add --no-hooks global option Derrick Stolee via GitGitGadget
2025-04-03 22:55 ` brian m. carlson
2025-04-04 0:40 ` Derrick Stolee
2025-04-04 14:15 ` Phillip Wood
2025-04-14 10:59 ` Derrick Stolee [this message]
2025-04-16 10:29 ` Phillip Wood
2025-04-16 14:28 ` Junio C Hamano
2025-04-16 15:30 ` Derrick Stolee
2025-04-14 15:25 ` Lucas Seiki Oshiro
2025-04-14 21:05 ` brian m. carlson
2025-04-11 18:53 ` D. Ben Knoble
2025-04-16 15:42 ` [PATCH v2] docs: document core.hooksPath=/dev/null Derrick Stolee via GitGitGadget
2025-04-16 16:53 ` Lucas Seiki Oshiro
2025-04-17 0:25 ` Derrick Stolee
2025-04-17 0:39 ` brian m. carlson
2025-04-17 3:42 ` Junio C Hamano
2025-04-17 16:02 ` Lucas Seiki Oshiro
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=cb3d080b-51a3-4096-9650-34ec4ed68f1d@gmail.com \
--to=stolee@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=gitster@pobox.com \
--cc=james@jamesliu.io \
--cc=phillip.wood@dunelm.org.uk \
--cc=sandals@crustytoothpaste.net \
/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).