rev-parse parseopt: do not search help text for flag chars
authorBrandon Casey <redacted>
Sun, 17 Sep 2017 22:28:15 +0000 (15:28 -0700)
committerJunio C Hamano <redacted>
Tue, 19 Sep 2017 03:13:07 +0000 (12:13 +0900)
commit28a8d0f77a27646dcbd87f0718b79501113cb82c
treec7edd6b28bff8ddcadeb2eda0af8be74000f44c2
parentf221861e490d2c57b960cf86c5bc37279a3ebc2b
rev-parse parseopt: do not search help text for flag chars

When searching for flag characters in the option spec, we should ensure
the search stays within the bounds of the option spec and does not enter
the help text portion of the spec.  So when we find the boundary white
space marking the start of the help text, let's mark it with a nul
character.  Then when we search for flag characters starting from the
beginning of the string we'll stop at the nul and won't enter the help
text.

Now, the following option spec:

    exclame this does something!

will produce this 'set' expression when --exclame is specified:

    set -- --exclame --

instead of this one:

    set -- --exclame this does something --

Mark t1502.4 and t1502.5 as fixed.

Signed-off-by: Brandon Casey <redacted>
Signed-off-by: Junio C Hamano <redacted>
builtin/rev-parse.c
t/t1502-rev-parse-parseopt.sh
git clone https://git.99rst.org/PROJECT