Subject: [PATCH 0/2] Improving advise messages from "switch"

From: Junio C Hamano <[email-masked]>
Date: Tue, 27 Jan 2026 11:29:34 -0800

Simon Cheng noticed [*] that "git switch <name>", in an attempt to
create a local branch <name> after a remote tracking branch of the
same name, fails correctly when multiple remotes have branches with
that name, but gives an advise message to disambiguate using "git
checkout".

Obviously, the user wanted to use "git switch", and "git switch" is
equipped to do so, just like "git checkout" can, so it makes more
sense to give hint based on "git switch".

The first patch of this series restructures the call chain of
checkout, switch, and restore commands a bit, so that a helper deep
in the callchain can find out what end-user command it is working
for.  The second patch takes advantage of the new structure to tweak
the advise message in question, given from a helper function in a
fairly deep part of the call chain.

[Reference]

 * https://lore.kernel.org/git/[email-masked]

Junio C Hamano (2):
  checkout: pass program-readable token to unified "main"
  checkout: tell "parse_remote_branch" which command is calling it

 builtin/checkout.c        | 92 ++++++++++++++++++++++++++++-----------
 t/t2027-checkout-track.sh | 21 +++++++++
 2 files changed, 88 insertions(+), 25 deletions(-)

-- 
2.53.0-rc2-135-gb1217c0133