]> git.ipfire.org Git - thirdparty/git.git/commit
hook: allow hook.jobs=-1 to use all available CPU cores
authorAdrian Ratiu <adrian.ratiu@collabora.com>
Fri, 10 Apr 2026 09:06:07 +0000 (12:06 +0300)
committerJunio C Hamano <gitster@pobox.com>
Fri, 10 Apr 2026 14:58:55 +0000 (07:58 -0700)
commit495b7d54dc006556548e2fd3ca15c4f533917329
treeda1d2646ff4d7d677de257a002a9f1fa288133ff
parentdcfb5af67e7d7156c4d1ede66de18088c990356c
hook: allow hook.jobs=-1 to use all available CPU cores

Allow -1 as a value for hook.jobs, hook.<event>.jobs, and the -j
CLI flag to mean "use as many jobs as there are CPU cores", matching
the convention used by fetch.parallel and other Git subsystems.

The value is resolved to online_cpus() at parse time so the rest
of the code always works with a positive resolved count.

Other non-positive values (0, -2, etc) are rejected with a warning
(config) or die (CLI).

Suggested-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/config/hook.adoc
builtin/hook.c
hook.c
t/t1800-hook.sh