aboutsummaryrefslogtreecommitdiff
path: root/parse-options.c
diff options
context:
space:
mode:
authorJonathan Nieder <jrnieder@gmail.com>2010-12-01 17:32:55 -0600
committerJunio C Hamano <gitster@pobox.com>2010-12-07 14:19:32 -0800
commit979240fee32628c317998f3c3fe2619cf01decc2 (patch)
tree7bc371cf6b37aa152da3fa48f34cb1de435a711d /parse-options.c
parentb0b3a8b666ac9bcab93c9b05ca7de918d7fa18bc (diff)
downloadgit-979240fee32628c317998f3c3fe2619cf01decc2.tar.gz
git-979240fee32628c317998f3c3fe2619cf01decc2.tar.xz
parse-options: make resuming easier after PARSE_OPT_STOP_AT_NON_OPTION
Introduce a PARSE_OPT_NON_OPTION state, so parse_option_step() callers can easily distinguish between non-options and other reasons for option parsing termination (like "--"). Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'parse-options.c')
-rw-r--r--parse-options.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/parse-options.c b/parse-options.c
index cd9268691..42b51ef14 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -373,7 +373,7 @@ int parse_options_step(struct parse_opt_ctx_t *ctx,
if (parse_nodash_opt(ctx, arg, options) == 0)
continue;
if (ctx->flags & PARSE_OPT_STOP_AT_NON_OPTION)
- break;
+ return PARSE_OPT_NON_OPTION;
ctx->out[ctx->cpidx++] = ctx->argv[0];
continue;
}
@@ -455,6 +455,7 @@ int parse_options(int argc, const char **argv, const char *prefix,
switch (parse_options_step(&ctx, options, usagestr)) {
case PARSE_OPT_HELP:
exit(129);
+ case PARSE_OPT_NON_OPTION:
case PARSE_OPT_DONE:
break;
default: /* PARSE_OPT_UNKNOWN */