From 4d10f4a9527e664e001b9747b1daff6681b3f807 Mon Sep 17 00:00:00 2001 From: Adrian Ratiu Date: Wed, 25 Mar 2026 21:54:56 +0200 Subject: [PATCH] hook: detect & emit two more bugs Trigger a bug when an unknown hook type is encountered while setting up hook execution. Also issue a bug if a configured hook is enabled without a cmd. Mostly useful for defensive coding. Suggested-by: Patrick Steinhardt Signed-off-by: Adrian Ratiu Signed-off-by: Junio C Hamano --- hook.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hook.c b/hook.c index 4a0db5cfeb..b0226ed716 100644 --- a/hook.c +++ b/hook.c @@ -409,7 +409,11 @@ static int pick_next_hook(struct child_process *cp, } else if (h->kind == HOOK_CONFIGURED) { /* to enable oneliners, let config-specified hooks run in shell. */ cp->use_shell = true; + if (!h->u.configured.command) + BUG("non-disabled HOOK_CONFIGURED hook has no command"); strvec_push(&cp->args, h->u.configured.command); + } else { + BUG("unknown hook kind"); } if (!cp->args.nr) -- 2.52.0