{"thread":{"id":"28675","subject":"Git shouldn't allow to push a new branch called HEAD","startedAt":"2011-10-14T11:31:17Z","lastAt":"2011-11-14T20:26:42Z","messageCount":8,"participants":["Daniele Segato","P Rouleau","Michael Haggerty","Jeff King","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"177633","messageId":"1318591877.2938.20.camel@mastroc3.mobc3.local","threadId":"28675","inReplyTo":null,"subject":"Git shouldn't allow to push a new branch called HEAD","fromName":"Daniele Segato","fromEmail":"daniele.segato@gmail.com","sentAt":"2011-10-14T11:31:17Z","receivedAt":"2011-10-14T11:31:17Z","isPatch":false,"sender":{"key":"daniele.segato@gmail.com","avatar":"https://avatars.githubusercontent.com/u/469948?v=4"},"body":"Hi all,\n\n\nfollowing from a discussion in IRC freenode #git between me, sitaram an\nshruggar\n\n\nstep to reproduce:\n\n$ mkdir /tmp/gitbug\n$ cd /tmp/gitbug/\n\n$ # create a fake remote repo\n$ git init --bare remote.git\n\n$ # clone it with the user that will generate the bug\n$ git clone remote.git buggenerator\n$ cd buggenerator/\n$ touch whatever\n$ git add .\n$ git commit -m \"first commit\"\n$ git push origin master \n\n$ # now clone the same repo the other guy is the \"victim\" of this issue\n$ cd ..\n$ git clone remote.git victim\n\n$ # time to create the remote HEAD branch\n$ cd buggenerator/\n$ git push origin HEAD:HEAD\n\n$ # the remote refs has been created!\n$ git ls-remote\n\n$ # another commit\n$ echo 'any change' >> whatever \n$ git commit -a -m \"some change\"\n$ git push origin master \n\n$ # the refs/heads/HEAD is still where it was\n$ git ls-remote\n\n$ # now from the victim perspective\n$ cd ../victim/\n\n$ # every time executing a fetch he will get a force update\n$ # or maybe even an error, seen it my real repo, don't know how\n$ # to reproduce\n$ git fetch \n$ git fetch \n$ git ls-remote\n$ git fetch \n$ git ls-remote\n$ git branch -a\n\n\n\nfull console log:\n\nmastro@mastroc3 ~  $ mkdir /tmp/gitbug\nmastro@mastroc3 ~  $ cd /tmp/gitbug/\nmastro@mastroc3 /tmp/gitbug  $ git init --bare remote.git\nInitialized empty Git repository in /tmp/gitbug/remote.git/\nmastro@mastroc3 /tmp/gitbug  $ git clone remote.git buggenerator\nCloning into buggenerator...\ndone.\nwarning: You appear to have cloned an empty repository.\nmastro@mastroc3 /tmp/gitbug  $ cd buggenerator/\nmastro@mastroc3 /tmp/gitbug/buggenerator (master #) $ touch whatever\nmastro@mastroc3 /tmp/gitbug/buggenerator (master #) $ git add .\nmastro@mastroc3 /tmp/gitbug/buggenerator (master #) $ git commit -m\n\"first commit\"\n[master (root-commit) 11d0a12] first commit\n 0 files changed, 0 insertions(+), 0 deletions(-)\n create mode 100644 whatever\nmastro@mastroc3 /tmp/gitbug/buggenerator (master) $ git push origin\nmaster \nCounting objects: 3, done.\nWriting objects: 100% (3/3), 213 bytes, done.\nTotal 3 (delta 0), reused 0 (delta 0)\nUnpacking objects: 100% (3/3), done.\nTo /tmp/gitbug/remote.git\n * [new branch]      master -> master\nmastro@mastroc3 /tmp/gitbug/buggenerator (master) $ cd ..\nmastro@mastroc3 /tmp/gitbug  $ git clone remote.git victim\nCloning into victim...\ndone.\nmastro@mastroc3 /tmp/gitbug  $ cd buggenerator/\n\n# now creating the HEAD remote branch\n\nmastro@mastroc3 /tmp/gitbug/buggenerator (master) $ git push origin\nHEAD:HEAD\nTotal 0 (delta 0), reused 0 (delta 0)\nTo /tmp/gitbug/remote.git\n * [new branch]      HEAD -> HEAD\nmastro@mastroc3 /tmp/gitbug/buggenerator (master) $ git ls-remote\nFrom /tmp/gitbug/remote.git\n11d0a122125e50e78c7aa4aa81a3d6090dba648e\tHEAD\n11d0a122125e50e78c7aa4aa81a3d6090dba648e\trefs/heads/HEAD <-----\nshouldn't be there!\n11d0a122125e50e78c7aa4aa81a3d6090dba648e\trefs/heads/master\nmastro@mastroc3 /tmp/gitbug/buggenerator (master) $ echo 'any change' >>\nwhatever \nmastro@mastroc3 /tmp/gitbug/buggenerator (master *) $ git commit -a -m\n\"some change\"\n[master 77852ef] some change\n 1 files changed, 1 insertions(+), 0 deletions(-)\nmastro@mastroc3 /tmp/gitbug/buggenerator (master) $ git push origin\nmaster \nCounting objects: 5, done.\nWriting objects: 100% (3/3), 253 bytes, done.\nTotal 3 (delta 0), reused 0 (delta 0)\nUnpacking objects: 100% (3/3), done.\nTo /tmp/gitbug/remote.git\n   11d0a12..77852ef  master -> master\nmastro@mastroc3 /tmp/gitbug/buggenerator (master) $ git ls-remote\nFrom /tmp/gitbug/remote.git\n77852effa972187d60d4c75145198991f1c0f868\tHEAD\n11d0a122125e50e78c7aa4aa81a3d6090dba648e\trefs/heads/HEAD\n77852effa972187d60d4c75145198991f1c0f868\trefs/heads/master\nmastro@mastroc3 /tmp/gitbug/buggenerator (master) $ cd ../victim/\nmastro@mastroc3 /tmp/gitbug/victim (master) $ git fetch \nremote: Counting objects: 5, done.\nremote: Total 3 (delta 0), reused 0 (delta 0)\nUnpacking objects: 100% (3/3), done.\nFrom /tmp/gitbug/remote\n   11d0a12..77852ef  master     -> origin/master\nmastro@mastroc3 /tmp/gitbug/victim (master) $ git fetch \nFrom /tmp/gitbug/remote\n + 77852ef...11d0a12 HEAD       -> origin/HEAD  (forced update)\nmastro@mastroc3 /tmp/gitbug/victim (master) $ git fetch \nFrom /tmp/gitbug/remote\n   11d0a12..77852ef  master     -> origin/master\nmastro@mastroc3 /tmp/gitbug/victim (master) $ git ls-remote\nFrom /tmp/gitbug/remote.git\n77852effa972187d60d4c75145198991f1c0f868\tHEAD\n11d0a122125e50e78c7aa4aa81a3d6090dba648e\trefs/heads/HEAD\n77852effa972187d60d4c75145198991f1c0f868\trefs/heads/master\nmastro@mastroc3 /tmp/gitbug/victim (master) $ git fetch \nFrom /tmp/gitbug/remote\n + 77852ef...11d0a12 HEAD       -> origin/HEAD  (forced update)\nmastro@mastroc3 /tmp/gitbug/victim (master) $ git ls-remote\nFrom /tmp/gitbug/remote.git\n77852effa972187d60d4c75145198991f1c0f868\tHEAD\n11d0a122125e50e78c7aa4aa81a3d6090dba648e\trefs/heads/HEAD\n77852effa972187d60d4c75145198991f1c0f868\trefs/heads/master\nmastro@mastroc3 /tmp/gitbug/victim (master) $ git branch -a\n* master\n  remotes/origin/HEAD -> origin/master\n  remotes/origin/master\n\n\n\n\nthis can be fixed with:\n\ngit push --delete origin HEAD\n(or git push origin :HEAD)\n\nthen\ngit remote prune origin\n\n\n\nBut I think that git shouldn't allow the remote HEAD reference to be\ncreated in the first place\n\nregards,\nDaniele\n"},{"id":"177634","messageId":"1318592153.2938.21.camel@mastroc3.mobc3.local","threadId":"28675","inReplyTo":"1318591877.2938.20.camel@mastroc3.mobc3.local","subject":"Re: Git shouldn't allow to push a new branch called HEAD","fromName":"Daniele Segato","fromEmail":"daniele.bilug@gmail.com","sentAt":"2011-10-14T11:35:53Z","receivedAt":"2011-10-14T11:35:53Z","isPatch":false,"sender":{"key":"daniele.bilug@gmail.com","avatar":null},"body":"On Fri, 2011-10-14 at 13:31 +0200, Daniele Segato wrote:\n> Hi all,\n> \n> \n> following from a discussion in IRC freenode #git between me, sitaram an\n> shruggar\n> \n> \n> step to reproduce:\n> \n> $ mkdir /tmp/gitbug\n> $ cd /tmp/gitbug/\n> \n> $ # create a fake remote repo\n> $ git init --bare remote.git\n> \n> $ # clone it with the user that will generate the bug\n> $ git clone remote.git buggenerator\n> $ cd buggenerator/\n> $ touch whatever\n> $ git add .\n> $ git commit -m \"first commit\"\n> $ git push origin master \n> \n> $ # now clone the same repo the other guy is the \"victim\" of this issue\n> $ cd ..\n> $ git clone remote.git victim\n> \n> $ # time to create the remote HEAD branch\n> $ cd buggenerator/\n> $ git push origin HEAD:HEAD\n> \n> $ # the remote refs has been created!\n> $ git ls-remote\n> \n> $ # another commit\n> $ echo 'any change' >> whatever \n> $ git commit -a -m \"some change\"\n> $ git push origin master \n> \n> $ # the refs/heads/HEAD is still where it was\n> $ git ls-remote\n> \n> $ # now from the victim perspective\n> $ cd ../victim/\n> \n> $ # every time executing a fetch he will get a force update\n> $ # or maybe even an error, seen it my real repo, don't know how\n> $ # to reproduce\n> $ git fetch \n> $ git fetch \n> $ git ls-remote\n> $ git fetch \n> $ git ls-remote\n> $ git branch -a\n\nThis should also help understanding what happen in the \"victim\" local\nrepo at every fetch:\n\nmastro@mastroc3 /tmp/gitbug/victim (master) $ git br -av\n* master                11d0a12 [behind 1] first commit\n  remotes/origin/HEAD   -> origin/master\n  remotes/origin/master 77852ef some change\nmastro@mastroc3 /tmp/gitbug/victim (master) $ git fetch \nFrom /tmp/gitbug/remote\n + 77852ef...11d0a12 HEAD       -> origin/HEAD  (forced update)\nmastro@mastroc3 /tmp/gitbug/victim (master) $ git br -av\n* master                11d0a12 first commit\n  remotes/origin/HEAD   -> origin/master\n  remotes/origin/master 11d0a12 first commit\n\n\nregards,\nDaniele\n"},{"id":"177699","messageId":"loom.20111015T004856-72@post.gmane.org","threadId":"28675","inReplyTo":"1318591877.2938.20.camel@mastroc3.mobc3.local","subject":"Re: Git shouldn't allow to push a new branch called HEAD","fromName":"P Rouleau","fromEmail":"prouleau72@gmail.com","sentAt":"2011-10-14T23:00:04Z","receivedAt":"2011-10-14T23:00:04Z","isPatch":false,"sender":{"key":"prouleau72@gmail.com","avatar":"https://gravatar.com/avatar/8779e3894834cde1e03b6e5ede343580eb982eca9b5b16b0c492179048818607?d=mp&s=160"},"body":"Daniele Segato <daniele.segato <at> gmail.com> writes:\n\n> \n> Hi all,\n> \n> following from a discussion in IRC freenode #git between me, sitaram an\n> shruggar\n> \n> step to reproduce:\n> \n> $ # time to create the remote HEAD branch\n> $ cd buggenerator/\n> $ git push origin HEAD:HEAD\n> \n> But I think that git shouldn't allow the remote HEAD reference to be\n> created in the first place\n\nMaybe git should also refuse to create a local branch named HEAD. I made a\nmistake recently where I used something likes this:\n\nfor B in $(git branch -a|grep \"remotes/origin/\"); do git co -t $B ; done\n\nAfter that, git st was giving a warning about an ambiguous HEAD ref. Hopefully,\na simple \"git branch -d HEAD\" fixed it once I found the problem.\n\nP.Rouleau\n"},{"id":"179415","messageId":"1321261662.2941.13.camel@mastroc3.mobc3.local","threadId":"28675","inReplyTo":"1318592153.2938.21.camel@mastroc3.mobc3.local","subject":"Re: Git shouldn't allow to push a new branch called HEAD","fromName":"Daniele Segato","fromEmail":"daniele.bilug@gmail.com","sentAt":"2011-11-14T09:07:42Z","receivedAt":"2011-11-14T09:07:42Z","isPatch":false,"sender":{"key":"daniele.bilug@gmail.com","avatar":null},"body":"On Fri, 2011-10-14 at 13:35 +0200, Daniele Segato wrote:\n> On Fri, 2011-10-14 at 13:31 +0200, Daniele Segato wrote:\n> > Hi all,\n> > \n> > \n> > following from a discussion in IRC freenode #git between me, sitaram an\n> > shruggar\n> > \n> > \n> > step to reproduce:\n> > \n> > $ mkdir /tmp/gitbug\n> > $ cd /tmp/gitbug/\n> > \n> > $ # create a fake remote repo\n> > $ git init --bare remote.git\n> > \n> > $ # clone it with the user that will generate the bug\n> > $ git clone remote.git buggenerator\n> > $ cd buggenerator/\n> > $ touch whatever\n> > $ git add .\n> > $ git commit -m \"first commit\"\n> > $ git push origin master \n> > \n> > $ # now clone the same repo the other guy is the \"victim\" of this issue\n> > $ cd ..\n> > $ git clone remote.git victim\n> > \n> > $ # time to create the remote HEAD branch\n> > $ cd buggenerator/\n> > $ git push origin HEAD:HEAD\n> > \n> > $ # the remote refs has been created!\n> > $ git ls-remote\n> > \n> > $ # another commit\n> > $ echo 'any change' >> whatever \n> > $ git commit -a -m \"some change\"\n> > $ git push origin master \n> > \n> > $ # the refs/heads/HEAD is still where it was\n> > $ git ls-remote\n> > \n> > $ # now from the victim perspective\n> > $ cd ../victim/\n> > \n> > $ # every time executing a fetch he will get a force update\n> > $ # or maybe even an error, seen it my real repo, don't know how\n> > $ # to reproduce\n> > $ git fetch \n> > $ git fetch \n> > $ git ls-remote\n> > $ git fetch \n> > $ git ls-remote\n> > $ git branch -a\n> \n> This should also help understanding what happen in the \"victim\" local\n> repo at every fetch:\n> \n> mastro@mastroc3 /tmp/gitbug/victim (master) $ git br -av\n> * master                11d0a12 [behind 1] first commit\n>   remotes/origin/HEAD   -> origin/master\n>   remotes/origin/master 77852ef some change\n> mastro@mastroc3 /tmp/gitbug/victim (master) $ git fetch \n> From /tmp/gitbug/remote\n>  + 77852ef...11d0a12 HEAD       -> origin/HEAD  (forced update)\n> mastro@mastroc3 /tmp/gitbug/victim (master) $ git br -av\n> * master                11d0a12 first commit\n>   remotes/origin/HEAD   -> origin/master\n>   remotes/origin/master 11d0a12 first commit\n\n\nHi again,\n\nI'm aware my request has been ignored for a good reason but I would\nappreciate someone stepping in and explaining to me why this is not a\nbug or why it has been ignored.\n\nThanks.\n\nRegards,\nDaniele Segato\n"},{"id":"179418","messageId":"4EC0F15A.9010502@alum.mit.edu","threadId":"28675","inReplyTo":"1321261662.2941.13.camel@mastroc3.mobc3.local","subject":"Re: Git shouldn't allow to push a new branch called HEAD","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2011-11-14T10:45:46Z","receivedAt":"2011-11-14T10:45:46Z","isPatch":false,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"On 11/14/2011 10:07 AM, Daniele Segato wrote:\n> On Fri, 2011-10-14 at 13:35 +0200, Daniele Segato wrote:\n>> On Fri, 2011-10-14 at 13:31 +0200, Daniele Segato wrote:\n>>> following from a discussion in IRC freenode #git between me, sitaram an\n>>> shruggar\n>>>\n>>>\n>>> step to reproduce:\n>>>\n>>> $ mkdir /tmp/gitbug\n>>> $ cd /tmp/gitbug/\n>>>\n>>> $ # create a fake remote repo\n>>> $ git init --bare remote.git\n>>>\n>>> $ # clone it with the user that will generate the bug\n>>> $ git clone remote.git buggenerator\n>>> $ cd buggenerator/\n>>> $ touch whatever\n>>> $ git add .\n>>> $ git commit -m \"first commit\"\n>>> $ git push origin master \n>>>\n>>> $ # now clone the same repo the other guy is the \"victim\" of this issue\n>>> $ cd ..\n>>> $ git clone remote.git victim\n>>>\n>>> $ # time to create the remote HEAD branch\n>>> $ cd buggenerator/\n>>> $ git push origin HEAD:HEAD\n>>>\n>>> $ # the remote refs has been created!\n>>> $ git ls-remote\n>>>\n>>> $ # another commit\n>>> $ echo 'any change' >> whatever \n>>> $ git commit -a -m \"some change\"\n>>> $ git push origin master \n>>>\n>>> $ # the refs/heads/HEAD is still where it was\n>>> $ git ls-remote\n>>>\n>>> $ # now from the victim perspective\n>>> $ cd ../victim/\n>>>\n>>> $ # every time executing a fetch he will get a force update\n>>> $ # or maybe even an error, seen it my real repo, don't know how\n>>> $ # to reproduce\n>>> $ git fetch \n>>> $ git fetch \n>>> $ git ls-remote\n>>> $ git fetch \n>>> $ git ls-remote\n>>> $ git branch -a\n>>\n>> This should also help understanding what happen in the \"victim\" local\n>> repo at every fetch:\n>>\n>> mastro@mastroc3 /tmp/gitbug/victim (master) $ git br -av\n>> * master                11d0a12 [behind 1] first commit\n>>   remotes/origin/HEAD   -> origin/master\n>>   remotes/origin/master 77852ef some change\n>> mastro@mastroc3 /tmp/gitbug/victim (master) $ git fetch \n>> From /tmp/gitbug/remote\n>>  + 77852ef...11d0a12 HEAD       -> origin/HEAD  (forced update)\n>> mastro@mastroc3 /tmp/gitbug/victim (master) $ git br -av\n>> * master                11d0a12 first commit\n>>   remotes/origin/HEAD   -> origin/master\n>>   remotes/origin/master 11d0a12 first commit\n> \n> I'm aware my request has been ignored for a good reason but I would\n> appreciate someone stepping in and explaining to me why this is not a\n> bug or why it has been ignored.\n\nThis is a nice little bug.\n\nI'm sure that you noticed that running \"git fetch\" repeatedly from the\n\"victim\" repository alternates between two behaviors (I'm using 1.7.7.2):\n\n> $ git fetch\n> From /home/mhagger/tmp/gitbug/remote\n>  + 6bf3df1...4c9ebba HEAD       -> origin/HEAD  (forced update)\n> $ git for-each-ref\n> 4c9ebba3c0618bd6238a810013da4a8cd4f2213b commit\trefs/heads/master\n> 4c9ebba3c0618bd6238a810013da4a8cd4f2213b commit\trefs/remotes/origin/HEAD\n> 4c9ebba3c0618bd6238a810013da4a8cd4f2213b commit\trefs/remotes/origin/master\n> $ git fetch\n> From /home/mhagger/tmp/gitbug/remote\n>    4c9ebba..6bf3df1  master     -> origin/master\n> $ git for-each-ref\n> 4c9ebba3c0618bd6238a810013da4a8cd4f2213b commit\trefs/heads/master\n> 6bf3df178cd92ca72625ae5bda9206c4333fd807 commit\trefs/remotes/origin/HEAD\n> 6bf3df178cd92ca72625ae5bda9206c4333fd807 commit\trefs/remotes/origin/master\n> $ git fetch\n> From /home/mhagger/tmp/gitbug/remote\n>  + 6bf3df1...4c9ebba HEAD       -> origin/HEAD  (forced update)\n> $ git fetch\n> From /home/mhagger/tmp/gitbug/remote\n>    4c9ebba..6bf3df1  master     -> origin/master\n\nThe whole time, victim's .git/HEAD contains \"ref: refs/heads/master\",\n.git/refs/remotes/origin/HEAD contains \"ref:\nrefs/remotes/origin/master\", and its packed-refs file contains\n\n# pack-refs with: peeled\n4c9ebba3c0618bd6238a810013da4a8cd4f2213b refs/remotes/origin/master\n\nIn \"remote.git\", refs/heads/HEAD contains not a symbolic reference but\nthe explicit SHA1 \"4c9ebba...\".  This is of course not affected by\nrunning \"git fetch\" in the \"victim\" tree.  Deleting this file makes the\nproblem go away.\n\n\nGiven that this problem seems to be in the remote protocol rather than\nin the refs API, I think I'll stop working on this.  I hope that my\nobservations are helpful to somebody.\n\nMichael\n\n-- \nMichael Haggerty\nmhagger@alum.mit.edu\nhttp://softwareswirl.blogspot.com/\n"},{"id":"179421","messageId":"20111114111659.GC10847@sigill.intra.peff.net","threadId":"28675","inReplyTo":"4EC0F15A.9010502@alum.mit.edu","subject":"Re: Git shouldn't allow to push a new branch called HEAD","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-11-14T11:16:59Z","receivedAt":"2011-11-14T11:16:59Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Nov 14, 2011 at 11:45:46AM +0100, Michael Haggerty wrote:\n\n> The whole time, victim's .git/HEAD contains \"ref: refs/heads/master\",\n> .git/refs/remotes/origin/HEAD contains \"ref:\n> refs/remotes/origin/master\", and its packed-refs file contains\n> \n> # pack-refs with: peeled\n> 4c9ebba3c0618bd6238a810013da4a8cd4f2213b refs/remotes/origin/master\n> \n> In \"remote.git\", refs/heads/HEAD contains not a symbolic reference but\n> the explicit SHA1 \"4c9ebba...\".  This is of course not affected by\n> running \"git fetch\" in the \"victim\" tree.  Deleting this file makes the\n> problem go away.\n> \n> \n> Given that this problem seems to be in the remote protocol rather than\n> in the refs API, I think I'll stop working on this.  I hope that my\n> observations are helpful to somebody.\n\nI didn't recreate the test situation and look closely, but my impression\nis that this isn't a code bug at all, but rather a design problem in the\nway we store remote namespaces. That is, we make \"refs/remotes/foo/HEAD\"\na symbolic ref with special meaning, but then fetch into it from the\nremote's refs/heads namespace, writing remote's HEAD branch into\nwhatever our HEAD symref points to.\n\nSo one solution is to block fetching of remote branches called HEAD\n(which I would be OK with). But another is to use a more sensible layout\nfor representing the remote refs, like:\n\n   refs/remotes/origin/HEAD            (a symbolic ref)\n   refs/remotes/origin/heads/master\n   refs/remotes/origin/tags/v1.0\n\netc. Then the namespaces are properly separated, and the magic remote\n\"HEAD\" symref is not in the way.\n\nObviously there's a lot more to it than just tweaking the default fetch\nrefspecs. The ref lookup rules need to be changed to take this into\naccount. There was some discussion about this over the summer (under the\nsubject of possible \"1.8.0\" changes), but I don't think any work has\nbeen done.\n\n-Peff\n"},{"id":"179438","messageId":"7vbosejvx8.fsf@alter.siamese.dyndns.org","threadId":"28675","inReplyTo":"20111114111659.GC10847@sigill.intra.peff.net","subject":"Re: Git shouldn't allow to push a new branch called HEAD","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-11-14T20:22:59Z","receivedAt":"2011-11-14T20:22:59Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> So one solution is to block fetching of remote branches called HEAD\n> (which I would be OK with). But another is...\n> ... Obviously there's a lot more to it than just tweaking the default fetch\n> refspecs. The ref lookup rules need to be changed to take this into\n> account. There was some discussion about this over the summer (under the\n> subject of possible \"1.8.0\" changes), but I don't think any work has\n> been done.\n\nI would say discussing and ironing out the kinks of the design counts as\nwork, but I agree nobody was seriously interested in laying out a sensible\ntransition plan and discussion died out before anything concrete happened.\n\nRegardless of the layout chanage, which probably is a 2.X topic, I think a\ngood first step would be to start forbidding anything that ends with _?HEAD\nas a branch or tag name, on top of Michael's \"enforce the refname rules more\nvigorously when a ref is created\" series.\n"},{"id":"179443","messageId":"20111114202642.GB26269@sigill.intra.peff.net","threadId":"28675","inReplyTo":"7vbosejvx8.fsf@alter.siamese.dyndns.org","subject":"Re: Git shouldn't allow to push a new branch called HEAD","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-11-14T20:26:42Z","receivedAt":"2011-11-14T20:26:42Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Nov 14, 2011 at 12:22:59PM -0800, Junio C Hamano wrote:\n\n> Jeff King <peff@peff.net> writes:\n> \n> > So one solution is to block fetching of remote branches called HEAD\n> > (which I would be OK with). But another is...\n> > ... Obviously there's a lot more to it than just tweaking the default fetch\n> > refspecs. The ref lookup rules need to be changed to take this into\n> > account. There was some discussion about this over the summer (under the\n> > subject of possible \"1.8.0\" changes), but I don't think any work has\n> > been done.\n> \n> I would say discussing and ironing out the kinks of the design counts as\n> work, but I agree nobody was seriously interested in laying out a sensible\n> transition plan and discussion died out before anything concrete happened.\n\nYeah, I should have said \"...has been done since then\".\n\n> Regardless of the layout chanage, which probably is a 2.X topic, I think a\n> good first step would be to start forbidding anything that ends with _?HEAD\n> as a branch or tag name, on top of Michael's \"enforce the refname rules more\n> vigorously when a ref is created\" series.\n\nAgreed. Changing the layout is a long-term fix, and I think disallowing\nHEAD is a reasonable stop-gap measure.\n\n-Peff\n"}]}