]> git.99rst.org Git - git.git/commit
hook: include hooks from the config
authorAdrian Ratiu <redacted>
Wed, 18 Feb 2026 22:23:48 +0000 (00:23 +0200)
committerJunio C Hamano <redacted>
Thu, 19 Feb 2026 21:23:41 +0000 (13:23 -0800)
commit03b4043b9182bd3d36541371fa39f04d6d038286
tree46af18d57733c40b3438b40b6029d22124c95a30
parent9fdaa6788924d4bb5ffc3a5908dae8a50e072f77
hook: include hooks from the config

Teach the hook.[hc] library to parse configs to populate the list of
hooks to run for a given event.

Multiple commands can be specified for a given hook by providing
"hook.<friendly-name>.command = <path-to-hook>" and
"hook.<friendly-name>.event = <hook-event>" lines.

Hooks will be started in config order of the "hook.<name>.event"
lines and will be run sequentially (.jobs == 1) like before.
Running the hooks in parallel will be enabled in a future patch.

The "traditional" hook from the hookdir is run last, if present.

A strmap cache is added to struct repository to avoid re-reading
the configs on each rook run. This is useful for hooks like the
ref-transaction which gets executed multiple times per process.

Examples:

  $ git config --get-regexp "^hook\."
  hook.bar.command=~/bar.sh
  hook.bar.event=pre-commit

  # Will run ~/bar.sh, then .git/hooks/pre-commit
  $ git hook run pre-commit

Signed-off-by: Emily Shaffer <redacted>
Signed-off-by: Adrian Ratiu <redacted>
Signed-off-by: Junio C Hamano <redacted>
Documentation/config/hook.adoc [new file with mode: 0644]
Documentation/git-hook.adoc
builtin/hook.c
hook.c
hook.h
repository.c
repository.h
t/t1800-hook.sh
git clone https://git.99rst.org/PROJECT