<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/hook.h, branch main</title>
<subtitle>Fork of git SCM with my patches.</subtitle>
<id>http://git.kilabit.info/git/atom?h=main</id>
<link rel='self' href='http://git.kilabit.info/git/atom?h=main'/>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/'/>
<updated>2026-03-25T21:00:47Z</updated>
<entry>
<title>hook: show disabled hooks in "git hook list"</title>
<updated>2026-03-25T21:00:47Z</updated>
<author>
<name>Adrian Ratiu</name>
<email>adrian.ratiu@collabora.com</email>
</author>
<published>2026-03-25T19:55:02Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=e17bd99281ae01a758d717bdfaa759bbeefb6149'/>
<id>urn:sha1:e17bd99281ae01a758d717bdfaa759bbeefb6149</id>
<content type='text'>
Disabled hooks were filtered out of the cache entirely, making them
invisible to "git hook list". Keep them in the cache with a new
"disabled" flag which is propagated to the respective struct hook.

"git hook list" now shows disabled hooks as tab-separated columns,
with the status as a prefix before the name (like scope with
--show-scope). With --show-scope it looks like:

$ git hook list --show-scope pre-commit
global	linter
local	disabled	no-leaks
hook from hookdir

A disabled hook without a command issues a warning instead of the
fatal "hook.X.command must be configured" error. We could also throw
an error, however it seemd a bit excessive to me in this case.

Suggested-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Adrian Ratiu &lt;adrian.ratiu@collabora.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>hook: show config scope in git hook list</title>
<updated>2026-03-25T21:00:47Z</updated>
<author>
<name>Adrian Ratiu</name>
<email>adrian.ratiu@collabora.com</email>
</author>
<published>2026-03-25T19:55:01Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=b66efad2b1f53755a80699dc39f94e2b15d6af67'/>
<id>urn:sha1:b66efad2b1f53755a80699dc39f94e2b15d6af67</id>
<content type='text'>
Users running "git hook list" can see which hooks are configured but
have no way to tell at which config scope (local, global, system...)
each hook was defined.

Store the scope from ctx-&gt;kvi-&gt;scope in the single-pass config callback,
then carry it through the cache to the hook structs, so we can expose it
to users via the "git hook list --show-scope" flag, which mirrors the
existing git config --show-scope convention.

Without the flag the output is unchanged.

The scope is printed as a tab-separated prefix (like "git config --show-scope"),
making it unambiguously machine-parseable even when the friendly name
contains spaces.

Example usage:
$ git hook list --show-scope pre-commit
global	linter
local	no-leaks
hook from hookdir

Traditional hooks from the hookdir are unaffected by --show-scope since
the config scope concept does not apply to them.

Suggested-by: Junio C Hamano &lt;gitster@pobox.com&gt;
Signed-off-by: Adrian Ratiu &lt;adrian.ratiu@collabora.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>hook: make consistent use of friendly-name in docs</title>
<updated>2026-03-25T21:00:46Z</updated>
<author>
<name>Adrian Ratiu</name>
<email>adrian.ratiu@collabora.com</email>
</author>
<published>2026-03-25T19:54:58Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=2e5dbaff169dfb28fa8e8c4f992d8252a4ef1312'/>
<id>urn:sha1:2e5dbaff169dfb28fa8e8c4f992d8252a4ef1312</id>
<content type='text'>
Both `name` and `friendly-name` is being used. Standardize on
`friendly-name` for consistency since name is rather generic,
even when used in the hooks namespace.

Suggested-by: Junio C Hamano &lt;gitster@pobox.com&gt;
Signed-off-by: Adrian Ratiu &lt;adrian.ratiu@collabora.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>hook: replace hook_list_clear() -&gt; string_list_clear_func()</title>
<updated>2026-03-25T21:00:46Z</updated>
<author>
<name>Adrian Ratiu</name>
<email>adrian.ratiu@collabora.com</email>
</author>
<published>2026-03-25T19:54:57Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=a8b1ba86d494ea8825292c91c243e5d84fd7ee2c'/>
<id>urn:sha1:a8b1ba86d494ea8825292c91c243e5d84fd7ee2c</id>
<content type='text'>
Replace the custom function with string_list_clear_func() which
is a more common pattern for clearing a string_list.

To be able to do this, rework hook_clear() into hook_free(), so
it can be passed to string_list_clear_func().

A slight complication is the need to keep a copy of the internal
cb data free() pointer, however I think it's worth it since the
API becomes cleaner, e.g. no more calls with NULL function args
like hook_list_clear(hooks, NULL).

In other words, the callers don't need to keep track of hook
internal state to determine when cleanup is necessary or not
(pass NULL) because each `struct hook` now owns its data_free
callback.

Suggested-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Adrian Ratiu &lt;adrian.ratiu@collabora.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>hook: rename cb_data_free/alloc -&gt; hook_data_free/alloc</title>
<updated>2026-03-25T21:00:46Z</updated>
<author>
<name>Adrian Ratiu</name>
<email>adrian.ratiu@collabora.com</email>
</author>
<published>2026-03-25T19:54:55Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=8f7db6f8b585a3eef4ba595efd2d098f9abf3606'/>
<id>urn:sha1:8f7db6f8b585a3eef4ba595efd2d098f9abf3606</id>
<content type='text'>
Rename the hook callback function types to use the hook prefix.

This is a style fix with no logic changes.

