summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0d4ede9)
raw | patch | inline | side by side (parent: 0d4ede9)
author | Olivier Marin <dkr@freesurf.fr> | |
Mon, 21 Jul 2008 18:30:36 +0000 (20:30 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 22 Jul 2008 04:20:04 +0000 (21:20 -0700) |
p->argc represent the number of arguments that have not been parsed yet,
_including_ the one we are currently parsing. If it is not greater than
one then there is no more argument.
Signed-off-by: Olivier Marin <dkr@freesurf.fr>
Acked-by: Pierre Habouzit <madcoder@debian.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
_including_ the one we are currently parsing. If it is not greater than
one then there is no more argument.
Signed-off-by: Olivier Marin <dkr@freesurf.fr>
Acked-by: Pierre Habouzit <madcoder@debian.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
parse-options.c | patch | blob | history | |
t/t0040-parse-options.sh | patch | blob | history |
diff --git a/parse-options.c b/parse-options.c
index 987b0157192b9fe4c7451d94f5948bdbd7f524bb..71a7acf4e22bd12c0919f277410d6ec52dd5efc8 100644 (file)
--- a/parse-options.c
+++ b/parse-options.c
p->opt = NULL;
} else if (p->argc == 1 && (opt->flags & PARSE_OPT_LASTARG_DEFAULT)) {
*arg = (const char *)opt->defval;
- } else if (p->argc) {
+ } else if (p->argc > 1) {
p->argc--;
*arg = *++p->argv;
} else
index 6309aed4511738b2f68e16974a5a5ceadf2617e5..03dbe00102626e05c37e45d8a3b1364b99644942 100755 (executable)
--- a/t/t0040-parse-options.sh
+++ b/t/t0040-parse-options.sh
test_cmp expect output
'
+test_expect_success 'missing required value' '
+ test-parse-options -s;
+ test $? = 129 &&
+ test-parse-options --string;
+ test $? = 129
+'
+
cat > expect << EOF
boolean: 1
integer: 13