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

Re: [PATCH 1/3] git-compat-util: introduce skip_to_opt_val()

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 3, 2017, 22:48 UTC
Message-ID
<xmqqfu8rig10.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<CAP8UFD2OSsqzhyAL-QG1TOowB-xgbf=kC9wHre+FLc+0J1Xy+Q@mail.gmail.com>
Christian Couder <christian.couder@gmail.com> writes:
> Anyway there is a design choice to be made. Adding a "const char
> *default" argument makes the function more generic,...

I didn't suggest anything of that sort, and I do not understand why you are repeatedly talking about "default" that you considered and rejected, as if it were an alternative viable option. I agree that "default" is not yet a good idea and it is a solution to a problem that is not yet shown to exist.

On the other hand, just assigning NULL to *arg when you did not see a delimiting '=', on the other hand, is an alternative option that is viable.

> .... I think setting
> "arg" to NULL increases the risk of crashes and makes it too easy to
> make "--key" and "--key=" behave differently which I think is not
> consistent and not intuitive.

So now this is very specific to the need of command line argument parsing and is not a generic thing? You cannot have your cake and eat it too, though.

Previous: Christian CouderNext: Christian Couder
Message 9 of 11 in “git-compat-util: introduce skip_to_opt_val()”
  1. 1/3 git-compat-util: introduce skip_to_opt_val()Christian Couder, Dec 3, 2017
  2. 2/3 index-pack: use skip_to_opt_val()Christian Couder, Dec 3, 2017
  3. 3/3 diff: use skip_to_opt_val()Christian Couder, Dec 3, 2017
  4. Jacob KellerDec 7, 2017
  5. Jacob KellerDec 7, 2017
  6. Christian CouderDec 7, 2017
  7. Junio C HamanoDec 3, 2017
  8. Christian CouderDec 3, 2017
  9. Junio C HamanoDec 3, 2017
  10. Christian CouderDec 4, 2017
  11. Junio C HamanoDec 4, 2017

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.