git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 2/2] hook: accept .enabled and .parallel given without a value

From
Thomas Bachem via GitGitGadget <gitgitgadget@gmail.com>
Date
Oct 23, 2026, 13:19 UTC
Message-ID
<53a5a1787acd97e0233ba48b46162089de6fcd3a.1792761542.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.2272.v2.git.1792761542.gitgitgadget@gmail.com>
From: Thomas Bachem <mail@thomasbachem.com>

hook.<name>.enabled and hook.<name>.parallel are booleans, and git-config(1) documents a boolean without a value as true. But hook_config_lookup_all() rejects every hook.<name>.<key> that has no value, so "git -c hook.lint.parallel hook run pre-commit" fails with "missing value for 'hook.lint.parallel'", and so does a bare "parallel" under [hook "lint"]. The same happens with .enabled, for a hook as well as for an event.

Keep rejecting a missing value for the other keys. For .enabled and .parallel, pass it to git_parse_maybe_bool(), which takes it as true.

Assisted-by: Claude Fable 5.1
Signed-off-by: Thomas Bachem <mail@thomasbachem.com>
---
 hook.c          |  3 ++-
 t/t1800-hook.sh | 22 ++++++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/hook.c b/hook.c
index 5e756cb353..c500fec33e 100644
--- a/hook.c
+++ b/hook.c
@@ -184,7 +184,8 @@ static int hook_config_lookup_all(const char *key, const char *value,
 		return 0;
 	}
 
-	if (!value)
+	/* .enabled and .parallel are bools, where a missing value means true */
+	if (!value && strcmp(subkey, "enabled") && strcmp(subkey, "parallel"))
 		return config_error_nonbool(key);
 
 	/* Extract name, ensuring it is null-terminated. */
diff --git a/t/t1800-hook.sh b/t/t1800-hook.sh
index 45b99a7f04..fca4cfc712 100755
--- a/t/t1800-hook.sh
+++ b/t/t1800-hook.sh
@@ -516,6 +516,17 @@ test_expect_success 'globally disabled hook can be re-enabled locally' '
 	test_cmp expected actual
 '
 
+test_expect_success 'hook.<friendly-name>.enabled without a value means true' '
+	test_config_global hook.global-hook.event "test-hook" &&
+	test_config_global hook.global-hook.command "echo \"global-hook ran\"" &&
+	test_config_global hook.global-hook.enabled false &&
+
+	echo "global-hook ran" >expected &&
+	git -c hook.global-hook.enabled \
+		hook run --allow-unknown-hook-name test-hook 2>actual &&
+	test_cmp expected actual
+'
+
 test_expect_success 'configured hooks run before hookdir hook' '
 	setup_hookdir &&
 	test_config hook.first.event "pre-commit" &&
@@ -1080,6 +1091,17 @@ test_expect_success 'hook.jobs=-1 resolves to online_cpus()' '
 	test_grep "\"region_enter\".*\"hook\".*\"test-hook\".*\"max:$cpus\"" trace.txt
 '
 
+test_expect_success 'hook.<friendly-name>.parallel without a value means true' '
+	test_config hook.hook-1.event test-hook &&
+	test_config hook.hook-1.command "true" &&
+	test_config hook.jobs 2 &&
+
+	GIT_TRACE2_EVENT="$(pwd)/trace-parallel.txt" \
+		git -c hook.hook-1.parallel \
+		hook run --allow-unknown-hook-name test-hook >out 2>err &&
+	test_grep "\"region_enter\".*\"hook\".*\"test-hook\".*\"max:2\"" trace-parallel.txt
+'
+
 test_expect_success 'hook.<event>.jobs=-1 resolves to online_cpus()' '
 	test_config hook.hook-1.event test-hook &&
 	test_config hook.hook-1.command "true" &&
-- 
gitgitgadget
Previous: Thomas Bachem via GitGitGadgetNext: Junio C Hamano
Message 10 of 11 in “Fix two hook configuration bugs”
  1. 0/2 Fix two hook configuration bugsThomas Bachem via GitGitGadget, Oct 20, 2026
  2. 1/2 hook: honor hook.<event>.enabled for the hookdir hookThomas Bachem via GitGitGadget, Oct 20, 2026
  3. Junio C HamanoOct 20, 2026
  4. Adrian RatiuOct 20, 2026
  5. Junio C HamanoOct 21, 2026
  6. Adrian RatiuOct 22, 2026
  7. 2/2 hook: accept .enabled and .parallel given without a valueThomas Bachem via GitGitGadget, Oct 20, 2026
  8. 0/2 Two hook configuration changesThomas Bachem via GitGitGadget, Oct 23, 2026
  9. 1/2 hook: make hook.<event>.enabled cover the hookdir hookThomas Bachem via GitGitGadget, Oct 23, 2026
  10. 2/2 hook: accept .enabled and .parallel given without a valueThomas Bachem via GitGitGadget, Oct 23, 2026
  11. Junio C HamanoOct 23, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.