Skip to content

Improving advise messages from "switch"

Junio C Hamano git 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 3 repliesIn review
  2. v12 patches 2 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2checkout: pass program-readable token to unified "main"builtin/checkout.c+43 -202 replies
2/2checkout: tell "parse_remote_branch" which command is calling itbuiltin/checkout.c t/t2027-checkout-track.sh+42 -51 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

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

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.