Re: [PATCH 1/2] bisect--helper: use OPT_CMDMODE instead of OPT_BOOL
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- May 4, 2016, 11:02 UTC
- Message-ID
- <alpine.DEB.2.20.1605041259180.9313@virtualbox>
- In-Reply-To
- <1462338472-3581-2-git-send-email-pranit.bauva@gmail.com>
Hi Pranit,
On Wed, 4 May 2016, Pranit Bauva wrote:
> `--next-all` is meant to be used as a sub command to support multiple > "operation mode" though the current implementation does not contain any > other sub command along side with `--next-all` but further commits will > include some more subcommands.
That is a good explanation.
Show 9 quoted lines
> diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
> index 3324229..5f6ef8c 100644
> --- a/builtin/bisect--helper.c
> +++ b/builtin/bisect--helper.c
> @@ -8,13 +8,17 @@ static const char * const git_bisect_helper_usage[] = {
> NULL
> };
>
> +enum sub_commands {Instead of "sub_commands" and ...
Show 7 quoted lines
> + NEXT_ALL = 1
> +};
> +
> int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
> {
> - int next_all = 0;
> + int sub_command = 0;... sub_command, seeing as you convert things into ...
Show 6 quoted lines
> int no_checkout = 0;
> struct option options[] = {
> - OPT_BOOL(0, "next-all", &next_all,
> - N_("perform 'git bisect next'")),
> + OPT_CMDMODE(0, "next-all", &sub_command,
> + N_("perform 'git bisect next'"), NEXT_ALL),... using CMDMODE, how about using `enum mode` and `int mode`? And actually `enum mode mode` instead of `int mode`. Or...
Actually, it could be even more concise by writing
enum { NEXT_ALL = 1 } mode = 0;There is not really a need for that enum to be in a different scope than cmd_bisect__helper(), and neither does it need to be named...
Ciao, Dscho