From: Adrian Ratiu Date: Mon, 09 Mar 2026 00:54:10 GMT Subject: [PATCH 04/10] hook: detect & emit two more bugs Message-ID: <20260309005416.2760030-5-adrian.ratiu@collabora.com> In-Reply-To: <20260309005416.2760030-1-adrian.ratiu@collabora.com> 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 --- hook.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hook.c b/hook.c index bc1c45b16d..b8ed4d79e2 100644 --- a/hook.c +++ b/hook.c @@ -408,7 +408,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.732.gb351b5166d.dirty