Skip to content

Commit 4d10f4a

Browse files
10ne1gitster
authored andcommitted
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 <ps@pks.im> Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 8f7db6f commit 4d10f4a

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

hook.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,11 @@ static int pick_next_hook(struct child_process *cp,
409409
} else if (h->kind == HOOK_CONFIGURED) {
410410
/* to enable oneliners, let config-specified hooks run in shell. */
411411
cp->use_shell = true;
412+
if (!h->u.configured.command)
413+
BUG("non-disabled HOOK_CONFIGURED hook has no command");
412414
strvec_push(&cp->args, h->u.configured.command);
415+
} else {
416+
BUG("unknown hook kind");
413417
}
414418

415419
if (!cp->args.nr)

0 commit comments

Comments
 (0)