]> Kevux Git Server - rit/commit
checkout: tell "parse_remote_branch" which command is calling it
authorJunio C Hamano <gitster@pobox.com>
Thu, 29 Jan 2026 19:06:16 +0000 (11:06 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 9 Feb 2026 16:33:17 +0000 (08:33 -0800)
commit12fee11f21e9b63626da5058fa055f95d55a5515
tree357c4dc6ccc5ba00c307e8c9abe3924d9d78598f
parent2096948158ea0b253a68a81c691fdf88ff00589a
checkout: tell "parse_remote_branch" which command is calling it

When "git checkout <dwim>" and "git switch <dwim>" need to error out
due to ambiguity of the branch name <dwim>, these two commands give
an advise message with a sample command that tells the user how to
disambiguate from the parse_remote_branch() function.  The sample
command hardcodes "git checkout", since this feature predates "git
switch" by a large margin.  To a user who said "git switch <dwim>"
and got this message, it is confusing.

Pass the "enum checkout_command", which was invented in the previous
step for this exact purpose, down the call chain leading to
parse_remote_branch() function to change the sample command shown to
the user in this advise message.

Also add a bit more test coverage for this "fail to DWIM under
ambiguity" that we lack, as well as the message we produce when we
fail.

Reported-by: Simon Cheng <cyqsimon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/checkout.c
t/t2027-checkout-track.sh