Re: [PATCH/RFC] parse-options.c: make OPTION__COUNTUP consider negative values
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Mar 17, 2016, 08:14 UTC
- Message-ID
- <CAPig+cTi7biYK7=P07-VZvA=d6mwgsdYxZG_vvVm7sRj2fcu6Q@mail.gmail.com>
- In-Reply-To
- <CAPig+cRkAE4BzbgniP=peHE-pBfKt1i2C4MqJcJ36sMfsSh3KQ@mail.gmail.com>
On Thu, Mar 17, 2016 at 3:28 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 11 quoted lines
> I also realized that Pranit can achieve the desired behavior without > modifying OPT__VERBOSE at all. Specifically, rather than initializing > his opt_verbose variable to -1, he can instead initialize it to 1. > Then: > > * if --verbose is seen (one or more times), opt_verbose will be >=2, > and the real verbosity level will be (opt_verbose - 1) > > * if --no-verbose is seen, opt_verbose will be 0 > > * if neither is seen, then opt_verbose will remain 1
Eh, this is bogus. "git commit --no-verbose --verbose" would leave opt_verbose at 1, which would fool it into thinking neither had been seen.
Thus, a further +1 for an OPT__VERBOSE which understands "unspecified".
> However, I think this approach is far too ugly and non-obvious to > seriously suggest using it, whereas the change to OPT__VERBOSE is > easily understood and could prove useful in the future for other > commands with multiple verbosity levels.