Re: [PATCHv2 4/5] branch: introduce --list option
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 8, 2011, 21:17 UTC
- Message-ID
- <7vmxeewx7f.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <7vr53qwxtz.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 14 quoted lines
> Michael J Gruber <git@drmicha.warpmail.net> writes: > >> Jeff King venit, vidit, dixit 07.09.2011 21:56: >> ... >>> It does make me a little nervous about the "'git branch -v' >>> automatically means 'git branch --list -v'" patch, though. It closes the >>> door in the future to us being more or less verbose about branch >>> creation details (and while helpful, it creates a slight inconsistency >>> in the interface). > > Hasn't 'git branch -v' meant listing in verbose mode for a long enough > time that changing it now would mean a moderately major regression? > > At least my copy of v1.7.0 seems to list with "git branch -v".
Ah, nevermind.
As the series is already in 'next', here is what I came up with.
-- >8 -- From: Michael J Gruber <git@drmicha.warpmail.net> Date: Thu, 8 Sep 2011 14:09:50 -0700 Subject: [PATCH] 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> --- Documentation/git-branch.txt | 6 +++--- builtin/branch.c | 3 +-- t/t3203-branch-output.sh | 8 ++++++-- 3 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt index 2b8bc84..f46013c 100644 --- a/Documentation/git-branch.txt +++ b/Documentation/git-branch.txt @@ -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. @@ -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. diff --git a/builtin/branch.c b/builtin/branch.c index 98a420f..099c75c 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -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) diff --git a/t/t3203-branch-output.sh b/t/t3203-branch-output.sh index f2b294b..76fe7e0 100755 --- a/t/t3203-branch-output.sh +++ b/t/t3203-branch-output.sh @@ -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
-- 1.7.7.rc0.188.g3793ac