git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>
Cc: git@vger.kernel.org,  sorganov@gmail.com
Subject: Re: [PATCH] branch: Remove unnecessary verbose flag
Date: Fri, 26 Dec 2025 13:15:54 +0900	[thread overview]
Message-ID: <xmqqldiplvyd.fsf@gitster.g> (raw)
In-Reply-To: <20251226032804.596058-1-jayatheerthkulkarni2005@gmail.com> (K. Jayatheerth's message of "Fri, 26 Dec 2025 08:58:04 +0530")

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.

  reply	other threads:[~2025-12-26  4:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2025-12-26 15:43   ` Why git branch --show-current ignores -v? Sergey Organov

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=xmqqldiplvyd.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jayatheerthkulkarni2005@gmail.com \
    --cc=sorganov@gmail.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;
as well as URLs for NNTP newsgroup(s).