summaryrefslogtreecommitdiffstats
path: root/parse-options.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2023-12-20 19:14:54 +0100
committerJunio C Hamano <gitster@pobox.com>2023-12-20 19:14:54 +0100
commit9eec6a1c5fc03e5f01f200bdb28f1dc6b8e9f03e (patch)
treeb8551bbca8f950eeb9cf76de8b73cb9321bb072e /parse-options.c
parentMerge branch 'rs/incompatible-options-messages' (diff)
parentparse-options: decouple "--end-of-options" and "--" (diff)
downloadgit-9eec6a1c5fc03e5f01f200bdb28f1dc6b8e9f03e.tar.xz
git-9eec6a1c5fc03e5f01f200bdb28f1dc6b8e9f03e.zip
Merge branch 'jk/end-of-options'
"git $cmd --end-of-options --rev -- --path" for some $cmd failed to interpret "--rev" as a rev, and "--path" as a path. This was fixed for many programs like "reset" and "checkout". * jk/end-of-options: parse-options: decouple "--end-of-options" and "--"
Diffstat (limited to 'parse-options.c')
-rw-r--r--parse-options.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/parse-options.c b/parse-options.c
index c3955847f4..65fab5bb9d 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -930,13 +930,18 @@ enum parse_opt_result parse_options_step(struct parse_opt_ctx_t *ctx,
continue;
}
- if (!arg[2] /* "--" */ ||
- !strcmp(arg + 2, "end-of-options")) {
+ if (!arg[2] /* "--" */) {
if (!(ctx->flags & PARSE_OPT_KEEP_DASHDASH)) {
ctx->argc--;
ctx->argv++;
}
break;
+ } else if (!strcmp(arg + 2, "end-of-options")) {
+ if (!(ctx->flags & PARSE_OPT_KEEP_UNKNOWN_OPT)) {
+ ctx->argc--;
+ ctx->argv++;
+ }
+ break;
}
if (internal_help && !strcmp(arg + 2, "help-all"))