Re: git checkout foo is getting confused by folder named foo
On 25 September 2013 22:01, Matthieu Moy matthieu@grenoble-inp.fr wrote: Jona Christopher Sahnwaldt j...@sahnwaldt.de writes: Yes, I think the rules for the short form (the guessing when there's no --) should be made simpler, or maybe the guessing should be dropped altogether. I don't know. I don't know git well enough to be able to be more specific. I just find the current behavior very confusing. It can hardly be simpler (in the sense behavior that can be described with fewer words), but it could be tightened to be safer. When a remote branch $foo exists, a local branch $foo does not, and a file $foo does, then git checkout $foo rather likely means I want to use git checkout's DWIM and create local branch $foo, but it currently means to Git checkout file foo from the index. It would make sense to die here, and require the use of --. That sounds good. A rule like when A is true, B is false, and C is true, then X is probably too complex to be useful. It's probably better to give up and say sorry, I DKWYM (don't know what you mean). :-) There are a few more ideas, opinions, discussions about all this at http://stackoverflow.com/questions/18833617/why-does-git-checkout-remote-branchname-not-create-new-tracking-branch especially in the comments. Cheers, JC No time to write a patch for this. Any volunteer? -- Matthieu Moy http://www-verimag.imag.fr/~moy/ -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: git checkout foo is getting confused by folder named foo
On 25 September 2013 04:51, David Aguilar dav...@gmail.com wrote: On Tue, Sep 24, 2013 at 2:07 PM, Jona Christopher Sahnwaldt j...@sahnwaldt.de wrote: Hi, maybe this has already been reported, but I didn't find it in the mail archive. If I understand correctly, after I clone a repo, I should be able to switch to branch foo just by running git checkout foo This doesn't seem to work if a folder called foo exists in the root of the repo. git checkout foo -- Thanks for the suggestion, but it doesn't work for me. With both 1.7.9.5 and 1.8.3.2, I get this: $ git checkout wiktionary -- fatal: invalid reference: wiktionary When I try the full branch name: $ git checkout origin/wiktionary -- Note: checking out 'origin/wiktionary'. You are in 'detached HEAD' state. You can [...] :-( Christopher The double-dash at the end disambiguates between refs and paths. You can use that trick on any command that accepts refspec (branches, tags, etc) and pathspec (path patterns). -- David -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: git checkout foo is getting confused by folder named foo
Jona Christopher Sahnwaldt j...@sahnwaldt.de writes: On 25 September 2013 04:51, David Aguilar dav...@gmail.com wrote: On Tue, Sep 24, 2013 at 2:07 PM, Jona Christopher Sahnwaldt j...@sahnwaldt.de wrote: Hi, maybe this has already been reported, but I didn't find it in the mail archive. If I understand correctly, after I clone a repo, I should be able to switch to branch foo just by running git checkout foo This doesn't seem to work if a folder called foo exists in the root of the repo. git checkout foo -- Thanks for the suggestion, but it doesn't work for me. With both 1.7.9.5 and 1.8.3.2, I get this: $ git checkout wiktionary -- fatal: invalid reference: wiktionary OK, what happens is that git checkout wiktionary is actually a shorthand for git checkout -b wiktionary --track origin/wiktionary. In other words, it does not only checkout the branch, but it creates a local branch with the right name, and checks it out. The -- disables this shorthand. I'd consider this as a bug. I've just sent a patch to try to fix this. When I try the full branch name: $ git checkout origin/wiktionary -- Note: checking out 'origin/wiktionary'. You are in 'detached HEAD' state. You can [...] This actually checks out the right commit, but does not create a local branch. That's not a very desirable solution. In short, this should do the trick: git checkout -b wiktionary --track origin/wiktionary -- Matthieu Moy http://www-verimag.imag.fr/~moy/ -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: git checkout foo is getting confused by folder named foo
Jona Christopher Sahnwaldt j...@sahnwaldt.de writes: Hi everyone, tl;dr: The short form git checkout foo is a mess. There's simply too much DWIM magic going on. There are no comprehensible rules how it decides if foo is a pathspec or a refspec. There is a very simple rule: What's on the left hand side of -- are refs, what's on the right hand side are paths. When you don't use --, then Git tries to guess, and fails whenever there's an ambiguity. OK, what happens is that git checkout wiktionary is actually a shorthand for git checkout -b wiktionary --track origin/wiktionary. No, it isn't. What I meant was that the short form advised by people were _meant_ to be a shorthand. Let's consider several scenarios: I don't get your point. Is the overly long list a way of complaining? Are you suggesting a change? What do you think about the change I'm proposing? -- Matthieu Moy http://www-verimag.imag.fr/~moy/ -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: git checkout foo is getting confused by folder named foo
On 25 September 2013 21:12, Matthieu Moy matthieu@grenoble-inp.fr wrote: Jona Christopher Sahnwaldt j...@sahnwaldt.de writes: Hi everyone, tl;dr: The short form git checkout foo is a mess. There's simply too much DWIM magic going on. There are no comprehensible rules how it decides if foo is a pathspec or a refspec. There is a very simple rule: What's on the left hand side of -- are refs, what's on the right hand side are paths. When you don't use --, then Git tries to guess, and fails whenever there's an ambiguity. That's the case I'm concerned with. And I think the guessing confuses users in many cases. It certainly has confused me. OK, what happens is that git checkout wiktionary is actually a shorthand for git checkout -b wiktionary --track origin/wiktionary. No, it isn't. What I meant was that the short form advised by people were _meant_ to be a shorthand. Let's consider several scenarios: I don't get your point. Is the overly long list a way of complaining? It's a way of showing that human beings can't understand git's guesswork. :-) It was also a (failed) attempt to understand the rules of this heuristic. And an attempt to show the developers that the rules have gotten out of hand. Are you suggesting a change? Yes, I think the rules for the short form (the guessing when there's no --) should be made simpler, or maybe the guessing should be dropped altogether. I don't know. I don't know git well enough to be able to be more specific. I just find the current behavior very confusing. What do you think about the change I'm proposing? I don't know. It looks like it's not really addressing my specific problem, because as far as I understand it only applies when there is a --. But again, I don't know git well enough. Anyway, thanks for your work. I'm sorry I can't provide more useful input. This short form of checkout is just a small feature. I guess I'm bikeshedding here. Cheers, JC -- Matthieu Moy http://www-verimag.imag.fr/~moy/ -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: git checkout foo is getting confused by folder named foo
Jona Christopher Sahnwaldt j...@sahnwaldt.de writes: Yes, I think the rules for the short form (the guessing when there's no --) should be made simpler, or maybe the guessing should be dropped altogether. I don't know. I don't know git well enough to be able to be more specific. I just find the current behavior very confusing. It can hardly be simpler (in the sense behavior that can be described with fewer words), but it could be tightened to be safer. When a remote branch $foo exists, a local branch $foo does not, and a file $foo does, then git checkout $foo rather likely means I want to use git checkout's DWIM and create local branch $foo, but it currently means to Git checkout file foo from the index. It would make sense to die here, and require the use of --. No time to write a patch for this. Any volunteer? -- Matthieu Moy http://www-verimag.imag.fr/~moy/ -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
git checkout foo is getting confused by folder named foo
Hi, maybe this has already been reported, but I didn't find it in the mail archive. If I understand correctly, after I clone a repo, I should be able to switch to branch foo just by running git checkout foo This doesn't seem to work if a folder called foo exists in the root of the repo. I got the same behavior with git 1.8.3.2 on a Mac and git 1.7.9.5 on Linux. Steps to reproduce: git clone https://github.com/dbpedia/extraction-framework.git cd extraction-framework/ First the happy path - there is a remote branch live-dev, but no folder extraction-framework/live-dev: git checkout live-dev Response: Branch live-dev set up to track remote branch live-dev from origin. Switched to a new branch 'live-dev' Fine! Now the unhappy path - there is a branch wiktionary, but also a folder extraction-framework/wiktionary: git checkout wiktionary Nothing - no response, no changes to working tree. .git/index seems to be modified though. Slightly different - cd to some folder, try checkout again: cd mappings git checkout wiktionary Response: error: pathspec 'wiktionary' did not match any file(s) known to git. My workaround is that when I switch to a branch for the first time, I have to call git checkout -t -b wiktionary --track origin/wiktionary Response: Branch wiktionary set up to track remote branch wiktionary from origin. Switched to a new branch 'wiktionary' Looks good. After that, I can switch back and forth between branches just by git checkout wiktionary / git checkout master. Cheers, Christopher -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: git checkout foo is getting confused by folder named foo
On Tue, Sep 24, 2013 at 2:07 PM, Jona Christopher Sahnwaldt j...@sahnwaldt.de wrote: Hi, maybe this has already been reported, but I didn't find it in the mail archive. If I understand correctly, after I clone a repo, I should be able to switch to branch foo just by running git checkout foo This doesn't seem to work if a folder called foo exists in the root of the repo. git checkout foo -- The double-dash at the end disambiguates between refs and paths. You can use that trick on any command that accepts refspec (branches, tags, etc) and pathspec (path patterns). -- David -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: git checkout foo is getting confused by folder named foo
David Aguilar dav...@gmail.com writes: On Tue, Sep 24, 2013 at 2:07 PM, Jona Christopher Sahnwaldt j...@sahnwaldt.de wrote: Hi, maybe this has already been reported, but I didn't find it in the mail archive. If I understand correctly, after I clone a repo, I should be able to switch to branch foo just by running git checkout foo This doesn't seem to work if a folder called foo exists in the root of the repo. git checkout foo -- The double-dash at the end disambiguates between refs and paths. You can use that trick on any command that accepts refspec (branches, tags, etc) and pathspec (path patterns). I was going to reply with similar advice, but I actually tried it on the example repo and it didn't work. Apparently it doesn't interoperate properly with the functionality that guesses when you're trying to check out a remote branch and creates an equivalently named local branch. [2] fs@erdos /tmp $ git clone https://github.com/dbpedia/extraction-framework.git Cloning into 'extraction-framework'... remote: Counting objects: 33513, done. remote: Compressing objects: 100% (6633/6633), done. remote: Total 33513 (delta 19000), reused 32922 (delta 18436) Receiving objects: 100% (33513/33513), 23.48 MiB | 747.00 KiB/s, done. Resolving deltas: 100% (19000/19000), done. Checking connectivity... done [2] fs@erdos /tmp $ cd extraction-framework/ [2] fs@erdos /tmp/extraction-framework $ git checkout live-dev -- fatal: invalid reference: live-dev [2] fs@erdos /tmp/extraction-framework $ git checkout live-dev Branch live-dev set up to track remote branch live-dev from origin. Switched to a new branch 'live-dev' [2] fs@erdos /tmp/extraction-framework $ git checkout master Switched to branch 'master' [2] fs@erdos /tmp/extraction-framework $ git checkout wiktionary [2] fs@erdos /tmp/extraction-framework $ git branch live-dev * master [2] fs@erdos /tmp/extraction-framework $ git checkout wiktionary -- fatal: invalid reference: wiktionary -Keshav -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: git checkout foo is getting confused by folder named foo
On Wed, Sep 25, 2013 at 10:13 AM, Keshav Kini keshav.k...@gmail.com wrote: [2] fs@erdos /tmp/extraction-framework $ git checkout wiktionary -- fatal: invalid reference: wiktionary It may work if we demote this from fatal to error warning so the dwim logic in checkout has a chance to try differently, I think. -- Duy -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html