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

Re: [RFH] convert shortlog to use parse_options

From
Pierre Habouzit <madcoder@debian.org>
Date
Dec 13, 2007, 09:06 UTC
Message-ID
<20071213090604.GA12398@artemis.madism.org>
In-Reply-To
<20071213055226.GA3636@coredump.intra.peff.net>
On Thu, Dec 13, 2007 at 05:52:26AM +0000, Jeff King wrote:
Show 13 quoted lines
> Pierre,
> 
> I am converting shortlog to use parse_options, but I have hit a behavior
> I can't seem to represent.
> 
> The "-w" option has an optional argument, and we used to accept only
> "-w" or "-wX,Y,Z". However, parse_options allows "-w X,Y,Z".
> 
> This means that "-w HEAD" used to mean "turn on wrapping
> with default parameters, look at HEAD" and now translates to
> "-w with parameter HEAD".
> 
> Is there a way to do this currently, or can we add an option flag?

No we can't. And I believe that such a thing is definitely bad practice :/ So if you really need to, we will have to add some PARSE_OPT_STICKARG or sth alike that would check that the argument was "sticked" to the option either with `-wA,B,C` or `--long-opt=A,B,C` depending on the fact that an option is short or long.

Though: `git shortlog -w -- HEAD` will work properly because option
arguments don't take the next token as an argument thing if it starts
with a dash.

Though note that you can't migrate things that use init_revisions and so on to parseoptions yet, because revisions also have dashed tokens (--not e.g.) and that the first run of parse_options will just hate it and fail. Maybe we can do parse_options work in multiple passes though, but that would require a quite extensive rethought of the module, the introduction of a parseopt context to be freed after the last pass (because we will have a lot of small allocation stuff going on). I'll try to see what I can do in that direction.

For that we must migrate diff and revisions option parser as big macros (I started[0] it but didn't had the time to complete it yet, and it's quite a huge task, because there is no incremental upgrade path here, and there are commands using both diff and revisions options so we must migrate both at once) and use aggregated parseoptions specifiers.

  [0] http://git.madism.org/?p=git.git;a=commitdiff;h=059cfb6d4cfbdff68d81577d00c9dbce6fed443e
-- 
·O·  Pierre Habouzit
··O                                                madcoder@debian.org
OOO                                                http://www.madism.org
Previous: Jeff KingNext: Jeff King
Message 2 of 51 in “[RFH] convert shortlog to use parse_options”
  1. Jeff KingDec 13, 2007
  2. Pierre HabouzitDec 13, 2007
  3. Jeff KingDec 13, 2007
  4. Pierre HabouzitDec 13, 2007
  5. 1/2 parseopt: Enforce the use of the sticked form for optional arguments.Pierre Habouzit, Dec 13, 2007
  6. 2/2 parseopt: Add a gitcli(5) man page.Pierre Habouzit, Dec 13, 2007
  7. Wincent ColaiutaDec 13, 2007
  8. Pierre HabouzitDec 13, 2007
  9. (squashme) gitcli documentation fixupsJunio C Hamano, Dec 17, 2007
  10. Pierre HabouzitDec 17, 2007
  11. Pierre HabouzitDec 17, 2007
  12. builtin-tag: fix fallouts from recent parsopt restriction.Junio C Hamano, Dec 17, 2007
  13. Pierre HabouzitDec 17, 2007
  14. Junio C HamanoDec 17, 2007
  15. Pierre HabouzitDec 17, 2007
  16. Junio C HamanoDec 17, 2007
  17. Pierre HabouzitDec 17, 2007
  18. Junio C HamanoDec 17, 2007
  19. Jeff KingDec 17, 2007
  20. Pierre HabouzitDec 17, 2007
  21. Pierre HabouzitDec 17, 2007
  22. Jeff KingDec 17, 2007
  23. Pierre HabouzitDec 17, 2007
  24. Junio C HamanoDec 17, 2007
  25. Jeff KingDec 17, 2007
  26. Pierre HabouzitDec 17, 2007
  27. Pierre HabouzitDec 17, 2007
  28. Junio C HamanoDec 17, 2007
  29. Pierre HabouzitDec 17, 2007
  30. Pierre HabouzitDec 17, 2007
  31. Junio C HamanoDec 13, 2007
  32. Pierre HabouzitDec 13, 2007
  33. Pierre HabouzitDec 13, 2007
  34. Junio C HamanoDec 13, 2007
  35. Kristian HøgsbergDec 13, 2007
  36. Kristian HøgsbergDec 13, 2007
  37. Junio C HamanoDec 13, 2007
  38. Jeff KingDec 14, 2007
  39. Junio C HamanoDec 14, 2007
  40. Andreas EricssonDec 14, 2007
  41. Pierre HabouzitDec 14, 2007
  42. Junio C HamanoDec 14, 2007
  43. Pierre HabouzitDec 15, 2007
  44. Junio C HamanoDec 17, 2007
  45. Andreas EricssonDec 17, 2007
  46. Junio C HamanoDec 17, 2007
  47. Andreas EricssonDec 17, 2007
  48. Kristian HøgsbergDec 17, 2007
  49. Junio C HamanoDec 13, 2007
  50. Pierre HabouzitDec 13, 2007
  51. Pierre HabouzitDec 13, 2007

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.