* Why git branch --show-current ignores -v?
@ 2025-12-25 16:08 Sergey Organov
2025-12-26 2:09 ` Junio C Hamano
0 siblings, 1 reply; 6+ messages in thread
From: Sergey Organov @ 2025-12-25 16:08 UTC (permalink / raw)
To: git
Hello,
It looks useful and natural for "git branch --show-current -v[v]" to
verbosely describe current branch, similar to what --list does. Is there
sound reason why -v is not supported by --show-current?
Thanks,
-- Sergey Organov
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Why git branch --show-current ignores -v?
2025-12-25 16:08 Why git branch --show-current ignores -v? Sergey Organov
@ 2025-12-26 2:09 ` Junio C Hamano
2025-12-26 2:11 ` Junio C Hamano
2025-12-26 15:43 ` Why git branch --show-current ignores -v? Sergey Organov
0 siblings, 2 replies; 6+ messages in thread
From: Junio C Hamano @ 2025-12-26 2:09 UTC (permalink / raw)
To: Sergey Organov; +Cc: git
Sergey Organov <sorganov@gmail.com> writes:
> It looks useful and natural for "git branch --show-current -v[v]" to
> verbosely describe current branch, similar to what --list does. Is there
> sound reason why -v is not supported by --show-current?
The "--show-current" feature was invented merely for those who
somehow found it ugly to use "git symbolic-ref HEAD" when a user
wants to learn what the current branch was. If I have to guess,
nobody thought about it as a way to get the same output as "--list"
but restricted to the single current branch. Hence nobody felt the
need to support any option that the "--list" operation supported,
including "-v". IOW, nobody shared your "It looks useful" so far,
especially among the people who knew where the "--show-current"
option came from.
I do not think anybody terribly objects if somebody teaches "-v" to
make "git branch --show-current" more verbose, and other "--list"
operations in general, but I suspect that the exact contents in the
verbose output may have to be different from that of "--list". For
one thing, as "--show-current" limits its output to the current
branch, the two-place indent "git branch --list" gives its output is
not there, and "-v" would probably not want to add it.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Why git branch --show-current ignores -v?
2025-12-26 2:09 ` Junio C Hamano
@ 2025-12-26 2:11 ` Junio C Hamano
2025-12-26 3:28 ` [PATCH] branch: Remove unnecessary verbose flag K Jayatheerth
2025-12-26 15:43 ` Why git branch --show-current ignores -v? Sergey Organov
1 sibling, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2025-12-26 2:11 UTC (permalink / raw)
To: Sergey Organov; +Cc: git
Junio C Hamano <gitster@pobox.com> writes:
> Sergey Organov <sorganov@gmail.com> writes:
>
>> It looks useful and natural for "git branch --show-current -v[v]" to
>> verbosely describe current branch, similar to what --list does. Is there
>> sound reason why -v is not supported by --show-current?
>
> The "--show-current" feature was invented merely for those who
> somehow found it ugly to use "git symbolic-ref HEAD" when a user
> wants to learn what the current branch was. If I have to guess,
> nobody thought about it as a way to get the same output as "--list"
> but restricted to the single current branch. Hence nobody felt the
> need to support any option that the "--list" operation supported,
> including "-v". IOW, nobody shared your "It looks useful" so far,
> especially among the people who knew where the "--show-current"
> option came from.
>
> I do not think anybody terribly objects if somebody teaches "-v" to
> make "git branch --show-current" more verbose, and other "--list"
> operations in general, but I suspect that the exact contents in the
> verbose output may have to be different from that of "--list". For
> one thing, as "--show-current" limits its output to the current
> branch, the two-place indent "git branch --list" gives its output is
> not there, and "-v" would probably not want to add it.
Forgot to say something much more important.
Commands should complain when users give them input that they do not
understand. If "git branch --show-current -v" silently eats "-v", I
would say it is a bug.
Unless we define that the current output is already verbose, that
is.
Thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] branch: Remove unnecessary verbose flag
2025-12-26 2:11 ` Junio C Hamano
@ 2025-12-26 3:28 ` K Jayatheerth
2025-12-26 4:15 ` Junio C Hamano
0 siblings, 1 reply; 6+ messages in thread
From: K Jayatheerth @ 2025-12-26 3:28 UTC (permalink / raw)
To: gitster; +Cc: git, sorganov, K Jayatheerth
The --show-current option doesn't know how to handle verbose
logic. In such a case, we want the program to die when both flags
are used together.
Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>
---
builtin/branch.c | 2 ++
t/t3200-branch.sh | 4 ++++
2 files changed, 6 insertions(+)
diff --git a/builtin/branch.c b/builtin/branch.c
index c577b5d20f..433c213dc0 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -860,6 +860,8 @@ int cmd_branch(int argc,
ret = delete_branches(argc, argv, delete > 1, filter.kind, quiet);
goto out;
} else if (show_current) {
+ if (filter.verbose)
+ die(_("options '%s' and '%s' cannot be used together"), "--show-current", "-v");
print_current_branch_name();
ret = 0;
goto out;
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index c58e505c43..5bb49de9c2 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -1716,4 +1716,8 @@ test_expect_success 'errors if given a bad branch name' '
test_cmp expect actual
'
+test_expect_success 'git branch --show-current rejects -v' '
+ test_must_fail git branch --show-current -v
+'
+
test_done
--
2.52.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] branch: Remove unnecessary verbose flag
2025-12-26 3:28 ` [PATCH] branch: Remove unnecessary verbose flag K Jayatheerth
@ 2025-12-26 4:15 ` Junio C Hamano
0 siblings, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2025-12-26 4:15 UTC (permalink / raw)
To: K Jayatheerth; +Cc: git, sorganov
K Jayatheerth <jayatheerthkulkarni2005@gmail.com> writes:
> The --show-current option doesn't know how to handle verbose
> logic. In such a case, we want the program to die when both flags
> are used together.
>
> Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>
> ---
> builtin/branch.c | 2 ++
> t/t3200-branch.sh | 4 ++++
> 2 files changed, 6 insertions(+)
>
> diff --git a/builtin/branch.c b/builtin/branch.c
> index c577b5d20f..433c213dc0 100644
> --- a/builtin/branch.c
> +++ b/builtin/branch.c
> @@ -860,6 +860,8 @@ int cmd_branch(int argc,
> ret = delete_branches(argc, argv, delete > 1, filter.kind, quiet);
> goto out;
> } else if (show_current) {
> + if (filter.verbose)
> + die(_("options '%s' and '%s' cannot be used together"), "--show-current", "-v");
> print_current_branch_name();
> ret = 0;
> goto out;
> diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
> index c58e505c43..5bb49de9c2 100755
> --- a/t/t3200-branch.sh
> +++ b/t/t3200-branch.sh
> @@ -1716,4 +1716,8 @@ test_expect_success 'errors if given a bad branch name' '
> test_cmp expect actual
> '
>
> +test_expect_success 'git branch --show-current rejects -v' '
> + test_must_fail git branch --show-current -v
> +'
> +
> test_done
Thanks.
This is certainly an improvement over status quo.
Ideally, however, if you say
git branch -v -q --show-current
shouldn't it also barf? IOW, checking the end state (i.e.
filter.verbose being zero) is one thing, but to do a good job, we
probably should check how we got to the end state.
Since that would require a far larger change without a tangible
benefit, I'd say the posted patch that checks only the end state is
good enough for now.
Will queue.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Why git branch --show-current ignores -v?
2025-12-26 2:09 ` Junio C Hamano
2025-12-26 2:11 ` Junio C Hamano
@ 2025-12-26 15:43 ` Sergey Organov
1 sibling, 0 replies; 6+ messages in thread
From: Sergey Organov @ 2025-12-26 15:43 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
Junio C Hamano <gitster@pobox.com> writes:
> Sergey Organov <sorganov@gmail.com> writes:
>
>> It looks useful and natural for "git branch --show-current -v[v]" to
>> verbosely describe current branch, similar to what --list does. Is there
>> sound reason why -v is not supported by --show-current?
>
[...]
> I do not think anybody terribly objects if somebody teaches "-v" to
> make "git branch --show-current" more verbose, and other "--list"
> operations in general, but I suspect that the exact contents in the
> verbose output may have to be different from that of "--list". For
> one thing, as "--show-current" limits its output to the current
> branch, the two-place indent "git branch --list" gives its output is
> not there, and "-v" would probably not want to add it.
Yep, I didn't mean to suggest exactly the same format and contents,
though just reproducing the --list won't hurt either.
The actual use-case was to quickly figure the upstream branch and
relative status of the current one, and
git br --show-current -vv
just looked more natural for the job at hand than something like
git br -lvv master
that besides is not exactly the same, and then the following one is
kinda overkill for manual use)))
git br -lvv `git br --show-current`
That suddenly gets me to why Git has no synonym for the current branch
in the first place? No @HEAD or @@?
git br -lvv @@
is pretty-looking perl'y that unfortunately doesn't work.
Thanks,
Sergey Organov
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-12-26 15:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-25 16:08 Why git branch --show-current ignores -v? Sergey Organov
2025-12-26 2:09 ` Junio C Hamano
2025-12-26 2:11 ` Junio C Hamano
2025-12-26 3:28 ` [PATCH] branch: Remove unnecessary verbose flag K Jayatheerth
2025-12-26 4:15 ` Junio C Hamano
2025-12-26 15:43 ` Why git branch --show-current ignores -v? Sergey Organov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).