Re: Suggestion: better error message when an ambiguous checkout is executed
From: Junio C Hamano <hidden>
Date: 2017-09-12 06:53:24
Junio C Hamano [off-list ref] writes:
Mahmoud Al-Qudsi [off-list ref] writes:quoted
The default git behavior when attempting to `git checkout xxx` for some value of "xxx" that cannot be resolved to a single, unique file/path/branch/tag/commit/etc is to display the following:... So a possible implementation approach would be - to let the current code do what it is doing - except that you add new code immediately before the code that issues 'xxx' did not match (i.e. the code already checked that 'xxx' taken as a pathspec does not match anything, and about to give the error message but hasn't done so just yet). - your new code . checks if 'xxx' could be an attempt to refer to a rev but insufficiently spelled out (e.g. both origin[12]/xxx exists, or for a bonus point, a similarly named origin/xxy exists and could be a typo). . if the above check found something, then you report it and terminate without complaining "pathspec 'xxx' did not match..." . on the other hand, if the above check did not find anything, then you let the current code issue the same error message as before.
I was sweeping my mailbox to collect loose ends that haven't been tied down, and noticed that this topic does not seem to have reached a conclusion. Do we want to reboot the effort? Or should we just throw it in the #leftoverbits bin for now? Thanks.