Skip to content

Commit 878bd80

Browse files
committed
Merge branch 'maint-1.6.4' into maint
* maint-1.6.4: rev-parse: fix --parse-opt --keep-dashdash --stop-at-non-option
2 parents 8e99859 + 2998138 commit 878bd80

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

builtin/rev-parse.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,8 @@ static int cmd_parseopt(int argc, const char **argv, const char *prefix)
407407
ALLOC_GROW(opts, onb + 1, osz);
408408
memset(opts + onb, 0, sizeof(opts[onb]));
409409
argc = parse_options(argc, argv, prefix, opts, usage,
410-
keep_dashdash ? PARSE_OPT_KEEP_DASHDASH : 0 |
411-
stop_at_non_option ? PARSE_OPT_STOP_AT_NON_OPTION : 0);
410+
(keep_dashdash ? PARSE_OPT_KEEP_DASHDASH : 0) |
411+
(stop_at_non_option ? PARSE_OPT_STOP_AT_NON_OPTION : 0));
412412

413413
strbuf_addf(&parsed, " --");
414414
sq_quote_argv(&parsed, argv, 0);

t/t1502-rev-parse-parseopt.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,22 @@ test_expect_success 'test --parseopt --keep-dashdash' '
7979
test_cmp expect output
8080
'
8181

82+
cat >expect <<EOF
83+
set -- --foo -- '--' 'arg' '--spam=ham'
84+
EOF
85+
86+
test_expect_success 'test --parseopt --keep-dashdash --stop-at-non-option with --' '
87+
git rev-parse --parseopt --keep-dashdash --stop-at-non-option -- --foo -- arg --spam=ham <optionspec >output &&
88+
test_cmp expect output
89+
'
90+
91+
cat > expect <<EOF
92+
set -- --foo -- 'arg' '--spam=ham'
93+
EOF
94+
95+
test_expect_success 'test --parseopt --keep-dashdash --stop-at-non-option without --' '
96+
git rev-parse --parseopt --keep-dashdash --stop-at-non-option -- --foo arg --spam=ham <optionspec >output &&
97+
test_cmp expect output
98+
'
99+
82100
test_done

0 commit comments

Comments
 (0)