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>
This commit is contained in:
Pierre Habouzit 2007-12-21 11:41:41 +01:00 committed by Junio C Hamano
parent 5e2de4f9bb
commit c43a24834a
2 changed files with 51 additions and 51 deletions

View File

@ -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;
}