]> Kevux Git Server - rit/commit
hook: show config scope in git hook list
authorAdrian Ratiu <adrian.ratiu@collabora.com>
Wed, 25 Mar 2026 19:55:01 +0000 (21:55 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 25 Mar 2026 21:00:47 +0000 (14:00 -0700)
commitb66efad2b1f53755a80699dc39f94e2b15d6af67
tree3e42cefd6493973af8c8e6e6aa6059836cb1fc50
parentd8513bc5d84f21ea6d327a9cf9a369077eb19c67
hook: show config scope in git hook list

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->kvi->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 <gitster@pobox.com>
Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-hook.adoc
builtin/hook.c
hook.c
hook.h
t/t1800-hook.sh