public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, K Jayatheerth <jayatheerthkulkarni2005@gmail.com>
Subject: [PATCH v2] branch: reject --show-current with -v
Date: Sun, 22 Mar 2026 11:37:05 +0530	[thread overview]
Message-ID: <20260322060705.53491-1-jayatheerthkulkarni2005@gmail.com> (raw)

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.

Acked-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>
---
I only changed the title of the commit message.
The previous one (i.e remove unnecessary verbose flag) sounded
like we are nuking the whole verbose flag.

The acked by tag exists here because this was supposed to be queued,
I am resending this to remind.
The originial discussion however is here:
https://lore.kernel.org/git/20251226032804.596058-1-jayatheerthkulkarni2005@gmail.com/T/#u

 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 a1a43380d0..cab22e1538 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -861,6 +861,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.53.0


             reply	other threads:[~2026-03-22  6:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-22  6:07 K Jayatheerth [this message]
2026-03-22 16:34 ` [PATCH v2] branch: reject --show-current with -v Phillip Wood
2026-03-22 21:42   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260322060705.53491-1-jayatheerthkulkarni2005@gmail.com \
    --to=jayatheerthkulkarni2005@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox