3 test_description='test git rev-parse --parseopt'
6 cat > expect <<\END_EXPECT
8 usage: some-command [options] <args>...
10 some-command does foo and bar!
12 -h, --help show the help
13 --foo some nifty option --foo
14 --bar ... some cool option --bar with an argument
16 An option group Header
17 -C[...] option C with an optional argument
20 --extra1 line above used to cause a segfault but no longer does
25 cat > optionspec << EOF
26 some-command [options] <args>...
28 some-command does foo and bar!
32 foo some nifty option --foo
33 bar= some cool option --bar with an argument
35 An option group Header
36 C? option C with an optional argument
39 extra1 line above used to cause a segfault but no longer does
42 test_expect_success 'test --parseopt help output' '
43 git rev-parse --parseopt -- -h > output < optionspec
44 test_cmp expect output
48 set -- --foo --bar 'ham' -- 'arg'
51 test_expect_success 'test --parseopt' '
52 git rev-parse --parseopt -- --foo --bar=ham arg < optionspec > output &&
53 test_cmp expect output
56 test_expect_success 'test --parseopt with mixed options and arguments' '
57 git rev-parse --parseopt -- --foo arg --bar=ham < optionspec > output &&
58 test_cmp expect output
62 set -- --foo -- 'arg' '--bar=ham'
65 test_expect_success 'test --parseopt with --' '
66 git rev-parse --parseopt -- --foo -- arg --bar=ham < optionspec > output &&
67 test_cmp expect output
70 test_expect_success 'test --parseopt --stop-at-non-option' '
71 git rev-parse --parseopt --stop-at-non-option -- --foo arg --bar=ham < optionspec > output &&
72 test_cmp expect output
76 set -- --foo -- '--' 'arg' '--bar=ham'
79 test_expect_success 'test --parseopt --keep-dashdash' '
80 git rev-parse --parseopt --keep-dashdash -- --foo -- arg --bar=ham < optionspec > output &&
81 test_cmp expect output