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

Re: [PATCH 1/2] do not mangle short options which take arguments

From
Jeff King <peff@peff.net>
Date
Oct 2, 2009, 07:57 UTC
Message-ID
<20091002075724.GC27664@coredump.intra.peff.net>
In-Reply-To
<20091002073628.GA9444@localhost>
On Fri, Oct 02, 2009 at 09:36:28AM +0200, Clemens Buchacher wrote:
> Yes, that syntax looks reasonable. I expect this to be more involved, so I
> will rework the patch once we agree on whether or not we want it at all.
Thanks.
> Yes, that can happen. On the other hand, the "-ammend" typo actually did
> happen.

It did, but we are only guessing at how many people will be disrupted by the new rule. That being said...

Show 9 quoted lines
> And what I'm even more worried about are ambiguities like
> 
>   $ git commit -uno <path>
>   $ git commit -nou <path>
> 
> which are interpreted as one of
> 
>   $ git commit --untracked-files=no <path>
>   $ git commit --untracked-files --no-verify --only <path>

Making this clearer is a much more compelling argument to me. Though I thought it was customary (not just for git, but for other programs) that a short option that takes a parameter (even an optional one) would consume the rest of a short options string. Still, it is a potential source of confusion.

Show 5 quoted lines
> > On the other hand, the cuddled value already has some DWYM magic (it
> > recognizes -amend), so it is already a little bit unsafe to use
> 
> Well, an error message is a lot safer than executing something you did not
> intend.

It's also an error exit code, which can affect how a script performs (e.g., "git diff --exit-code"). But I don't have any real examples off the top of my head of how this could be particularly disastrous, so feel free to dismiss that as pushing too far into the hypothetical.

-Peff
Previous: Paolo BonziniNext: Johannes Schindelin
Message 18 of 21 in “how optparse can go horribly wrong”
  1. Shawn O. PearceSep 25, 2009
  2. Nicolas SebrechtSep 26, 2009
  3. Sverre RabbelierSep 26, 2009
  4. Shawn O. PearceSep 26, 2009
  5. Clemens BuchacherSep 28, 2009
  6. 1/2 do not mangle short options which take argumentsClemens Buchacher, Oct 1, 2009
  7. 2/2 allow mangling short options which take integer argumentsClemens Buchacher, Oct 1, 2009
  8. Johannes SchindelinOct 1, 2009
  9. Clemens BuchacherOct 2, 2009
  10. Jeff KingOct 2, 2009
  11. Clemens BuchacherOct 2, 2009
  12. Johannes SchindelinOct 2, 2009
  13. Clemens BuchacherOct 3, 2009
  14. Johannes SchindelinOct 1, 2009
  15. Jeff KingOct 2, 2009
  16. Clemens BuchacherOct 2, 2009
  17. Paolo BonziniOct 2, 2009
  18. Jeff KingOct 2, 2009
  19. Johannes SchindelinOct 2, 2009
  20. Jeff KingOct 2, 2009
  21. Johannes SchindelinOct 2, 2009

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.