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 "--"
This commit is contained in:
Junio C Hamano
2023-12-20 10:14:54 -08:00
3 changed files with 25 additions and 2 deletions

View File

@@ -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"))