git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Pranit Bauva <pranit.bauva@gmail.com>
Date
Mar 16, 2016, 21:41 UTC
Message-ID
<CAFZEwPMGBKCfEoo2ofCak25jDMRwWwq=1HmgqSyPEpJWhOL_6g@mail.gmail.com>
In-Reply-To
<CAPig+cRKyaUefz0qj6unkaiPg25=Xi2WorQE4Fm46CCf00UbHQ@mail.gmail.com>
On Thu, Mar 17, 2016 at 3:07 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 27 quoted lines
> 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.

Previous: Eric SunshineNext: Jeff King
Message 6 of 18 in “parse-options does not recognize "unspecified" behavior”
  1. Pranit BauvaMar 16, 2016
  2. Jeff KingMar 16, 2016
  3. Pranit BauvaMar 16, 2016
  4. Jeff KingMar 16, 2016
  5. Eric SunshineMar 16, 2016
  6. Pranit BauvaMar 16, 2016
  7. Jeff KingMar 16, 2016
  8. Stefan BellerMar 16, 2016
  9. Jeff KingMar 16, 2016
  10. Stefan BellerMar 16, 2016
  11. Jeff KingMar 17, 2016
  12. Eric SunshineMar 17, 2016
  13. Jeff KingMar 17, 2016
  14. SZEDER GáborMar 19, 2016
  15. Pranit BauvaMar 19, 2016
  16. SZEDER GáborMar 25, 2016
  17. Pranit BauvaMar 25, 2016
  18. Pranit BauvaMar 16, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.