From: Pierre Habouzit <madcoder@debian.org>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: git@vger.kernel.org, "Junio C Hamano" <gitster@pobox.com>,
"Kristian Høgsberg" <krh@redhat.com>
Subject: Re: [PATCH] Port builtin-add.c to use the new option parser.
Date: Sat, 13 Oct 2007 17:03:06 +0200 [thread overview]
Message-ID: <20071013150306.GH7110@artemis.corp> (raw)
In-Reply-To: <Pine.LNX.4.64.0710131544030.25221@racer.site>
[-- Attachment #1: Type: text/plain, Size: 1873 bytes --]
On Sat, Oct 13, 2007 at 02:47:20PM +0000, Johannes Schindelin wrote:
> 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
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
next prev parent reply other threads:[~2007-10-13 15:03 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-13 13:29 [RFC] CLI option parsing and usage generation for porcelains Pierre Habouzit
2007-10-13 14:53 ` Wincent Colaiuta
2007-10-14 9:18 ` Eric Wong
2007-10-14 9:57 ` Pierre Habouzit
2007-10-14 16:54 ` [PATCH] parse-options: Allow abbreviated options when unambiguous Johannes Schindelin
2007-10-14 18:02 ` Johannes Schindelin
2007-10-14 18:08 ` Pierre Habouzit
2007-10-14 21:01 ` Eric Wong
2007-10-14 22:12 ` Johannes Schindelin
2007-10-14 22:49 ` Eric Wong
2007-10-14 22:59 ` git-svn and submodules, was " Johannes Schindelin
2007-10-15 7:07 ` git-svn and submodules Benoit SIGOURE
2007-10-15 10:00 ` Andreas Ericsson
2007-10-15 10:51 ` Benoit SIGOURE
2007-10-15 10:14 ` David Kastrup
2007-10-15 10:53 ` Benoit SIGOURE
2007-10-15 16:27 ` Andreas Ericsson
2007-10-15 14:45 ` Karl Hasselström
2007-10-15 15:14 ` .gitignore and svn:ignore [WAS: git-svn and submodules] Chris Shoemaker
2007-10-16 7:58 ` Eric Wong
2007-10-16 9:43 ` Karl Hasselström
2007-10-16 13:05 ` Chris Shoemaker
2007-10-15 15:53 ` git-svn and submodules Linus Torvalds
2007-10-15 16:17 ` Performance issue with excludes (was: Re: git-svn and submodules) Benoit SIGOURE
2007-10-15 16:34 ` Linus Torvalds
2007-10-15 16:51 ` Benoit SIGOURE
2007-10-15 17:10 ` Linus Torvalds
2007-10-15 17:38 ` Benoit SIGOURE
[not found] ` <1192282153-26684-2-git-send-email-madcoder@debian.org>
2007-10-13 14:39 ` [PATCH] Add a simple option parser Johannes Schindelin
2007-10-13 14:58 ` Pierre Habouzit
[not found] ` <1192282153-26684-3-git-send-email-madcoder@debian.org>
2007-10-13 14:47 ` [PATCH] Port builtin-add.c to use the new " Johannes Schindelin
2007-10-13 15:03 ` Pierre Habouzit [this message]
2007-10-13 19:22 ` Alex Riesen
2007-10-13 20:27 ` Pierre Habouzit
[not found] ` <1192282153-26684-4-git-send-email-madcoder@debian.org>
[not found] ` <1192282153-26684-5-git-send-email-madcoder@debian.org>
[not found] ` <1192282153-26684-6-git-send-email-madcoder@debian.org>
[not found] ` <1192282153-26684-7-git-send-email-madcoder@debian.org>
[not found] ` <1192282153-26684-8-git-send-email-madcoder@debian.org>
[not found] ` <1192282153-26684-9-git-send-email-madcoder@debian.org>
[not found] ` <1192282153-26684-10-git-send-email-madcoder@debian.org>
2007-10-14 14:01 ` [PATCH] Simplify usage string printing Jonas Fonseca
2007-10-14 16:26 ` Pierre Habouzit
2007-10-13 19:16 ` [PATCH] Add a simple option parser Alex Riesen
2007-10-13 20:54 ` Pierre Habouzit
2007-10-13 22:14 ` Alex Riesen
2007-10-14 7:02 ` Pierre Habouzit
2007-10-14 14:10 ` [PATCH] Update manpages to reflect new short and long option aliases Jonas Fonseca
2007-10-14 16:26 ` Pierre Habouzit
-- strict thread matches above, loose matches on Subject: below --
2007-10-03 21:45 [PATCH] Add a simple option parser Kristian Høgsberg
2007-10-03 21:45 ` [PATCH] Port builtin-add.c to use the new " Kristian Høgsberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071013150306.GH7110@artemis.corp \
--to=madcoder@debian.org \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=krh@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).