Merge branch 'ow/rev-parse-parseopt-fix'
The parser in the script interface to parse-options in "git rev-parse" has been updated to diagnose a bogus input correctly. * ow/rev-parse-parseopt-fix: rev-parse --parseopt: detect missing opt-spec
This commit is contained in:
commit
de1fee2f1e
@ -479,6 +479,9 @@ static int cmd_parseopt(int argc, const char **argv, const char *prefix)
|
|||||||
if (!s)
|
if (!s)
|
||||||
s = help;
|
s = help;
|
||||||
|
|
||||||
|
if (s == sb.buf)
|
||||||
|
die(_("missing opt-spec before option flags"));
|
||||||
|
|
||||||
if (s - sb.buf == 1) /* short option only */
|
if (s - sb.buf == 1) /* short option only */
|
||||||
o->short_name = *sb.buf;
|
o->short_name = *sb.buf;
|
||||||
else if (sb.buf[1] != ',') /* long option only */
|
else if (sb.buf[1] != ',') /* long option only */
|
||||||
|
@ -306,6 +306,13 @@ test_expect_success 'test --parseopt help output: "wrapped" options normal "or:"
|
|||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'test --parseopt invalid opt-spec' '
|
||||||
|
test_write_lines x -- "=, x" >spec &&
|
||||||
|
echo "fatal: missing opt-spec before option flags" >expect &&
|
||||||
|
test_must_fail git rev-parse --parseopt -- >out <spec 2>err &&
|
||||||
|
test_cmp expect err
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'test --parseopt help output: multi-line blurb after empty line' '
|
test_expect_success 'test --parseopt help output: multi-line blurb after empty line' '
|
||||||
sed -e "s/^|//" >spec <<-\EOF &&
|
sed -e "s/^|//" >spec <<-\EOF &&
|
||||||
|cmd [--some-option]
|
|cmd [--some-option]
|
||||||
|
Loading…
Reference in New Issue
Block a user