Re: [PATCH v5 1/2] bisect--helper: use OPT_CMDMODE instead of OPT_BOOL
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- May 8, 2016, 07:04 UTC
- Message-ID
- <alpine.DEB.2.20.1605080858190.4092@virtualbox>
- In-Reply-To
- <1462546167-1125-2-git-send-email-pranit.bauva@gmail.com>
Hi Pranit,
On Fri, 6 May 2016, Pranit Bauva wrote:
Show 11 quoted lines
> diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
> index 3324229..d8de651 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 subcommand {
> + NEXT_ALL = 1
> +};I still do not think that this enum needs to have file scope. Function scope is enough.
> int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
> {
> - int next_all = 0;
> + int subcommand = 0;Since subcommand is not simply an integer, but wants to take on the values defined in the enum above, the type should be changed accordingly. You could do it this way (short and sweet, with the appropriate scope):
enum { NEXT_ALL = 1 } subcommand = 0;See https://github.com/git/git/blob/v2.8.2/builtin/replace.c#L423-L430 for an example (which uses "cmdmode" instead of "subcommand", too).
Ciao, Dscho