Re: parse-options does not recognize "unspecified" behavior

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 17, 2016 at 3:07 AM, Eric Sunshine <sunshine@xxxxxxxxxxxxxx> wrote:

> The goal comes from his GSoC microproject. Specifically, Pranit wants
> an "unspecified" value. The reason is that he is adding a
> commit.verbose=<level> config variable to back the existing git-commit
> --verbose option. Any use of --verbose (one or more times) or
> --no-verbose should override the config.verbose value altogether, so
> he wants a way to know if --verbose or --no-verbose was used; hence
> the "unspecified" value. And, really, this issue isn't necessarily
> specific to git-commit. It could apply to any command that understands
> verbosity levels and wants to be able to get them from both a config
> variable and a command-line option.
>
> A much easier solution would be to update OPT_VERBOSE() to understand
> that negative values are "unspecified", and then --verbose would
> (pseudocode):
>
>     if (value < 0)
>         value = 0
>     value++;
>
> and --no-verbose would:
>
>     value = 0
>
> That should be compatible with existing clients of OPT__VERBOSE()
> which initialize the value to 0, and should satisfy Pranit's case; he
> can initialize it to -1, and if it is still -1 when option parsing is
> done, then he knows that neither --verbose nor --no-verbose was seen.

This is a much easier solution. I didn't think of this. This type of
problem can only arise with only verbose, so it would be better to
specifically change that part of code.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]