Re: [PATCH v3 07/13] git hook run: add an --ignore-missing flag
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 29, 2021, 05:59 UTC
- Message-ID
- <xmqqbl38mkwa.fsf@gitster.g>
- In-Reply-To
- <patch-v3-07.13-840fb530df3-20211019T231647Z-avarab@gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
Show 18 quoted lines
> + int ignore_missing = 0;
> const char *hook_name;
> const char *hook_path;
> struct option run_options[] = {
> + OPT_BOOL(0, "ignore-missing", &ignore_missing,
> + N_("silently ignore missing requested <hook-name>")),
> OPT_END(),
> };
> int ret;
> @@ -53,6 +56,8 @@ static int run(int argc, const char **argv, const char *prefix)
> git_config(git_default_config, NULL);
>
> hook_name = argv[0];
> + if (ignore_missing)
> + return run_hooks_oneshot(hook_name, &opt);
> hook_path = find_hook(hook_name);
> if (!hook_path) {
> error("cannot find a hook named %s", hook_name);Given that the rest of this "run()" function is more or less identical to run_hooks_oneshot(), I have to wonder why we do not give an .ignore_missing member to the hooks_opt structure to be done with this. Otehrwise, every time the underlying run_hooks() interface needs to change, we need to update two places, no?