aboutsummaryrefslogtreecommitdiff
path: root/parse-options.c
diff options
context:
space:
mode:
authorPierre Habouzit <madcoder@debian.org>2007-12-21 11:41:41 +0100
committerJunio C Hamano <gitster@pobox.com>2007-12-22 10:26:08 -0800
commitc43a24834a9babd3ddd9c27ccc81174c2cb36859 (patch)
tree7b15beb51e3bb2c2ba43cfb64e01522629e34a69 /parse-options.c
parent5e2de4f9bb666186e4f8ba0c9c5db640fd7a04bd (diff)
downloadgit-c43a24834a9babd3ddd9c27ccc81174c2cb36859.tar.gz
git-c43a24834a9babd3ddd9c27ccc81174c2cb36859.tar.xz
Force the sticked form for options with optional arguments.
This forbids "git tag -n <number> -l" we allowed earlier, so adjust t7004 while at it. Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Diffstat (limited to 'parse-options.c')
-rw-r--r--parse-options.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/parse-options.c b/parse-options.c
index e12b428c0..7a08a0c64 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -89,7 +89,7 @@ static int get_value(struct optparse_t *p,
*(const char **)opt->value = NULL;
return 0;
}
- if (opt->flags & PARSE_OPT_OPTARG && (!arg || *arg == '-')) {
+ if (opt->flags & PARSE_OPT_OPTARG && !p->opt) {
*(const char **)opt->value = (const char *)opt->defval;
return 0;
}
@@ -103,7 +103,7 @@ static int get_value(struct optparse_t *p,
return (*opt->callback)(opt, NULL, 1);
if (opt->flags & PARSE_OPT_NOARG)
return (*opt->callback)(opt, NULL, 0);
- if (opt->flags & PARSE_OPT_OPTARG && (!arg || *arg == '-'))
+ if (opt->flags & PARSE_OPT_OPTARG && !p->opt)
return (*opt->callback)(opt, NULL, 0);
if (!arg)
return opterror(opt, "requires a value", flags);
@@ -114,7 +114,7 @@ static int get_value(struct optparse_t *p,
*(int *)opt->value = 0;
return 0;
}
- if (opt->flags & PARSE_OPT_OPTARG && (!arg || !isdigit(*arg))) {
+ if (opt->flags & PARSE_OPT_OPTARG && !p->opt) {
*(int *)opt->value = opt->defval;
return 0;
}