{"thread":{"id":"44301","subject":"Re: Automagic `git checkout branchname` mysteriously fails","startedAt":"2016-10-16T00:33:23Z","lastAt":"2016-10-17T11:40:27Z","messageCount":4,"participants":["Martin Langhoff","Kevin Daudt","Duy Nguyen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"304186","messageId":"CACPiFCJFXGmsJX97kQuA2h3trVX7L3SacwKrD4mpEU5SPxkLAA@mail.gmail.com","threadId":"44301","inReplyTo":"20161014205842.GA6350@ikke.info","subject":"Re: Automagic `git checkout branchname` mysteriously fails","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2016-10-14T21:06:48Z","receivedAt":"2016-10-16T00:33:23Z","isPatch":false,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"On Fri, Oct 14, 2016 at 4:58 PM, Kevin Daudt <me@ikke.info> wrote:\n> Correct, this only works when it's unambiguous what branch you actually\n> mean.\n\nThat's not surprising, but there isn't a warning. IMHO, finding\nseveral branch matches is a strong indication that it'll be worth\nreporting to the user that the DWIM machinery got hits, but couldn't\nwork it out.\n\nI get that process is not geared towards making a friendly msg easy,\nbut we could print to stderr something like:\n\n \"branch\" matches more than one candidate ref, cannot choose automatically.\n If you mean to check out a branch, try git branch command.\n If you mean to check out a file, use -- before the pathname to\n disambiguate.\n\nand then continue with execution. With a bit of wordsmithing, the msg\ncan be made to be helpful in the various failure modes.\n\ncheers,\n\n\nm\n-- \n martin.langhoff@gmail.com\n - ask interesting questions  ~  http://linkedin.com/in/martinlanghoff\n - don't be distracted        ~  http://github.com/martin-langhoff\n   by shiny stuff\n"},{"id":"304187","messageId":"20161014205842.GA6350@ikke.info","threadId":"44301","inReplyTo":"CACPiFC+8+wVEcDt9JZgTW1dwCCFKszyXD6ysDxNQorcNkom7Lw@mail.gmail.com","subject":"Re: Automagic `git checkout branchname` mysteriously fails","fromName":"Kevin Daudt","fromEmail":"me@ikke.info","sentAt":"2016-10-14T20:58:42Z","receivedAt":"2016-10-16T00:33:24Z","isPatch":false,"sender":{"key":"me@ikke.info","avatar":"https://avatars.githubusercontent.com/u/135698?v=4"},"body":"On Fri, Oct 14, 2016 at 04:25:49PM -0400, Martin Langhoff wrote:\n> In a (private) repo project I have, I recently tried (and failed) to do:\n> \n>   git checkout v4.1-support\n> \n> getting a \"pathspec did not match any files known to git\" error.\n> \n> There's an origin/v4.1-support, there is no v4.1-support \"local\"\n> branch. Creating the tracking branch explicitly worked.\n> \n> Other similar branches in existence upstream did work. Autocomplete\n> matched git's own behaviour for this; where git checkout foo woudn't\n> work, autocomplete would not offer a completion.\n> \n> Why is this?\n> \n> One theory I have not explored is that I have other remotes, and some\n> have a v4.1-support branch. If that's the case, the error message is\n> not very helpful, and could be improved.\n> \n> git --version\n> 2.7.4\n> \n> DWIM in git is remarkably good, even addictive... when it works :-)\n> \n> cheers,\n> \n\nCorrect, this only works when it's unambiguous what branch you actually\nmean.\n\nif remote_a/branch and remote_b/branch exists, git cannot guess which\none you actually mean.\n\nThe message you get is because git checkout can be followed by several\nthings. Either a branch/commit or a file. Git complaining it cannot find\na file with that name is because it has exhausted all other options.\n\nI do agree that message could be a bit more clear.\n"},{"id":"304192","messageId":"CACPiFC+8+wVEcDt9JZgTW1dwCCFKszyXD6ysDxNQorcNkom7Lw@mail.gmail.com","threadId":"44301","inReplyTo":null,"subject":"Automagic `git checkout branchname` mysteriously fails","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2016-10-14T20:25:49Z","receivedAt":"2016-10-16T00:33:41Z","isPatch":false,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"In a (private) repo project I have, I recently tried (and failed) to do:\n\n  git checkout v4.1-support\n\ngetting a \"pathspec did not match any files known to git\" error.\n\nThere's an origin/v4.1-support, there is no v4.1-support \"local\"\nbranch. Creating the tracking branch explicitly worked.\n\nOther similar branches in existence upstream did work. Autocomplete\nmatched git's own behaviour for this; where git checkout foo woudn't\nwork, autocomplete would not offer a completion.\n\nWhy is this?\n\nOne theory I have not explored is that I have other remotes, and some\nhave a v4.1-support branch. If that's the case, the error message is\nnot very helpful, and could be improved.\n\ngit --version\n2.7.4\n\nDWIM in git is remarkably good, even addictive... when it works :-)\n\ncheers,\n\n\n\nm\n-- \n martin.langhoff@gmail.com\n - ask interesting questions  ~  http://linkedin.com/in/martinlanghoff\n - don't be distracted        ~  http://github.com/martin-langhoff\n   by shiny stuff\n"},{"id":"304272","messageId":"CACsJy8A252mU8hgp2d+LQ8vku1w-sL9eP=t=G1AX61WJi8SUfA@mail.gmail.com","threadId":"44301","inReplyTo":"CACPiFCJFXGmsJX97kQuA2h3trVX7L3SacwKrD4mpEU5SPxkLAA@mail.gmail.com","subject":"Re: Automagic `git checkout branchname` mysteriously fails","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2016-10-17T11:39:46Z","receivedAt":"2016-10-17T11:40:27Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Sat, Oct 15, 2016 at 4:06 AM, Martin Langhoff\n<martin.langhoff@gmail.com> wrote:\n> On Fri, Oct 14, 2016 at 4:58 PM, Kevin Daudt <me@ikke.info> wrote:\n>> Correct, this only works when it's unambiguous what branch you actually\n>> mean.\n>\n> That's not surprising, but there isn't a warning. IMHO, finding\n> several branch matches is a strong indication that it'll be worth\n> reporting to the user that the DWIM machinery got hits, but couldn't\n> work it out.\n>\n> I get that process is not geared towards making a friendly msg easy,\n> but we could print to stderr something like:\n>\n>  \"branch\" matches more than one candidate ref, cannot choose automatically.\n>  If you mean to check out a branch, try git branch command.\n>  If you mean to check out a file, use -- before the pathname to\n>  disambiguate.\n\nOr even better, list all ambiguous candidates like Jeff did for\nambiguous short SHA-1 in 1ffa26c (get_short_sha1: list ambiguous\nobjects on error - 2016-09-26).There were a few occasions I was\nconfused by ambiguous refs and displaying them all would help me see\nwhat problem was much faster.\n-- \nDuy\n"}]}