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

Re: [PATCH 1/2] parse_options: Add flag to prevent errors for further processing

From
Shawn Bohrer <shawn.bohrer@gmail.com>
Date
Jun 19, 2008, 14:25 UTC
Message-ID
<20080619142527.GA8429@mediacenter>
In-Reply-To
<7v8wx2zibp.fsf@gitster.siamese.dyndns.org>
On Wed, Jun 18, 2008 at 11:52:42AM -0700, Junio C Hamano wrote:
Show 29 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > On Tue, 17 Jun 2008, Junio C Hamano wrote:
> >
> >> Jeff King <peff@peff.net> writes:
> >> 
> >> > I think the only right way to accomplish this is to convert the revision
> >> > and diff parameters into a parseopt-understandable format.
> >> 
> >> Not necessarily.  You could structure individual option parsers like how 
> >> diff option parsers are done.  You iterate over argv[], feed diff option 
> >> parser the current index into argv[] and ask if it is an option diff 
> >> understands, have diff eat the option (and possibly its parameter) to 
> >> advance the index, or allow diff option to say "I do not understand 
> >> this", and then handle it yourself or hand it to other parsers.
> >
> > AFAIR Pierre tried a few ways, and settled with a macro to introduce the 
> > diff options into a caller's options.
> >
> > IOW it would look something like this:
> >
> > static struct option builtin_what_options[] = {
> > 	[... options specific to this command ...]
> > 	DIFF__OPT(&diff_options)
> > };
> 
> I think that is the more painful approach Jeff mentioned, and my comment
> was to show that it is not the only way.
> 

It seems to me that you could implement Jeff's PARSE_OPT_STOP_AT_UNKNOWN, and then if multiple option parsers are needed you would simply loop over parse_options for each of the commands, waiting for argc to stop changing. Of course Jeff's flag would also need to stop parse_options from eating the first argument. Is this sort of what you are suggesting Junio?

-- Shawn

Previous: Junio C HamanoNext: Johannes Schindelin
Message 10 of 17 in “[RFC] convert shortlog to use parse_options”
  1. Shawn BohrerJun 18, 2008
  2. 1/2 parse_options: Add flag to prevent errors for further processingShawn Bohrer, Jun 18, 2008
  3. 2/2 git shortlog: Modify to use parse_optionsShawn Bohrer, Jun 18, 2008
  4. Junio C HamanoJun 18, 2008
  5. Jeff KingJun 18, 2008
  6. Jeff KingJun 18, 2008
  7. Junio C HamanoJun 18, 2008
  8. Johannes SchindelinJun 18, 2008
  9. Junio C HamanoJun 18, 2008
  10. Shawn BohrerJun 19, 2008
  11. Johannes SchindelinJun 22, 2008
  12. Junio C HamanoJun 23, 2008
  13. Jeff KingJun 23, 2008
  14. Junio C HamanoJun 23, 2008
  15. Johannes SchindelinJun 23, 2008
  16. Pierre HabouzitJun 22, 2008
  17. Junio C HamanoJun 23, 2008

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.