On Fri, Oct 25, 2013 at 8:14 AM, Jeff King <peff@xxxxxxxx> wrote: > On Fri, Oct 25, 2013 at 02:14:07AM -0400, Jeff King wrote: >> > Could this error message be improved for interactive commands by >> > first checking to see whether or not the path starts with a remote, >> > then recommend that the remote be pulled? >> >> That might be worth doing. We cannot definitely say the branch exists >> without hitting the network (which we would not want to do in the >> general case), but I think it is reasonable for git to give suggestions >> (we could also give a "did you mean X..." for near-typos, as we do for >> typo-ed commands like "git dif". >> >> If you do try it, please don't just check for the remote name, but >> actually complete the right-hand side of the fetch refspec for each >> remote. They are equivalent in the default config, but aren't >> necessarily so (and there has been talk of adjusting the layout of >> remote refspecs). I don't recall offhand what functions we have to help >> you, but I believe Johan (cc'd) was working in this area recently and >> might be able to say more. Actually, I don't think there's much refspec stuff to be done here. When running "git diff $remote/$branch", there are 3 possible outcomes: - $remote is not a valid remote name, the user probably meant something different (like "nested/branch"). The current error message is fine. - $remote is a valid remote name, but $branch has not (yet) been fetched from there. Suggest the user run "git fetch $remote" - $remote/$branch is a valid remote-tracking branch. The diff works! No errors. So, AFAICS, the patch should simply: 1. Split the input on the first '/' into $remote/$branch, and use the preceding part ($remote) as a potential remote name, and the following part ($branch) as a potential branch name. (Although it is theoretically possible to have remote names containing slashes, I don't think anybody uses them, and we have considered disallowing them, mainly because of this very issue: it makes "$remote/$branch" parsing (even more) ambiguous) 2. See if a remote called $remote exists. If it does, suggest to the user to run "git fetch $remote". If $remote does not exist, leave the current error message in place. Hope this helps, ...Johan -- Johan Herland, <johan@xxxxxxxxxxx> www.herland.net -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html