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

parse-options does not recognize "unspecified" behavior

From
Pranit Bauva <pranit.bauva@gmail.com>
Date
Mar 16, 2016, 19:51 UTC
Message-ID
<CAFZEwPPd2wFqFq2LFEzN2CzhTV6C420SLPcXi1SWE=z2epOYLw@mail.gmail.com>
Hey!

I noticed that parse-options does not recognize the variable which is set to -1 so as to denote the "unspecified" value.

I did the following changes in builtin/commit.c (in master branch not
the patch I am working on) :
 - static int verbose = -1
 - introduced a printf statement after parsing the options to print
the value of verbose.
When I ran `git commit` :
 I get the output that verbose is set to -1.

When I ran `git commit -v` : I get the output that verbose is set to 0.

When I ran `git commit -v -v` : I get the output that verbose is set to 1.

When I ran `git commit --no-verbose` : I get the out that verbose is set to 0.

Then I set verbose = -2.
And the output was obtained in a similar format.
 -2 with `git commit`
 -1 with `git commit -v`
  0 with `git commit -v -v`
  0 with `git commit --no-verbose`
  1 with `git commit -v -v -v`

It seems that parse-options just increments the value without considering the -1 flag to denote "unspecified value".

Is this a bug?
Next: Jeff King
Message 1 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.