branch: reject "--no-all" and "--no-remotes" early
As the command line parser for "git branch --all" forgets to use PARSE_OPT_NONEG, it accepted "git branch --no-all", and then passed a nonsense value to the underlying machinery, leading to a fatal error "filter_refs: invalid type". The "--remotes" option had exactly the same issue. Catch the unsupported options early in the option parser. Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
@ -55,9 +55,17 @@ cat >expect <<'EOF'
|
||||
EOF
|
||||
test_expect_success 'git branch -r shows remote branches' '
|
||||
git branch -r >actual &&
|
||||
test_cmp expect actual &&
|
||||
|
||||
git branch --remotes >actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'git branch --no-remotes is rejected' '
|
||||
test_must_fail git branch --no-remotes 2>err &&
|
||||
grep "unknown option .no-remotes." err
|
||||
'
|
||||
|
||||
cat >expect <<'EOF'
|
||||
branch-one
|
||||
branch-two
|
||||
@ -68,9 +76,17 @@ cat >expect <<'EOF'
|
||||
EOF
|
||||
test_expect_success 'git branch -a shows local and remote branches' '
|
||||
git branch -a >actual &&
|
||||
test_cmp expect actual &&
|
||||
|
||||
git branch --all >actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'git branch --no-all is rejected' '
|
||||
test_must_fail git branch --no-all 2>err &&
|
||||
grep "unknown option .no-all." err
|
||||
'
|
||||
|
||||
cat >expect <<'EOF'
|
||||
two
|
||||
one
|
||||
|
Reference in New Issue
Block a user