Subject: Re: [PATCH v2 16/20] builtin/reflog.c: let parse-options parse subcommands

From: Ævar Arnfjörð Bjarmason <[email-masked]>
Date: Fri, 19 Aug 2022 20:08:22 +0200

On Fri, Aug 19 2022, SZEDER Gábor wrote:

> +	parse_opt_subcommand_fn *fn = NULL;

Re the comment on notes.c this is a bit like that pattern...

> -log_reflog:
> -	return cmd_log_reflog(argc, argv, prefix);
> +			     PARSE_OPT_KEEP_UNKNOWN_OPT);
> +	if (fn)
> +		return fn(argc - 1, argv + 1, prefix);
> +	else
> +		return cmd_log_reflog(argc, argv, prefix);
>  }

Maybe more obvious (untested):

	if (!fn) {
		argc--;
		argv++;
		fn = cmd_log_reflog;
	}
	return fn(argc, argv, prefix);