diff mbox series

[v2] docs: document core.hooksPath=/dev/null

Message ID pull.1899.v2.git.1744818135435.gitgitgadget@gmail.com (mailing list archive)
State Accepted
Commit 1b2eee94f120969690d772af5a14f681f7d875a7
Headers show
Series [v2] docs: document core.hooksPath=/dev/null | expand

Commit Message

Derrick Stolee April 16, 2025, 3:42 p.m. UTC
From: Derrick Stolee <stolee@gmail.com>

If a user wishes to disable hooks, then they can do so using the
established pattern of setting 'core.hooksPath' to /dev/null. This is
already tested in t1350-config-hooks-path.sh, but has not previously
been visible in the documentation.

Update the documentation to include this as an option.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
---
    docs: document core.hooksPath=/dev/null
    
    Based on the discussion of the proposed --no-hooks option in v1, that
    code change is dropped in favor of this documentation of
    core.hooksPath=/dev/null.
    
    Thanks,
    
     * Stolee

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1899%2Fderrickstolee%2Fno-hooks-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1899/derrickstolee/no-hooks-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/1899

Range-diff vs v1:

 1:  91e82850e7d < -:  ----------- git: add --no-hooks global option
 -:  ----------- > 1:  a9cd4bd5100 docs: document core.hooksPath=/dev/null


 Documentation/config/core.adoc | 5 +++++
 1 file changed, 5 insertions(+)


base-commit: 5b97a56fa0e7d580dc8865b73107407c9b3f0eff

Comments

Lucas Seiki Oshiro April 16, 2025, 4:53 p.m. UTC | #1
Hi!

> +You can also disable all hooks entirely by setting `core.hooksPath`
> +to `/dev/null`.

Personally I think it would be better to focus on the non-expert user,
something like:

"""
You can also use this variable to disable all hooks entirely by setting
it to `/dev/null`. For non-expert users in a per-command basis it is
advisable to use configuration parameters of the form
`git -c core.hooksPath=/dev/null ...`.
"""
Derrick Stolee April 17, 2025, 12:25 a.m. UTC | #2
On 4/16/2025 12:53 PM, Lucas Seiki Oshiro wrote:
> Hi!
> 
>> +You can also disable all hooks entirely by setting `core.hooksPath`
>> +to `/dev/null`.
> 
> Personally I think it would be better to focus on the non-expert user,

I absolutely want this to be targeted for expert users, so users self-
select themselves into the risk of what happens when disabling hooks.
This is a "there be dragons here" kind of warning, implying that you
better know what you're doing if you are messing with hook paths.

Thanks,
-Stolee
brian m. carlson April 17, 2025, 12:39 a.m. UTC | #3
On 2025-04-17 at 00:25:28, Derrick Stolee wrote:
> On 4/16/2025 12:53 PM, Lucas Seiki Oshiro wrote:
> > Hi!
> > 
> >> +You can also disable all hooks entirely by setting `core.hooksPath`
> >> +to `/dev/null`.
> > 
> > Personally I think it would be better to focus on the non-expert user,
> 
> I absolutely want this to be targeted for expert users, so users self-
> select themselves into the risk of what happens when disabling hooks.
> This is a "there be dragons here" kind of warning, implying that you
> better know what you're doing if you are messing with hook paths.

Yes, I think that's the right choice.  As we've established elsewhere,
it's easy to break things or cause data loss (e.g., by not pushing Git
LFS objects) by disabling hooks and the user should be confident of what
they're doing before doing so.

That being said, I agree that in the general case we should make our
documentation accessible to non-expert users because nobody is born
knowing how to use Git and that will benefit the most people.  This just
happens to be an exception.

I thought the text in the patch looked good to me.  I appreciate you
graciously pivoting approaches and documenting this, both for the
benefit of users and as an approach to help make sure we don't break
this functionality.
Junio C Hamano April 17, 2025, 3:42 a.m. UTC | #4
"brian m. carlson" <sandals@crustytoothpaste.net> writes:

> I thought the text in the patch looked good to me.  I appreciate you
> graciously pivoting approaches and documenting this, both for the
> benefit of users and as an approach to help make sure we don't break
> this functionality.

Thanks, all.  I too appreciate that Derrick left no loose ends
untied after changing direction.
Lucas Seiki Oshiro April 17, 2025, 4:02 p.m. UTC | #5
> This is a "there be dragons here" kind of warning, implying that you
> better know what you're doing if you are messing with hook paths.

Fair, I understand your point. The paragraph itself looks very
clear to me!

Thanks!
diff mbox series

Patch

diff --git a/Documentation/config/core.adoc b/Documentation/config/core.adoc
index 8f6d8e77541..9fde1ab63a7 100644
--- a/Documentation/config/core.adoc
+++ b/Documentation/config/core.adoc
@@ -512,6 +512,11 @@  centrally configure your Git hooks instead of configuring them on a
 per-repository basis, or as a more flexible and centralized
 alternative to having an `init.templateDir` where you've changed
 default hooks.
++
+You can also disable all hooks entirely by setting `core.hooksPath`
+to `/dev/null`. This is usually only advisable for expert users and
+on a per-command basis using configuration parameters of the form
+`git -c core.hooksPath=/dev/null ...`.
 
 core.editor::
 	Commands such as `commit` and `tag` that let you edit