aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorAdrian Ratiu <adrian.ratiu@collabora.com>2026-03-25 21:55:02 +0200
committerJunio C Hamano <gitster@pobox.com>2026-03-25 14:00:47 -0700
commite17bd99281ae01a758d717bdfaa759bbeefb6149 (patch)
treea3d9a8c28b5d133eafd6038f2b099138f984cff5 /builtin
parentb66efad2b1f53755a80699dc39f94e2b15d6af67 (diff)
downloadgit-e17bd99281ae01a758d717bdfaa759bbeefb6149.tar.xz
hook: show disabled hooks in "git hook list"
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 <ps@pks.im> Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/hook.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/builtin/hook.c b/builtin/hook.c
index 4cc65a0dc5..f671e7f91a 100644
--- a/builtin/hook.c
+++ b/builtin/hook.c
@@ -72,16 +72,20 @@ static int list(int argc, const char **argv, const char *prefix,
case HOOK_TRADITIONAL:
printf("%s%c", _("hook from hookdir"), line_terminator);
break;
- case HOOK_CONFIGURED:
- if (show_scope)
- printf("%s\t%s%c",
- config_scope_name(h->u.configured.scope),
- h->u.configured.friendly_name,
- line_terminator);
+ case HOOK_CONFIGURED: {
+ const char *name = h->u.configured.friendly_name;
+ const char *scope = show_scope ?
+ config_scope_name(h->u.configured.scope) : NULL;
+ if (scope)
+ printf("%s\t%s%s%c", scope,
+ h->u.configured.disabled ? "disabled\t" : "",
+ name, line_terminator);
else
- printf("%s%c", h->u.configured.friendly_name,
- line_terminator);
+ printf("%s%s%c",
+ h->u.configured.disabled ? "disabled\t" : "",
+ name, line_terminator);
break;
+ }
default:
BUG("unknown hook kind");
}