mirror of
https://github.com/git/git.git
synced 2024-12-12 03:14:11 +08:00
Merge branch 'jk/end-of-options' into maint-2.43
"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:
commit
19fa15fb2d
@ -929,13 +929,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"))
|
||||
|
@ -616,4 +616,12 @@ test_expect_success 'reset --mixed sets up work tree' '
|
||||
test_must_be_empty actual
|
||||
'
|
||||
|
||||
test_expect_success 'reset handles --end-of-options' '
|
||||
git update-ref refs/heads/--foo HEAD^ &&
|
||||
git log -1 --format=%s refs/heads/--foo >expect &&
|
||||
git reset --hard --end-of-options --foo &&
|
||||
git log -1 --format=%s HEAD >actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -791,4 +791,14 @@ test_expect_success 'fast-export --first-parent outputs all revisions output by
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'fast-export handles --end-of-options' '
|
||||
git update-ref refs/heads/nodash HEAD &&
|
||||
git update-ref refs/heads/--dashes HEAD &&
|
||||
git fast-export --end-of-options nodash >expect &&
|
||||
git fast-export --end-of-options --dashes >actual.raw &&
|
||||
# fix up lines which mention the ref for comparison
|
||||
sed s/--dashes/nodash/ <actual.raw >actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_done
|
||||
|
Loading…
Reference in New Issue
Block a user