Skip to content

Commit ce7f874

Browse files
committed
t1502: protect runs of SPs used in the indentation
The expected output from the argument help use runs of SPs to align the description of each option; a careless use of --whitespace=fix can turn leading parts of them into appropriate number of HTs. Prevent such a breakage by prefixing all the expected lines with leading vertical bars in the original and stripping them with a small sed script. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9bab5b6 commit ce7f874

File tree

1 file changed

+56
-56
lines changed

1 file changed

+56
-56
lines changed

t/t1502-rev-parse-parseopt.sh

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -3,64 +3,64 @@
33
test_description='test git rev-parse --parseopt'
44
. ./test-lib.sh
55

6-
cat > expect <<\END_EXPECT
7-
cat <<\EOF
8-
usage: some-command [options] <args>...
9-
10-
some-command does foo and bar!
11-
12-
-h, --help show the help
13-
--foo some nifty option --foo
14-
--bar ... some cool option --bar with an argument
15-
-b, --baz a short and long option
16-
17-
An option group Header
18-
-C[...] option C with an optional argument
19-
-d, --data[=...] short and long option with an optional argument
20-
21-
Argument hints
22-
-b <arg> short option required argument
23-
--bar2 <arg> long option required argument
24-
-e, --fuz <with-space>
25-
short and long option required argument
26-
-s[<some>] short option optional argument
27-
--long[=<data>] long option optional argument
28-
-g, --fluf[=<path>] short and long option optional argument
29-
--longest <very-long-argument-hint>
30-
a very long argument hint
31-
32-
Extras
33-
--extra1 line above used to cause a segfault but no longer does
34-
35-
EOF
6+
sed -e 's/^|//' >expect <<\END_EXPECT
7+
|cat <<\EOF
8+
|usage: some-command [options] <args>...
9+
|
10+
| some-command does foo and bar!
11+
|
12+
| -h, --help show the help
13+
| --foo some nifty option --foo
14+
| --bar ... some cool option --bar with an argument
15+
| -b, --baz a short and long option
16+
|
17+
|An option group Header
18+
| -C[...] option C with an optional argument
19+
| -d, --data[=...] short and long option with an optional argument
20+
|
21+
|Argument hints
22+
| -b <arg> short option required argument
23+
| --bar2 <arg> long option required argument
24+
| -e, --fuz <with-space>
25+
| short and long option required argument
26+
| -s[<some>] short option optional argument
27+
| --long[=<data>] long option optional argument
28+
| -g, --fluf[=<path>] short and long option optional argument
29+
| --longest <very-long-argument-hint>
30+
| a very long argument hint
31+
|
32+
|Extras
33+
| --extra1 line above used to cause a segfault but no longer does
34+
|
35+
|EOF
3636
END_EXPECT
3737

38-
cat > optionspec << EOF
39-
some-command [options] <args>...
40-
41-
some-command does foo and bar!
42-
--
43-
h,help show the help
44-
45-
foo some nifty option --foo
46-
bar= some cool option --bar with an argument
47-
b,baz a short and long option
48-
49-
An option group Header
50-
C? option C with an optional argument
51-
d,data? short and long option with an optional argument
52-
53-
Argument hints
54-
b=arg short option required argument
55-
bar2=arg long option required argument
56-
e,fuz=with-space short and long option required argument
57-
s?some short option optional argument
58-
long?data long option optional argument
59-
g,fluf?path short and long option optional argument
60-
longest=very-long-argument-hint a very long argument hint
61-
62-
Extras
63-
extra1 line above used to cause a segfault but no longer does
38+
sed -e 's/^|//' >optionspec <<\EOF
39+
|some-command [options] <args>...
40+
|
41+
|some-command does foo and bar!
42+
|--
43+
|h,help show the help
44+
|
45+
|foo some nifty option --foo
46+
|bar= some cool option --bar with an argument
47+
|b,baz a short and long option
48+
|
49+
| An option group Header
50+
|C? option C with an optional argument
51+
|d,data? short and long option with an optional argument
52+
|
53+
| Argument hints
54+
|b=arg short option required argument
55+
|bar2=arg long option required argument
56+
|e,fuz=with-space short and long option required argument
57+
|s?some short option optional argument
58+
|long?data long option optional argument
59+
|g,fluf?path short and long option optional argument
60+
|longest=very-long-argument-hint a very long argument hint
61+
|
62+
|Extras
63+
|extra1 line above used to cause a segfault but no longer does
6464
EOF
6565

6666
test_expect_success 'test --parseopt help output' '

0 commit comments

Comments
 (0)