Skip to content

Commit 2e13ed4

Browse files
committed
Merge branch 'jk/end-of-options' into jc/sparse-checkout-set-add-end-of-options
* jk/end-of-options: parse-options: decouple "--end-of-options" and "--"
2 parents 564d025 + 9385174 commit 2e13ed4

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

parse-options.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -929,13 +929,18 @@ enum parse_opt_result parse_options_step(struct parse_opt_ctx_t *ctx,
929929
continue;
930930
}
931931

932-
if (!arg[2] /* "--" */ ||
933-
!strcmp(arg + 2, "end-of-options")) {
932+
if (!arg[2] /* "--" */) {
934933
if (!(ctx->flags & PARSE_OPT_KEEP_DASHDASH)) {
935934
ctx->argc--;
936935
ctx->argv++;
937936
}
938937
break;
938+
} else if (!strcmp(arg + 2, "end-of-options")) {
939+
if (!(ctx->flags & PARSE_OPT_KEEP_UNKNOWN_OPT)) {
940+
ctx->argc--;
941+
ctx->argv++;
942+
}
943+
break;
939944
}
940945

941946
if (internal_help && !strcmp(arg + 2, "help-all"))

t/t7102-reset.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,4 +616,12 @@ test_expect_success 'reset --mixed sets up work tree' '
616616
test_must_be_empty actual
617617
'
618618

619+
test_expect_success 'reset handles --end-of-options' '
620+
git update-ref refs/heads/--foo HEAD^ &&
621+
git log -1 --format=%s refs/heads/--foo >expect &&
622+
git reset --hard --end-of-options --foo &&
623+
git log -1 --format=%s HEAD >actual &&
624+
test_cmp expect actual
625+
'
626+
619627
test_done

t/t9350-fast-export.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,4 +791,14 @@ test_expect_success 'fast-export --first-parent outputs all revisions output by
791791
)
792792
'
793793

794+
test_expect_success 'fast-export handles --end-of-options' '
795+
git update-ref refs/heads/nodash HEAD &&
796+
git update-ref refs/heads/--dashes HEAD &&
797+
git fast-export --end-of-options nodash >expect &&
798+
git fast-export --end-of-options --dashes >actual.raw &&
799+
# fix up lines which mention the ref for comparison
800+
sed s/--dashes/nodash/ <actual.raw >actual &&
801+
test_cmp expect actual
802+
'
803+
794804
test_done

0 commit comments

Comments
 (0)