Suggested-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Adrian Ratiu &lt;adrian.ratiu@collabora.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>hook: fix minor style issues</title>
<updated>2026-03-25T21:00:45Z</updated>
<author>
<name>Adrian Ratiu</name>
<email>adrian.ratiu@collabora.com</email>
</author>
<published>2026-03-25T19:54:54Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=b06770e5d8948c7cad76d7507423376eacf1e005'/>
<id>urn:sha1:b06770e5d8948c7cad76d7507423376eacf1e005</id>
<content type='text'>
Fix some minor style nits pointed out by Patrick, Junio and Eric:
  * Use CALLOC_ARRAY instead of xcalloc.
  * Init struct members during declaration.
  * Simplify if condition boolean logic.
  * Missing curly braces in if/else stmts.
  * Unnecessary header includes.
  * Capitalization and full-stop in error/warn messages.
  * Curly brace on separate line when defining struct.
  * Comment spelling: free'd -&gt; freed.
  * Sort the included headers.
  * Blank line fixes to improve readability.

These contain no logic changes, the code behaves the same as before.

Suggested-by: Eric Sunshine &lt;sunshine@sunshineco.com&gt;
Suggested-by: Junio C Hamano &lt;gitster@pobox.com&gt;
Suggested-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Adrian Ratiu &lt;adrian.ratiu@collabora.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>hook: include hooks from the config</title>
<updated>2026-02-19T21:23:41Z</updated>
<author>
<name>Adrian Ratiu</name>
<email>adrian.ratiu@collabora.com</email>
</author>
<published>2026-02-18T22:23:48Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=03b4043b9182bd3d36541371fa39f04d6d038286'/>
<id>urn:sha1:03b4043b9182bd3d36541371fa39f04d6d038286</id>
<content type='text'>
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.&lt;friendly-name&gt;.command = &lt;path-to-hook&gt;" and
"hook.&lt;friendly-name&gt;.event = &lt;hook-event&gt;" lines.

Hooks will be started in config order of the "hook.&lt;name&gt;.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 &lt;emilyshaffer@google.com&gt;
Signed-off-by: Adrian Ratiu &lt;adrian.ratiu@collabora.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>hook: add "git hook list" command</title>
<updated>2026-02-19T21:23:41Z</updated>
<author>
<name>Emily Shaffer</name>
<email>emilyshaffer@google.com</email>
</author>
<published>2026-02-18T22:23:47Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=9fdaa6788924d4bb5ffc3a5908dae8a50e072f77'/>
<id>urn:sha1:9fdaa6788924d4bb5ffc3a5908dae8a50e072f77</id>
<content type='text'>
The previous commit introduced an ability to run multiple commands for
hook events and next commit will introduce the ability to define hooks
from configs, in addition to the "traditional" hooks from the hookdir.

Introduce a new command "git hook list" to make inspecting hooks easier
both for users and for the tests we will add.

Further commits will expand on this, e.g. by adding a -z output mode.

Signed-off-by: Emily Shaffer &lt;emilyshaffer@google.com&gt;
Signed-off-by: Adrian Ratiu &lt;adrian.ratiu@collabora.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>hook: run a list of hooks to prepare for multihook support</title>
<updated>2026-02-19T21:23:40Z</updated>
<author>
<name>Emily Shaffer</name>
<email>emilyshaffer@google.com</email>
</author>
<published>2026-02-18T22:23:46Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=4a36cb4c9f0f508db2e5dda75673e0d4b1242007'/>
<id>urn:sha1:4a36cb4c9f0f508db2e5dda75673e0d4b1242007</id>
<content type='text'>
Hooks are limited to run one command (the default from the hookdir) for
each event. This limitation makes it impossible to run multiple commands
via config files, which the next commits will add.

Implement the ability to run a list of hooks in hook.[ch]. For now, the
list contains only one entry representing the "default" hook from the
hookdir, so there is no user-visible change in this commit.

All hook commands still run sequentially like before. A separate patch
series will enable running them in parallel.

Signed-off-by: Emily Shaffer &lt;emilyshaffer@google.com&gt;
Signed-off-by: Adrian Ratiu &lt;adrian.ratiu@collabora.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>hook: add internal state alloc/free callbacks</title>
<updated>2026-02-19T21:23:40Z</updated>
<author>
<name>Adrian Ratiu</name>
<email>adrian.ratiu@collabora.com</email>
</author>
<published>2026-02-18T22:23:45Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=ee2fbfd6b28fba20bc936ad1c2cb2617ba251025'/>
<id>urn:sha1:ee2fbfd6b28fba20bc936ad1c2cb2617ba251025</id>
<content type='text'>
Some hooks use opaque structs to keep internal state between callbacks.

Because hooks ran sequentially (jobs == 1) with one command per hook,
these internal states could be allocated on the stack for each hook run.

Next commits add the ability to run multiple commands for each hook, so
the states cannot be shared or stored on the stack anymore, especially
since down the line we will also enable parallel execution (jobs &gt; 1).

Add alloc/free helpers for each hook, doing a "deep" alloc/init &amp; free
of their internal opaque struct.

The alloc callback takes a context pointer, to initialize the struct at
at the time of resource acquisition.

These callbacks must always be provided together: no alloc without free
and no free without alloc, otherwise a BUG() is triggered.

Signed-off-by: Adrian Ratiu &lt;adrian.ratiu@collabora.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
