From: SZEDER Gábor Date: Mon, 06 Apr 2026 16:39:48 GMT Subject: Re: [PATCH v3 05/12] hook: include hooks from the config Message-ID: In-Reply-To: <20260301184500.1488433-6-adrian.ratiu@collabora.com> On Sun, Mar 01, 2026 at 08:44:53PM +0200, Adrian Ratiu wrote: > 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..command = " and > "hook..event = " lines. > > Hooks will be started in config order of the "hook..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 > Signed-off-by: Adrian Ratiu > --- > diff --git a/t/t1800-hook.sh b/t/t1800-hook.sh > index d1380a4f0e..3a95cfe16d 100755 > --- a/t/t1800-hook.sh > +++ b/t/t1800-hook.sh > @@ -1,10 +1,26 @@ > #!/bin/sh > > -test_description='git-hook command' > +test_description='git-hook command and config-managed multihooks' > > . ./test-lib.sh > . "$TEST_DIRECTORY"/lib-terminal.sh > > +setup_hooks () { > + test_config hook.ghi.command "/path/ghi" > + test_config hook.ghi.event pre-commit --add > + test_config hook.ghi.event test-hook --add > + test_config_global hook.def.command "/path/def" > + test_config_global hook.def.event pre-commit --add > +} > + > +setup_hookdir () { > + mkdir .git/hooks > + write_script .git/hooks/pre-commit <<-EOF > + echo \"Legacy Hook\" > + EOF > + test_when_finished rm -rf .git/hooks > +} There is no &&-chain in these test helper functions.