Skip to content

Commit

Permalink
branch: -v does not automatically imply --list
Browse files Browse the repository at this point in the history
"branch -v" without other options or parameters still works in the list
mode, but that is not because there is "-v" but because there is no
parameter nor option.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Michael J Gruber authored and Junio C Hamano committed Sep 8, 2011
1 parent d8d3373 commit 7b78759
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
6 changes: 3 additions & 3 deletions Documentation/git-branch.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ DESCRIPTION
With no arguments, existing branches are listed and the current branch will
be highlighted with an asterisk. Option `-r` causes the remote-tracking
branches to be listed, and option `-a` shows both. This list mode is also
activated by the `--list` and `-v` options (see below).
activated by the `--list` option (see below).
<pattern> restricts the output to matching branches, the pattern is a shell
wildcard (i.e., matched using fnmatch(3))
Multiple patterns may be given; if any of them matches, the tag is shown.
Expand Down Expand Up @@ -120,10 +120,10 @@ OPTIONS

-v::
--verbose::
Show sha1 and commit subject line for each head, along with
When in list mode,
show sha1 and commit subject line for each head, along with
relationship to upstream branch (if any). If given twice, print
the name of the upstream branch, as well.
`--list` is implied by all verbosity options.

--abbrev=<length>::
Alter the sha1's minimum display length in the output listing.
Expand Down
3 changes: 1 addition & 2 deletions builtin/branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -712,8 +712,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
argc = parse_options(argc, argv, prefix, options, builtin_branch_usage,
0);

if (!delete && !rename && !force_create &&
(argc == 0 || (verbose && argc)))
if (!delete && !rename && !force_create && argc == 0)
list = 1;

if (!!delete + !!rename + !!force_create + !!list > 1)
Expand Down
8 changes: 6 additions & 2 deletions t/t3203-branch-output.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,16 @@ cat >expect <<'EOF'
two
one
EOF
test_expect_success 'git branch -v pattern shows branch summaries' '
git branch -v branch* >tmp &&
test_expect_success 'git branch --list -v pattern shows branch summaries' '
git branch --list -v branch* >tmp &&
awk "{print \$NF}" <tmp >actual &&
test_cmp expect actual
'

test_expect_success 'git branch -v pattern does not show branch summaries' '
test_must_fail git branch -v branch*
'

cat >expect <<'EOF'
* (no branch)
branch-one
Expand Down

0 comments on commit 7b78759

Please sign in to comment.