Thread (18 messages) flat view 18 messages, 5 authors, 2016-06-15

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

From: Pranit Bauva <hidden>
Date: 2016-06-15 23:08:46

On Thu, Mar 17, 2016 at 3:07 AM, Eric Sunshine [off-list ref] 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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help