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

Re: [PATCH] Port builtin-add.c to use the new option parser.

From
Pierre Habouzit <madcoder@debian.org>
Date
Oct 13, 2007, 15:03 UTC
Message-ID
<20071013150306.GH7110@artemis.corp>
In-Reply-To
<Pine.LNX.4.64.0710131544030.25221@racer.site>
On Sat, Oct 13, 2007 at 02:47:20PM +0000, Johannes Schindelin wrote:
Show 19 quoted lines
> Hi,
> 
> On Sat, 13 Oct 2007, Pierre Habouzit wrote:
> 
> > +static struct option builtin_add_options[] = {
> > +	OPT_BOOLEAN('i', "interactive", &add_interactive, "interactive picking"),
> > +	OPT_BOOLEAN('n', NULL, &show_only, "dry-run"),
> > +	OPT_BOOLEAN('f', NULL, &ignored_too, "allow adding otherwise ignored files"),
> > +	OPT_BOOLEAN('v', NULL, &verbose, "be verbose"),
> > +	OPT_BOOLEAN('u', NULL, &take_worktree_changes, "update only files that git already knows about"),
> > +	OPT_BOOLEAN( 0 , "refresh", &refresh_only, "don't add, only refresh stat() informations in the index"),
> > +};
> 
> I see you terminate the list by a ",".  How does this play with the option 
> parser?
> 
> Thinking about this more, I am reverting my stance on the ARRAY_SIZE() 
> issue.  I think if you introduce a "OPTION_NONE = 0" in the enum, then 
> this single last comma should be enough.
  adding a trailing comma does not add a NULL after that, it's ignored,
you're confused.
    ┌─(17:00)────
    └[artemis] cat a.c
    #include <stdio.h>
      int main(void) {
	const char * const arr[] = { "1", "2", };
	printf("%d\n", sizeof(arr) / sizeof(arr[0]));
	return 0;
    };
    ┌─(17:00)────
    └[artemis] ./a
    2
  Very few compilers do not grok trailing commas, I always put them
because it avoids spurious diffs for nothing, and that you can reorder
lines easily too.
  Note that I don't really like using ARRAY_SIZE either, I kept it that
way, but my taste would rather be to have an "empty" option, and
explicitely mark the end of the array.
-- 
·O·  Pierre Habouzit
··O                                                madcoder@debian.org
OOO                                                http://www.madism.org
Previous: Johannes SchindelinNext: Alex Riesen
Message 32 of 42 in “[RFC] CLI option parsing and usage generation for porcelains”
  1. Pierre HabouzitOct 13, 2007
  2. Wincent ColaiutaOct 13, 2007
  3. Eric WongOct 14, 2007
  4. Pierre HabouzitOct 14, 2007
  5. parse-options: Allow abbreviated options when unambiguousJohannes Schindelin, Oct 14, 2007
  6. Johannes SchindelinOct 14, 2007
  7. Pierre HabouzitOct 14, 2007
  8. Eric WongOct 14, 2007
  9. Johannes SchindelinOct 14, 2007
  10. Eric WongOct 14, 2007
  11. git-svn and submodules, was Re: [PATCH] parse-options: Allow abbreviated options when unambiguousJohannes Schindelin, Oct 14, 2007
  12. Benoit SIGOUREOct 15, 2007
  13. Andreas EricssonOct 15, 2007
  14. Benoit SIGOUREOct 15, 2007
  15. David KastrupOct 15, 2007
  16. Benoit SIGOUREOct 15, 2007
  17. Andreas EricssonOct 15, 2007
  18. Karl HasselströmOct 15, 2007
  19. .gitignore and svn:ignore [WAS: git-svn and submodules]Chris Shoemaker, Oct 15, 2007
  20. Eric WongOct 16, 2007
  21. Karl HasselströmOct 16, 2007
  22. Chris ShoemakerOct 16, 2007
  23. Linus TorvaldsOct 15, 2007
  24. Performance issue with excludes (was: Re: git-svn and submodules)Benoit SIGOURE, Oct 15, 2007
  25. Linus TorvaldsOct 15, 2007
  26. Benoit SIGOUREOct 15, 2007
  27. Linus TorvaldsOct 15, 2007
  28. Benoit SIGOUREOct 15, 2007
  29. Johannes SchindelinOct 13, 2007
  30. Pierre HabouzitOct 13, 2007
  31. Johannes SchindelinOct 13, 2007
  32. Pierre HabouzitOct 13, 2007
  33. Alex RiesenOct 13, 2007
  34. Pierre HabouzitOct 13, 2007
  35. Alex RiesenOct 13, 2007
  36. Pierre HabouzitOct 13, 2007
  37. Alex RiesenOct 13, 2007
  38. Pierre HabouzitOct 14, 2007
  39. Simplify usage string printingJonas Fonseca, Oct 14, 2007
  40. Pierre HabouzitOct 14, 2007
  41. Update manpages to reflect new short and long option aliasesJonas Fonseca, Oct 14, 2007
  42. Pierre HabouzitOct 14, 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.