{"thread":{"id":"29162","subject":"Branch names with slashes","startedAt":"2011-12-14T10:17:32Z","lastAt":"2011-12-16T07:02:37Z","messageCount":6,"participants":["Leonardo Kim","Michael Haggerty","Neal Kreitzinger","Junio C Hamano","Johannes Sixt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"181124","messageId":"CAGcUY13TOodu1BO3DCoNnVvNZ9QkWAbD-RmyqQX6P1q6tcO+yg@mail.gmail.com","threadId":"29162","inReplyTo":null,"subject":"Branch names with slashes","fromName":"Leonardo Kim","fromEmail":"dalinaum@gmail.com","sentAt":"2011-12-14T10:17:32Z","receivedAt":"2011-12-14T10:17:32Z","isPatch":false,"sender":{"key":"dalinaum@gmail.com","avatar":null},"body":"Hi\n\nBranch names can contain slashes, so we can use 'development/foo' as a\nbranch name. If I choose 'development' as a branch name, it doesn't\nwork. There is a directory named development at '.git/refs/heads'\ndirectory. So we cannot create a file named development for\n'refs/heads/development'.\n\nAn error message may occurs like below. Unfortunately, It is not of help to me.\n'error: 'refs/heads/development/foo' exists; cannot create\n'refs/heads/development'.\n\nI think that dealing with a file system and an error message above is\nnot sufficient for a novice like me. I hope that it should be\nimproved.\n\nThanks for your response.\nLeonardo YongUk KIM\n"},{"id":"181127","messageId":"4EE89BF8.6090700@alum.mit.edu","threadId":"29162","inReplyTo":"CAGcUY13TOodu1BO3DCoNnVvNZ9QkWAbD-RmyqQX6P1q6tcO+yg@mail.gmail.com","subject":"Re: Branch names with slashes","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2011-12-14T12:52:08Z","receivedAt":"2011-12-14T12:52:08Z","isPatch":false,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"On 12/14/2011 11:17 AM, Leonardo Kim wrote:\n> Branch names can contain slashes, so we can use 'development/foo' as a\n> branch name. If I choose 'development' as a branch name, it doesn't\n> work. There is a directory named development at '.git/refs/heads'\n> directory. So we cannot create a file named development for\n> 'refs/heads/development'.\n> \n> An error message may occurs like below. Unfortunately, It is not of help to me.\n> 'error: 'refs/heads/development/foo' exists; cannot create\n> 'refs/heads/development'.\n\nAssuming that the wording of the error message is not considered part of\nthe external API, it is trivial to change it.  What do you suggest?\n\nMichael\n\n-- \nMichael Haggerty\nmhagger@alum.mit.edu\nhttp://softwareswirl.blogspot.com/\n"},{"id":"181247","messageId":"4EEA5B55.1040405@gmail.com","threadId":"29162","inReplyTo":"CAGcUY13TOodu1BO3DCoNnVvNZ9QkWAbD-RmyqQX6P1q6tcO+yg@mail.gmail.com","subject":"Re: Branch names with slashes","fromName":"Neal Kreitzinger","fromEmail":"nkreitzinger@gmail.com","sentAt":"2011-12-15T20:40:53Z","receivedAt":"2011-12-15T20:40:53Z","isPatch":false,"sender":{"key":"nkreitzinger@gmail.com","avatar":null},"body":"On 12/14/2011 4:17 AM, Leonardo Kim wrote:\n> Branch names can contain slashes, so we can use 'development/foo' as\n> a branch name. If I choose 'development' as a branch name, it doesn't\n> work. There is a directory named development at '.git/refs/heads'\n> directory. So we cannot create a file named development for\n> 'refs/heads/development'.\n>\n> An error message may occurs like below. Unfortunately, It is not of\n> help to me. 'error: 'refs/heads/development/foo' exists; cannot\n> create 'refs/heads/development'.\n>\n> I think that dealing with a file system and an error message above is\n> not sufficient for a novice like me. I hope that it should be\n> improved.\n>\nFYI, We also use slashes in our branchnames to leverage some of the \nbenefits of a path-like namespace like pattern matching and the logical\nexpression of hierarchies using descriptive compound names. (We use git \n1.7.1 on linux.) Here's something to keep in mind: You have to plan \n(think ahead) for your naming conventions so that the namespaces will \nmaintain uniqueness at a peer level over time that cannot be confused as \nsubdirs under .git/refs/heads. For example:\n\nbranchnames:\n/mysystem/generic\n/mysystem/generic/project1\n\nwill not work because /mysystem/generic appears to be a parent dir to\n/mysystem/generic/project1 under .git/refs/heads.  The solution is:\n\n/mysystem/generic/base\n/mysystem/generic/project1\n\nthese branches can coexist because they are unique without one appearing\nto be a parent dir of the other.  IOW, their namespaces are peers in\ntheir entirety. To carry the example a little further,\n\n/mysystem/generic/project1/part2\nwill not work because once again it appears to be a subdir of an \nexisting branchname (ref).  However,\n/mysystem/generic/project1-part2\nwill work.\n\nI think the reason for this is that if you look at .git/refs/heads you\nwill see that these slash delimited branch names are actually stored as\nsubdirs in the filesystem sense.  Therefore, git will get confused and\nerror out as it tries to find branchnames that are not entirely unique\nby their full path namespace under .git/refs/heads because a branch\nnamespace that is a prefix (in the filesystem sense) of another branch \nname would occupy the same path under .git/refs/heads without being \ndistinguishable as unique, and vice versa.\n\nHope this helps. (Maybe someone else will find a clearer way to explain\nthis.)\n\nv/r,\nneal\n"},{"id":"181268","messageId":"4EEA777C.6040607@alum.mit.edu","threadId":"29162","inReplyTo":"4EEA5B55.1040405@gmail.com","subject":"Re: Branch names with slashes","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2011-12-15T22:41:00Z","receivedAt":"2011-12-15T22:41:00Z","isPatch":false,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"On 12/15/2011 09:40 PM, Neal Kreitzinger wrote:\n> On 12/14/2011 4:17 AM, Leonardo Kim wrote:\n>> Branch names can contain slashes, so we can use 'development/foo' as\n>> a branch name. If I choose 'development' as a branch name, it doesn't\n>> work. There is a directory named development at '.git/refs/heads'\n>> directory. So we cannot create a file named development for\n>> 'refs/heads/development'.\n>>\n>> An error message may occurs like below. Unfortunately, It is not of\n>> help to me. 'error: 'refs/heads/development/foo' exists; cannot\n>> create 'refs/heads/development'.\n>>\n>> I think that dealing with a file system and an error message above is\n>> not sufficient for a novice like me. I hope that it should be\n>> improved.\n>>\n> FYI, We also use slashes in our branchnames to leverage some of the\n> benefits of a path-like namespace like pattern matching and the logical\n> expression of hierarchies using descriptive compound names. (We use git\n> 1.7.1 on linux.) Here's something to keep in mind: You have to plan\n> (think ahead) for your naming conventions so that the namespaces will\n> maintain uniqueness at a peer level over time that cannot be confused as\n> subdirs under .git/refs/heads. For example:\n> \n> branchnames:\n> /mysystem/generic\n> /mysystem/generic/project1\n> \n> will not work because /mysystem/generic appears to be a parent dir to\n> /mysystem/generic/project1 under .git/refs/heads.  The solution is:\n> \n> /mysystem/generic/base\n> /mysystem/generic/project1\n> \n> these branches can coexist because they are unique without one appearing\n> to be a parent dir of the other.  IOW, their namespaces are peers in\n> their entirety. To carry the example a little further,\n> \n> /mysystem/generic/project1/part2\n> will not work because once again it appears to be a subdir of an\n> existing branchname (ref).  However,\n> /mysystem/generic/project1-part2\n> will work.\n> \n> I think the reason for this is that if you look at .git/refs/heads you\n> will see that these slash delimited branch names are actually stored as\n> subdirs in the filesystem sense.  Therefore, git will get confused and\n> error out as it tries to find branchnames that are not entirely unique\n> by their full path namespace under .git/refs/heads because a branch\n> namespace that is a prefix (in the filesystem sense) of another branch\n> name would occupy the same path under .git/refs/heads without being\n> distinguishable as unique, and vice versa.\n\nEverything that you say is correct.  And it is known, at least to a few\ngit implementers (i.e., not a bug but a conscious design decision).  For\nexample, the function is_refname_available() is used explicitly to\nprevent refnames that conflict in the way that you describe *even if*\nthe refnames in question are packed and therefore not 1:1 with\nfilesystem paths.  This is all a limitation of the fact that references\n*can* be represented by files and therefore they inherit the filesystem\nconstraint that a file and subdirectory within a single parent directory\ncannot have the same name.\n\nI don't believe that it would be possible to relax this limitations\nwithout at least a little breakage of backwards compatibility.\n\nWhat is the bottom line?  Feel free to submit patches to improve the\ndocumentation or error reporting.  But I doubt that the underlying\nlimitation will be removed.\n\nMichael\n\n-- \nMichael Haggerty\nmhagger@alum.mit.edu\nhttp://softwareswirl.blogspot.com/\n"},{"id":"181276","messageId":"7vhb11l6ki.fsf@alter.siamese.dyndns.org","threadId":"29162","inReplyTo":"4EEA777C.6040607@alum.mit.edu","subject":"Re: Branch names with slashes","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-12-16T00:10:37Z","receivedAt":"2011-12-16T00:10:37Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Haggerty <mhagger@alum.mit.edu> writes:\n\n> I don't believe that it would be possible to relax this limitations\n> without at least a little breakage of backwards compatibility.\n\nI do not think it is worth it, but you _could_ update your git to use a\nfile whose name is \"refs/heads/.foo/bar\" as the representation of foo/bar\nbranch and refs.c API, especially the ones close to resolve_ref(), should\nbe the only ones that need to know about this.  While walking the filesystem\nin refs/ hierarchy, any directory you see whose name do not begin with dot\nyou would treat it as a legacy one and perhaps rename it to match the new\nconvention on the fly.\n\n> What is the bottom line?  Feel free to submit patches to improve the\n> documentation or error reporting.  But I doubt that the underlying\n> limitation will be removed.\n\nI do not think so either. It is not even a limitation but is a basic\nnature of \"hierarchical names\".\n"},{"id":"181281","messageId":"4EEAED0D.90006@viscovery.net","threadId":"29162","inReplyTo":"CAGcUY13TOodu1BO3DCoNnVvNZ9QkWAbD-RmyqQX6P1q6tcO+yg@mail.gmail.com","subject":"Re: Branch names with slashes","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2011-12-16T07:02:37Z","receivedAt":"2011-12-16T07:02:37Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 12/14/2011 11:17, schrieb Leonardo Kim:\n> Branch names can contain slashes, so we can use 'development/foo' as a\n> branch name. If I choose 'development' as a branch name, it doesn't\n> work. There is a directory named development at '.git/refs/heads'\n> directory. So we cannot create a file named development for\n> 'refs/heads/development'.\n> \n> An error message may occurs like below. Unfortunately, It is not of help to me.\n> 'error: 'refs/heads/development/foo' exists; cannot create\n> 'refs/heads/development'.\n> \n> I think that dealing with a file system and an error message above is\n> not sufficient for a novice like me. I hope that it should be\n> improved.\n\nSorry, I don't see anything in the error message that makes a connection\nbetween refs and a file system; it only says \"foo/bar exists; cannot\ncreate foo\". I really don't see how this can be improved to avoid confusion.\n\n-- Hannes\n"}]}