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

Re: [PATCH] rev-parse --parseopt: fix handling of optional arguments

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Oct 16, 2013, 22:33 UTC
Message-ID
<20131016223306.GN9464@google.com>
In-Reply-To
<20131016141411.GB4589@mars-attacks.org>
Nicolas Vigier wrote:
Show 19 quoted lines
> I'm thinking about a patch to add the following two options to rev-parse :
>
> --sticked-opt-args::
> 	Only meaningful in --parseopt mode. Tells the options parser to
> 	output options with optional arguments in sticked form. The
> 	default is to output them in non-sticked mode, which can be
> 	difficult to parse unambiguously.
>
> --long-options::
> 	Only meaningful in --parseopt mode. Tells the options parser to
> 	output long option names, when available. The default is to use
> 	short option names when available.
>
> When you want to handle optional args unambiguously, you use the
> --sticked-opt-args option. And if you think an empty value can be
> a meaningful value, you add the --long-options option to be able to
> distinguish them.
>
> Would it make sense ?
That would make four distinct output formats:
 --sticked --long:
	Doesn't lose any information that normal use of C parse_options
	would have kept, as long as every short option with optional
	argument has a corresponding long option.
 --sticked --no-long:
	Loses the distinction between --gpg-sign and --gpg-sign=
 --no-sticked --long:
	Semantically equivalent to the existing output, just noisier.
 --no-sticked --no-long:
 	The existing output.

Are all of them needed? Is it worth tempting people to use --sticked --no-long when we know its pitfalls?

I would think that only the current normalized form and --sticked --long would need to be supported.

The fix you originally proposed seems tolerable to me, too --- it is not very invasive, and while it doesn't distinguish the empty-argument form "--gpg-sign=", that's a bit of an edge case.

The main reason I slightly prefer the solution that makes the output use long, sticked options on request is that the "normalized" commandline would start being an actual equivalent command line the command expects, instead of a weird, subtly different syntax. (That problem already exists with or without your patch --- the patch just draws attention to it.)

Previous: Nicolas VigierNext: Nicolas Vigier
Message 13 of 25 in “rev-parse --parseopt: fix handling of optional arguments”
  1. rev-parse --parseopt: fix handling of optional argumentsNicolas Vigier, Oct 15, 2013
  2. Junio C HamanoOct 15, 2013
  3. Nicolas VigierOct 15, 2013
  4. Jonathan NiederOct 15, 2013
  5. Junio C HamanoOct 15, 2013
  6. Jonathan NiederOct 15, 2013
  7. Johannes SixtOct 16, 2013
  8. Jeff KingOct 16, 2013
  9. Junio C HamanoOct 16, 2013
  10. Jeff KingOct 16, 2013
  11. Nicolas VigierOct 16, 2013
  12. Nicolas VigierOct 16, 2013
  13. Jonathan NiederOct 16, 2013
  14. rev-parse --parseopt: add the --sticked-long modeNicolas Vigier, Oct 25, 2013
  15. Junio C HamanoOct 25, 2013
  16. Nicolas VigierOct 25, 2013
  17. Junio C HamanoOct 25, 2013
  18. Philip OakleyOct 26, 2013
  19. Junio C HamanoOct 28, 2013
  20. sticked -> stuckNicolas Vigier, Oct 31, 2013
  21. 1/2 Use the word 'stuck' instead of 'sticked'Nicolas Vigier, Oct 31, 2013
  22. Junio C HamanoOct 31, 2013
  23. 2/2 rev-parse --parseopt: add the --stuck-long modeNicolas Vigier, Oct 31, 2013
  24. Michael HaggertyOct 27, 2013
  25. Nicolas VigierOct 15, 2013

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.