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

Re: [PATCH v2 6/7] Documentation: put blame/log -L in sticked form

From
Thomas Rast <tr@thomasrast.ch>
Date
Oct 30, 2013, 18:59 UTC
Message-ID
<874n7ywpnd.fsf@thomasrast.ch>
In-Reply-To
<xmqqiowed6t3.fsf@gitster.dls.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 24 quoted lines
> Thomas Rast <tr@thomasrast.ch> writes:
>
>> Junio C Hamano <gitster@pobox.com> writes:
>>
>>> I agree that this patch may reduce confusion locally, but if we were
>>> to go in this direction, we should be consistent and enforce "stuck"
>>> form everywhere,
>>
>> Hmm.  Do you want to go there?
>
> Absolutely not ;-)
>
> But that unpleasant place would be the logical conclusion where this
> patch leads us to, I would have to say. I was hoping that there is
> an alternative solution to avoid that.
>
> For example, gitk's parseviewargs is very well aware of the options
> it supports, and it goes through the argument list one by one,
> acting on what option it is looking at. Couldn't it be extended to
> handle options with stuck and unstuck form?  After all, it has to
> know that "-L" and "-S" are supported options; it wouldn't be too
> much to ask for the parser to also know that "-L" eats the next
> token (i.e. pass the pair <"-L", next token> intact as two separate
> args to the underlying "log") while it can pass "-L?*" as is, no?

It's not quite that easy because gitk does two-stage processing, and the big switch you are discussing here is only the second one. The first one is git-rev-parse, and while it happens to know about '-n 1', it does not recognize any other unstuck option arguments. (I haven't stared too long, but I think git-rev-parse is important to distinguish revisions from paths.)

I actually burned some train time today looking into this, and the situation is much worse than I thought. There is absolutely no consistency in any dimension:

a) many commands use parse_options internally, where mandatory args can
   be stuck or unstuck, but optional args must be stuck
   a1) git branch --{contains,merged,no-merged} take a mandatory arg,
       except if they are last on the command line, in which case the
       option reverts to the default (HEAD).  Effectively this means the
       argument is half-optional but the spelling seen in the wild is
       usually unstuck.
   a2) git-rev-parse (at least) still handrolls its parsing, so no
       --default=HEAD
   a3) git-commit-tree does not understand any of its short options in
       stuck form (!)
b) the perl scripts mostly seem to be using Getopt::Long which handles
   things similarly, though I can't quote chapter&verse
   b1) just to prove a point: git-add--interactive.  I'm sure there's a
       user-facing exception somewhere too...
c) shell scripts mostly go through git-sh-setup, using parseopt
   internally
   c1) git-filter-branch
d) gitk doesn't do *un*stuck as explained above

On top of that, documentation is a wild mash of styles, sometimes even in the same manpage. For example, git-describe(1) tells the poor user about --candidates=<n> and four paragraphs further down about --match <pattern>.

So my short-term plan just became: document instead of fix; clean up manpages towards the stuck form for long options; have gitk only parse -Lstuck.

Medium term we can move gitk to a different option parser, resolving at least that inconsistency.

Longer term we can see about moving some more of the remaining craziness towards parseopt, getting consistency for free.

-- 
Thomas Rast
tr@thomasrast.ch
Previous: Junio C HamanoNext: Junio C Hamano
Message 29 of 42 in “gitk support for git log -L”
  1. 0/4 gitk support for git log -LThomas Rast, Jun 9, 2013
  2. 1/4 gitk: refactor per-line part of getblobdiffline and its supportThomas Rast, Jun 9, 2013
  3. 2/4 gitk: split out diff part in $commitinfoThomas Rast, Jun 9, 2013
  4. 3/4 gitk: support showing the gathered inline diffsThomas Rast, Jun 9, 2013
  5. 4/4 gitk: recognize -L optionThomas Rast, Jun 9, 2013
  6. Thomas RastJul 23, 2013
  7. Thomas RastJul 29, 2013
  8. Jens LehmannJul 29, 2013
  9. Thomas RastJul 31, 2013
  10. Paul MackerrasAug 18, 2013
  11. Thomas RastAug 19, 2013
  12. Junio C HamanoAug 19, 2013
  13. Thomas RastOct 13, 2013
  14. Jonathan NiederOct 14, 2013
  15. Documentation: revamp gitk(1)Thomas Rast, Oct 20, 2013
  16. 0/7 gitk -LThomas Rast, Oct 29, 2013
  17. 1/7 gitk: support -G option from the command lineThomas Rast, Oct 29, 2013
  18. Junio C HamanoOct 30, 2013
  19. Thomas RastOct 30, 2013
  20. Junio C HamanoOct 30, 2013
  21. 2/7 gitk: refactor per-line part of getblobdiffline and its supportThomas Rast, Oct 29, 2013
  22. 3/7 gitk: split out diff part in $commitinfoThomas Rast, Oct 29, 2013
  23. 4/7 gitk: support showing the gathered inline diffsThomas Rast, Oct 29, 2013
  24. 5/7 gitk: recognize -L optionThomas Rast, Oct 29, 2013
  25. 6/7 Documentation: put blame/log -L in sticked formThomas Rast, Oct 29, 2013
  26. Junio C HamanoOct 30, 2013
  27. Thomas RastOct 30, 2013
  28. Junio C HamanoOct 30, 2013
  29. Thomas RastOct 30, 2013
  30. Junio C HamanoOct 30, 2013
  31. 0/5 gitk -LThomas Rast, Nov 16, 2013
  32. 1/5 gitk: support -G option from the command lineThomas Rast, Nov 16, 2013
  33. 2/5 gitk: refactor per-line part of getblobdiffline and its supportThomas Rast, Nov 16, 2013
  34. 3/5 gitk: split out diff part in $commitinfoThomas Rast, Nov 16, 2013
  35. 4/5 gitk: support showing the gathered inline diffsThomas Rast, Nov 16, 2013
  36. 5/5 gitk: recognize -L optionThomas Rast, Nov 16, 2013
  37. Paul MackerrasDec 1, 2013
  38. 0/3 Documentation: stuck arguments and gitk log -LThomas Rast, Nov 16, 2013
  39. 1/3 commit-tree: use prefixcmp instead of memcmp(..., N)Thomas Rast, Nov 16, 2013
  40. 2/3 Documentation: convert to --option=arg form where possibleThomas Rast, Nov 16, 2013
  41. 3/3 Documentation/gitk: document -L optionThomas Rast, Nov 16, 2013
  42. 7/7 Documentation/gitk: document -L optionThomas Rast, Oct 29, 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.