branch: -v does not automatically imply --list

"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>

Michael J Gruber committed Sep 8, 2011 at 14:09 UTC 7b787599e4f45784c36e82030d0f6bae72817bfc
3 files changed +10 -7
Documentation/git-branch.txt
+3 -3
@@ -21,7 +21,7 @@ DESCRIPTION
21 With no arguments, existing branches are listed and the current branch will
22 be highlighted with an asterisk. Option `-r` causes the remote-tracking
23 branches to be listed, and option `-a` shows both. This list mode is also
24 -activated by the `--list` and `-v` options (see below).
24 +activated by the `--list` option (see below).
25 <pattern> restricts the output to matching branches, the pattern is a shell
26 wildcard (i.e., matched using fnmatch(3))
27 Multiple patterns may be given; if any of them matches, the tag is shown.
@@ -120,10 +120,10 @@ OPTIONS
120
121 -v::
122 --verbose::
123 - Show sha1 and commit subject line for each head, along with
123 + When in list mode,
124 + show sha1 and commit subject line for each head, along with
125 relationship to upstream branch (if any). If given twice, print
126 the name of the upstream branch, as well.
126 - `--list` is implied by all verbosity options.
127
128 --abbrev=<length>::
129 Alter the sha1's minimum display length in the output listing.
builtin/branch.c
+1 -2
@@ -712,8 +712,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
712 argc = parse_options(argc, argv, prefix, options, builtin_branch_usage,
713 0);
714
715 - if (!delete && !rename && !force_create &&
716 - (argc == 0 || (verbose && argc)))
715 + if (!delete && !rename && !force_create && argc == 0)
716 list = 1;
717
718 if (!!delete + !!rename + !!force_create + !!list > 1)
t/t3203-branch-output.sh
+6 -2
@@ -84,12 +84,16 @@ cat >expect <<'EOF'
84 two
85 one
86 EOF
87 -test_expect_success 'git branch -v pattern shows branch summaries' '
88 - git branch -v branch* >tmp &&
87 +test_expect_success 'git branch --list -v pattern shows branch summaries' '
88 + git branch --list -v branch* >tmp &&
89 awk "{print \$NF}" <tmp >actual &&
90 test_cmp expect actual
91 '
92
93 +test_expect_success 'git branch -v pattern does not show branch summaries' '
94 + test_must_fail git branch -v branch*
95 +'
96 +
97 cat >expect <<'EOF'
98 * (no branch)
99 branch-one