All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Simon Cheng <cyqsimon@gmail.com>,
	Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
Subject: Re: [PATCH v2 2/2] checkout: tell "parse_remote_branch" which command is calling it
Date: Fri, 6 Feb 2026 17:05:24 +0100	[thread overview]
Message-ID: <aYYRRBdCrbWmy1Gj@pks.im> (raw)
In-Reply-To: <20260129190616.645471-3-gitster@pobox.com>

On Thu, Jan 29, 2026 at 11:06:16AM -0800, Junio C Hamano wrote:
> diff --git a/builtin/checkout.c b/builtin/checkout.c
> index 4f189fde48..17f31c30b2 100644
> --- a/builtin/checkout.c
> +++ b/builtin/checkout.c
> @@ -1299,14 +1300,30 @@ static char *parse_remote_branch(const char *arg,
>  
>  	if (!remote && num_matches > 1) {
>  	    if (advice_enabled(ADVICE_CHECKOUT_AMBIGUOUS_REMOTE_BRANCH_NAME)) {
> +		    const char *cmdname;
> +
> +		    switch (which_command) {
> +		    case CHECKOUT_CHECKOUT:
> +			    cmdname = "checkout";
> +			    break;
> +		    case CHECKOUT_SWITCH:
> +			    cmdname = "switch";
> +			    break;
> +		    default:
> +			    BUG("command <%d> should not reach parse_remote_branch",
> +				which_command);
> +			    break;
> +		    }

`parse_remote_branch()` is only called by `parse_branchname_arg()`,
which in turn is only called if `opts->accept_ref` is truish. And as
that value only gets set to 1 in git-checkout(1) and git-switch(1) we
know that we indeed don't have to care about git-restore(1).

>  		    advise(_("If you meant to check out a remote tracking branch on, e.g. 'origin',\n"
>  			     "you can do so by fully qualifying the name with the --track option:\n"
>  			     "\n"
> -			     "    git checkout --track origin/<name>\n"
> +			     "    git %s --track origin/<name>\n"
>  			     "\n"
>  			     "If you'd like to always have checkouts of an ambiguous <name> prefer\n"
>  			     "one remote, e.g. the 'origin' remote, consider setting\n"
> -			     "checkout.defaultRemote=origin in your config."));
> +			     "checkout.defaultRemote=origin in your config."),
> +			   cmdname);
>  	    }
>  
>  	    die(_("'%s' matched multiple (%d) remote tracking branches"),

Yup, makes sense.

Overall this patch series looks good to me. There's been the one
micronit in the preceding commit, but I really don't think it warrants
a new version.

Thanks!

Patrick

      reply	other threads:[~2026-02-06 16:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-27 19:29 [PATCH 0/2] Improving advise messages from "switch" Junio C Hamano
2026-01-27 19:29 ` [PATCH 1/2] checkout: pass program-readable token to unified "main" Junio C Hamano
2026-01-27 19:29 ` [PATCH 2/2] checkout: tell "parse_remote_branch" which command is calling it Junio C Hamano
2026-01-27 20:35   ` Kristoffer Haugsbakk
2026-01-27 21:22     ` Junio C Hamano
2026-01-29 19:06 ` [PATCH v2 0/2] Improving advise messages from "switch" Junio C Hamano
2026-01-29 19:06   ` [PATCH v2 1/2] checkout: pass program-readable token to unified "main" Junio C Hamano
2026-02-06 16:05     ` Patrick Steinhardt
2026-02-19 22:21       ` Junio C Hamano
2026-01-29 19:06   ` [PATCH v2 2/2] checkout: tell "parse_remote_branch" which command is calling it Junio C Hamano
2026-02-06 16:05     ` Patrick Steinhardt [this message]

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=aYYRRBdCrbWmy1Gj@pks.im \
    --to=ps@pks.im \
    --cc=cyqsimon@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=kristofferhaugsbakk@fastmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.