From: Stephen Boyd <bebarino@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: "git list" <git@vger.kernel.org>,
"René Scharfe" <rene.scharfe@lsrfire.ath.cx>,
"Pierre Habouzit" <madcoder@madism.org>
Subject: [PATCH] show-branch: don't use LASTARG_DEFAULT with OPTARG
Date: Sun, 7 Jun 2009 16:39:15 -0700 [thread overview]
Message-ID: <1244417955-21226-1-git-send-email-bebarino@gmail.com> (raw)
In-Reply-To: <4A2ACE32.8080504@gmail.com>
5734365 (show-branch: migrate to parse-options API 2009-05-21)
incorrectly set the --more option's flags to be
PARSE_OPT_LASTARG_DEFAULT and PARSE_OPT_OPTARG. These two flags
shouldn't be used together. An option taking a default should just set
the default value desired and parse options will take care of the rest.
Update the header comment to better convey this information.
Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---
builtin-show-branch.c | 3 +--
parse-options.h | 7 +++++--
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/builtin-show-branch.c b/builtin-show-branch.c
index 9433811..01bea3b 100644
--- a/builtin-show-branch.c
+++ b/builtin-show-branch.c
@@ -657,8 +657,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
"color '*!+-' corresponding to the branch"),
{ OPTION_INTEGER, 0, "more", &extra, "n",
"show <n> more commits after the common ancestor",
- PARSE_OPT_OPTARG | PARSE_OPT_LASTARG_DEFAULT,
- NULL, (intptr_t)1 },
+ PARSE_OPT_OPTARG, NULL, (intptr_t)1 },
OPT_SET_INT(0, "list", &extra, "synonym to more=-1", -1),
OPT_BOOLEAN(0, "no-name", &no_name, "suppress naming strings"),
OPT_BOOLEAN(0, "current", &with_current_branch,
diff --git a/parse-options.h b/parse-options.h
index b374ade..5653dba 100644
--- a/parse-options.h
+++ b/parse-options.h
@@ -71,8 +71,11 @@ typedef int parse_opt_cb(const struct option *, const char *arg, int unset);
* PARSE_OPT_NONEG: says that this option cannot be negated
* PARSE_OPT_HIDDEN: this option is skipped in the default usage, and
* shown only in the full usage.
- * PARSE_OPT_LASTARG_DEFAULT: if no argument is given, the default value
- * is used.
+ * PARSE_OPT_LASTARG_DEFAULT: says that this option will take the default
+ * value if no argument is given when the option
+ * is last on the command line. If the option is
+ * not last it will require an argument.
+ * Should not be used with PARSE_OPT_OPTARG.
* PARSE_OPT_NODASH: this option doesn't start with a dash.
* PARSE_OPT_LITERAL_ARGHELP: says that argh shouldn't be enclosed in brackets
* (i.e. '<argh>') in the help message.
--
1.6.3.2.202.g26c11
next prev parent reply other threads:[~2009-06-07 23:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-05 5:43 parse-options: ambiguous LASTARG_DEFAULT and OPTARG Stephen Boyd
2009-06-06 10:30 ` René Scharfe
2009-06-06 20:14 ` Stephen Boyd
2009-06-07 23:39 ` Stephen Boyd [this message]
2009-06-08 17:24 ` [PATCH] show-branch: don't use LASTARG_DEFAULT with OPTARG René Scharfe
2009-06-08 21:56 ` Junio C Hamano
2009-06-09 8:23 ` [PATCH] parse-options: add parse_options_check to validate option specs Pierre Habouzit
2009-06-12 19:31 ` Pierre Habouzit
2009-06-12 21:25 ` René Scharfe
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=1244417955-21226-1-git-send-email-bebarino@gmail.com \
--to=bebarino@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=madcoder@madism.org \
--cc=rene.scharfe@lsrfire.ath.cx \
/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).