git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 29, 2026, 19:06 UTC
Message-ID
<20260129190616.645471-1-gitster@pobox.com>
In-Reply-To
<20260127192936.904719-1-gitster@pobox.com>

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 | 18 ++++++++
 2 files changed, 85 insertions(+), 25 deletions(-)
---

This second iteration simplifies the tests in the second patch somewhat, and rewords its proposed log message, as suggested by Kristoffer Haugsbakk.

Previous: Junio C HamanoNext: Junio C Hamano
Message 6 of 11 in “Improving advise messages from "switch"”
  1. 0/2 Improving advise messages from "switch"Junio C Hamano, Jan 27, 2026
  2. 1/2 checkout: pass program-readable token to unified "main"Junio C Hamano, Jan 27, 2026
  3. 2/2 checkout: tell "parse_remote_branch" which command is calling itJunio C Hamano, Jan 27, 2026
  4. Kristoffer HaugsbakkJan 27, 2026
  5. Junio C HamanoJan 27, 2026
  6. 0/2 Improving advise messages from "switch"Junio C Hamano, Jan 29, 2026
  7. 1/2 checkout: pass program-readable token to unified "main"Junio C Hamano, Jan 29, 2026
  8. Patrick SteinhardtFeb 6, 2026
  9. Junio C HamanoFeb 19, 2026
  10. 2/2 checkout: tell "parse_remote_branch" which command is calling itJunio C Hamano, Jan 29, 2026
  11. Patrick SteinhardtFeb 6, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.