[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.