{"thread":{"id":"64680","subject":"Why git branch --show-current ignores -v?","startedAt":"2025-12-25T16:08:37Z","lastAt":"2025-12-26T15:43:24Z","messageCount":6,"participants":["Sergey Organov","Junio C Hamano","K Jayatheerth"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"532740","messageId":"87h5tev918.fsf@osv.gnss.ru","threadId":"64680","inReplyTo":null,"subject":"Why git branch --show-current ignores -v?","fromName":"Sergey Organov","fromEmail":"sorganov@gmail.com","sentAt":"2025-12-25T16:08:35Z","receivedAt":"2025-12-25T16:08:37Z","isPatch":false,"sender":{"key":"sorganov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8501568?v=4"},"body":"Hello,\n\nIt looks useful and natural for \"git branch --show-current -v[v]\" to\nverbosely describe current branch, similar to what --list does. Is there\nsound reason why -v is not supported by --show-current?\n\nThanks,\n-- Sergey Organov\n\n"},{"id":"532745","messageId":"xmqq8qeqm1tp.fsf@gitster.g","threadId":"64680","inReplyTo":"87h5tev918.fsf@osv.gnss.ru","subject":"Re: Why git branch --show-current ignores -v?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-12-26T02:09:06Z","receivedAt":"2025-12-26T02:09:09Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sergey Organov <sorganov@gmail.com> writes:\n\n> It looks useful and natural for \"git branch --show-current -v[v]\" to\n> verbosely describe current branch, similar to what --list does. Is there\n> sound reason why -v is not supported by --show-current?\n\nThe \"--show-current\" feature was invented merely for those who\nsomehow found it ugly to use \"git symbolic-ref HEAD\" when a user\nwants to learn what the current branch was.  If I have to guess,\nnobody thought about it as a way to get the same output as \"--list\"\nbut restricted to the single current branch.  Hence nobody felt the\nneed to support any option that the \"--list\" operation supported,\nincluding \"-v\".  IOW, nobody shared your \"It looks useful\" so far,\nespecially among the people who knew where the \"--show-current\"\noption came from.\n\nI do not think anybody terribly objects if somebody teaches \"-v\" to\nmake \"git branch --show-current\" more verbose, and other \"--list\"\noperations in general, but I suspect that the exact contents in the\nverbose output may have to be different from that of \"--list\".  For\none thing, as \"--show-current\" limits its output to the current\nbranch, the two-place indent \"git branch --list\" gives its output is\nnot there, and \"-v\" would probably not want to add it.\n\n"},{"id":"532746","messageId":"xmqq1pkim1p6.fsf@gitster.g","threadId":"64680","inReplyTo":"xmqq8qeqm1tp.fsf@gitster.g","subject":"Re: Why git branch --show-current ignores -v?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-12-26T02:11:49Z","receivedAt":"2025-12-26T02:11:51Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Sergey Organov <sorganov@gmail.com> writes:\n>\n>> It looks useful and natural for \"git branch --show-current -v[v]\" to\n>> verbosely describe current branch, similar to what --list does. Is there\n>> sound reason why -v is not supported by --show-current?\n>\n> The \"--show-current\" feature was invented merely for those who\n> somehow found it ugly to use \"git symbolic-ref HEAD\" when a user\n> wants to learn what the current branch was.  If I have to guess,\n> nobody thought about it as a way to get the same output as \"--list\"\n> but restricted to the single current branch.  Hence nobody felt the\n> need to support any option that the \"--list\" operation supported,\n> including \"-v\".  IOW, nobody shared your \"It looks useful\" so far,\n> especially among the people who knew where the \"--show-current\"\n> option came from.\n>\n> I do not think anybody terribly objects if somebody teaches \"-v\" to\n> make \"git branch --show-current\" more verbose, and other \"--list\"\n> operations in general, but I suspect that the exact contents in the\n> verbose output may have to be different from that of \"--list\".  For\n> one thing, as \"--show-current\" limits its output to the current\n> branch, the two-place indent \"git branch --list\" gives its output is\n> not there, and \"-v\" would probably not want to add it.\n\nForgot to say something much more important.  \n\nCommands should complain when users give them input that they do not\nunderstand.  If \"git branch --show-current -v\" silently eats \"-v\", I\nwould say it is a bug.\n\nUnless we define that the current output is already verbose, that\nis.\n\nThanks.\n"},{"id":"532747","messageId":"20251226032804.596058-1-jayatheerthkulkarni2005@gmail.com","threadId":"64680","inReplyTo":"xmqq1pkim1p6.fsf@gitster.g","subject":"[PATCH] branch: Remove unnecessary verbose flag","fromName":"K Jayatheerth","fromEmail":"jayatheerthkulkarni2005@gmail.com","sentAt":"2025-12-26T03:28:04Z","receivedAt":"2025-12-26T03:28:23Z","isPatch":true,"sender":{"key":"jayatheerthkulkarni2005@gmail.com","avatar":"https://avatars.githubusercontent.com/u/148841023?v=4"},"body":"The --show-current option doesn't know how to handle verbose\nlogic. In such a case, we want the program to die when both flags\nare used together.\n\nSigned-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>\n---\n builtin/branch.c  | 2 ++\n t/t3200-branch.sh | 4 ++++\n 2 files changed, 6 insertions(+)\n\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex c577b5d20f..433c213dc0 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -860,6 +860,8 @@ int cmd_branch(int argc,\n \t\tret = delete_branches(argc, argv, delete > 1, filter.kind, quiet);\n \t\tgoto out;\n \t} else if (show_current) {\n+\t\tif (filter.verbose)\n+\t\t\tdie(_(\"options '%s' and '%s' cannot be used together\"), \"--show-current\", \"-v\");\n \t\tprint_current_branch_name();\n \t\tret = 0;\n \t\tgoto out;\ndiff --git a/t/t3200-branch.sh b/t/t3200-branch.sh\nindex c58e505c43..5bb49de9c2 100755\n--- a/t/t3200-branch.sh\n+++ b/t/t3200-branch.sh\n@@ -1716,4 +1716,8 @@ test_expect_success 'errors if given a bad branch name' '\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'git branch --show-current rejects -v' '\n+\ttest_must_fail git branch --show-current -v\n+'\n+\n test_done\n-- \n2.52.0\n\n"},{"id":"532748","messageId":"xmqqldiplvyd.fsf@gitster.g","threadId":"64680","inReplyTo":"20251226032804.596058-1-jayatheerthkulkarni2005@gmail.com","subject":"Re: [PATCH] branch: Remove unnecessary verbose flag","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-12-26T04:15:54Z","receivedAt":"2025-12-26T04:15:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"K Jayatheerth <jayatheerthkulkarni2005@gmail.com> writes:\n\n> The --show-current option doesn't know how to handle verbose\n> logic. In such a case, we want the program to die when both flags\n> are used together.\n>\n> Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>\n> ---\n>  builtin/branch.c  | 2 ++\n>  t/t3200-branch.sh | 4 ++++\n>  2 files changed, 6 insertions(+)\n>\n> diff --git a/builtin/branch.c b/builtin/branch.c\n> index c577b5d20f..433c213dc0 100644\n> --- a/builtin/branch.c\n> +++ b/builtin/branch.c\n> @@ -860,6 +860,8 @@ int cmd_branch(int argc,\n>  \t\tret = delete_branches(argc, argv, delete > 1, filter.kind, quiet);\n>  \t\tgoto out;\n>  \t} else if (show_current) {\n> +\t\tif (filter.verbose)\n> +\t\t\tdie(_(\"options '%s' and '%s' cannot be used together\"), \"--show-current\", \"-v\");\n>  \t\tprint_current_branch_name();\n>  \t\tret = 0;\n>  \t\tgoto out;\n> diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh\n> index c58e505c43..5bb49de9c2 100755\n> --- a/t/t3200-branch.sh\n> +++ b/t/t3200-branch.sh\n> @@ -1716,4 +1716,8 @@ test_expect_success 'errors if given a bad branch name' '\n>  \ttest_cmp expect actual\n>  '\n>  \n> +test_expect_success 'git branch --show-current rejects -v' '\n> +\ttest_must_fail git branch --show-current -v\n> +'\n> +\n>  test_done\n\nThanks.\n\nThis is certainly an improvement over status quo.\n\nIdeally, however, if you say\n\n    git branch -v -q --show-current\n\nshouldn't it also barf?  IOW, checking the end state (i.e.\nfilter.verbose being zero) is one thing, but to do a good job, we\nprobably should check how we got to the end state.\n\nSince that would require a far larger change without a tangible\nbenefit, I'd say the posted patch that checks only the end state is\ngood enough for now.\n\nWill queue.\n"},{"id":"532765","messageId":"871pkh8d0l.fsf@osv.gnss.ru","threadId":"64680","inReplyTo":"xmqq8qeqm1tp.fsf@gitster.g","subject":"Re: Why git branch --show-current ignores -v?","fromName":"Sergey Organov","fromEmail":"sorganov@gmail.com","sentAt":"2025-12-26T15:43:22Z","receivedAt":"2025-12-26T15:43:24Z","isPatch":false,"sender":{"key":"sorganov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8501568?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Sergey Organov <sorganov@gmail.com> writes:\n>\n>> It looks useful and natural for \"git branch --show-current -v[v]\" to\n>> verbosely describe current branch, similar to what --list does. Is there\n>> sound reason why -v is not supported by --show-current?\n>\n\n[...]\n\n> I do not think anybody terribly objects if somebody teaches \"-v\" to\n> make \"git branch --show-current\" more verbose, and other \"--list\"\n> operations in general, but I suspect that the exact contents in the\n> verbose output may have to be different from that of \"--list\".  For\n> one thing, as \"--show-current\" limits its output to the current\n> branch, the two-place indent \"git branch --list\" gives its output is\n> not there, and \"-v\" would probably not want to add it.\n\nYep, I didn't mean to suggest exactly the same format and contents,\nthough just reproducing the --list won't hurt either.\n\nThe actual use-case was to quickly figure the upstream branch and\nrelative status of the current one, and\n\n    git br --show-current -vv\n\njust looked more natural for the job at hand than something like\n\n    git br -lvv master\n\nthat besides is not exactly the same, and then the following one is\nkinda overkill for manual use)))\n\n    git br -lvv `git br --show-current`\n\nThat suddenly gets me to why Git has no synonym for the current branch\nin the first place? No @HEAD or @@?\n\n   git br -lvv @@\n\nis pretty-looking perl'y that unfortunately doesn't work.\n\nThanks,\nSergey Organov\n"}]}