public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Cc: Simon Cheng <cyqsimon@gmail.com>
Subject: [PATCH 0/2] Improving advise messages from "switch"
Date: Tue, 27 Jan 2026 11:29:34 -0800	[thread overview]
Message-ID: <20260127192936.904719-1-gitster@pobox.com> (raw)

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/CA+itcS0iyqNyzOP0cueLg7B3yadoEr_VWJ-QoL+YPFUPJiE2RQ@mail.gmail.com

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


             reply	other threads:[~2026-01-27 19:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-27 19:29 Junio C Hamano [this message]
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

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=20260127192936.904719-1-gitster@pobox.com \
    --to=gitster@pobox.com \
    --cc=cyqsimon@gmail.com \
    --cc=git@vger.kernel.org \
    /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