All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Thomas Bachem via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Adrian Ratiu <adrian.ratiu@collabora.com>,
	Patrick Steinhardt <ps@pks.im>,
	Emily Shaffer <nasamuffin@google.com>,
	Junio C Hamano <gitster@pobox.com>,
	Thomas Bachem <mail@thomasbachem.com>
Subject: [PATCH v2 0/2] Two hook configuration changes
Date: Fri, 23 Oct 2026 13:19:00 +0000	[thread overview]
Message-ID: <pull.2272.v2.git.1792761542.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.2272.git.1792520353.gitgitgadget@gmail.com>

Two small changes to hook configuration. With the first,
hook.pre-commit.enabled=false also stops the pre-commit hook in the hooks
directory. With the second, hook.*.enabled and hook.*.parallel can be given
without a value, which means true, as for any other boolean.

Changes since v1:

 * The documentation of hook.<event>.enabled now says that it covers
   configured hooks and the hook in the hooks directory alike. The subject
   and message of patch 1 present this as a change in behavior rather than a
   fix (Adrian, Junio).

 * The test that hook.<event>.enabled=false leaves the hooks of other events
   alone now has a hookdir hook too.

Thomas Bachem (2):
  hook: make hook.<event>.enabled cover the hookdir hook
  hook: accept .enabled and .parallel given without a value

 Documentation/config/hook.adoc |  3 +-
 builtin/hook.c                 |  6 ++--
 hook.c                         | 17 ++++++----
 hook.h                         |  8 ++++-
 t/t1800-hook.sh                | 57 ++++++++++++++++++++++++++++++++--
 5 files changed, 78 insertions(+), 13 deletions(-)


base-commit: 6de20f6092dcf9bdb1c8efe03db4b70c82b423dd
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2272%2Fthomasbachem%2Fhook-event-enabled-hookdir-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2272/thomasbachem/hook-event-enabled-hookdir-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/2272

Range-diff vs v1:

 1:  1a7d060fae ! 1:  cfcbe80ba5 hook: honor hook.<event>.enabled for the hookdir hook
     @@ Metadata
      Author: Thomas Bachem <mail@thomasbachem.com>
      
       ## Commit message ##
     -    hook: honor hook.<event>.enabled for the hookdir hook
     +    hook: make hook.<event>.enabled cover the hookdir hook
      
     -    The documentation added by dcfb5af67e (hook: add hook.<event>.enabled
     -    switch, 2026-04-10) says that with hook.<event>.enabled set to false
     -    "no hooks fire for that event", but only hooks defined in the
     -    configuration are skipped. With hook.pre-commit.enabled=false,
     -    "git commit" still runs .git/hooks/pre-commit, and "git hook list"
     -    shows that hook without the "event-disabled" mark.
     +    hook.<event>.enabled, added by dcfb5af67e (hook: add
     +    hook.<event>.enabled switch, 2026-04-10), skips only the hooks
     +    defined in the configuration when set to false. With
     +    hook.pre-commit.enabled=false, "git commit" still runs
     +    .git/hooks/pre-commit, and "git hook list" shows that hook without
     +    the "event-disabled" mark.
      
     -    Move the event_disabled flag out of u.configured in struct hook, set
     -    it for the hookdir hook too, and check it for both kinds of hooks.
     +    That was the intent, but the documentation says "no hooks fire for
     +    that event", which reads as covering the hookdir hook too. No other
     +    setting turns off the hookdir hook of a single event either:
     +    core.hooksPath=/dev/null turns off the hookdir hooks of all events.
     +    Make the switch cover the hookdir hook as well, and say so in the
     +    documentation. This changes behavior for anyone who set the switch
     +    and relied on the hookdir hook still running.
      
          The test for hook.<event>.enabled=false looks only at the standard
          output, but "git hook run" sends hook output to the standard error,
     @@ Commit message
          Assisted-by: Claude Fable 5.1
          Signed-off-by: Thomas Bachem <mail@thomasbachem.com>
      
     + ## Documentation/config/hook.adoc ##
     +@@ Documentation/config/hook.adoc: hook.<friendly-name>.parallel::
     + 	the effective job count is greater than 1. {see-git-hook}
     + 
     + hook.<event>.enabled::
     +-	Switch to enable or disable all hooks for the `<event>` hook event.
     ++	Switch to enable or disable all hooks for the `<event>` hook event,
     ++	configured hooks and the traditional hook in the hooks directory alike.
     + 	When set to `false`, no hooks fire for that event, regardless of any
     + 	per-hook `hook.<friendly-name>.enabled` settings. Defaults to `true`.
     + 	{see-git-hook}
     +
       ## builtin/hook.c ##
      @@ builtin/hook.c: static int list(int argc, const char **argv, const char *prefix,
       
     @@ t/t1800-hook.sh: test_expect_success 'hook.<event>.jobs rejects values less than
       '
       
       test_expect_success 'hook.<event>.enabled=true does not suppress hooks' '
     +@@ t/t1800-hook.sh: test_expect_success 'hook.<event>.enabled=true does not suppress hooks' '
     + test_expect_success 'hook.<event>.enabled=false does not affect other events' '
     + 	test_config hook.hook-1.event test-hook &&
     + 	test_config hook.hook-1.command "echo ran" &&
     ++	test_hook test-hook <<-\EOF &&
     ++	echo hookdir ran
     ++	EOF
     + 	test_config hook.other-event.enabled false &&
     + 	git hook run --allow-unknown-hook-name test-hook >out 2>err &&
     +-	test_grep "ran" err
     ++	test_grep "^ran$" err &&
     ++	test_grep "^hookdir ran$" err
     + '
     + 
     + test_expect_success 'hook.<friendly-name>.enabled=false still disables that hook' '
      @@ t/t1800-hook.sh: test_expect_success 'git hook list shows event-disabled hooks as event-disabled'
       	test_config hook.hook-1.command "echo ran" &&
       	test_config hook.hook-2.event test-hook &&
 2:  3db167c9d1 = 2:  53a5a1787a hook: accept .enabled and .parallel given without a value

-- 
gitgitgadget

  parent reply	other threads:[~2026-10-23 13:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-20 18:19 [PATCH 0/2] Fix two hook configuration bugs Thomas Bachem via GitGitGadget
2026-10-20 18:19 ` [PATCH 1/2] hook: honor hook.<event>.enabled for the hookdir hook Thomas Bachem via GitGitGadget
2026-10-20 18:46   ` Junio C Hamano
2026-10-20 20:59     ` Adrian Ratiu
2026-10-21 17:42       ` Junio C Hamano
2026-10-22 13:40         ` Adrian Ratiu
2026-10-20 18:19 ` [PATCH 2/2] hook: accept .enabled and .parallel given without a value Thomas Bachem via GitGitGadget
2026-10-23 13:19 ` Thomas Bachem via GitGitGadget [this message]
2026-10-23 13:19   ` [PATCH v2 1/2] hook: make hook.<event>.enabled cover the hookdir hook Thomas Bachem via GitGitGadget
2026-10-23 13:19   ` [PATCH v2 2/2] hook: accept .enabled and .parallel given without a value Thomas Bachem via GitGitGadget
2026-10-23 17:53   ` [PATCH v2 0/2] Two hook configuration changes 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=pull.2272.v2.git.1792761542.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=adrian.ratiu@collabora.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=mail@thomasbachem.com \
    --cc=nasamuffin@google.com \
    --cc=ps@pks.im \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.