{"thread":{"id":"13873","subject":"How does git store branchpoints?","startedAt":"2008-06-09T14:17:13Z","lastAt":"2008-06-09T21:15:33Z","messageCount":5,"participants":["davetron5000","Jakub Narebski","David Copeland"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"79226","messageId":"beffea8c-fd2a-44d0-a566-3ded5d09a3d2@l42g2000hsc.googlegroups.com","threadId":"13873","inReplyTo":null,"subject":"How does git store branchpoints?","fromName":"davetron5000","fromEmail":"davetron5000@gmail.com","sentAt":"2008-06-09T14:17:13Z","receivedAt":"2008-06-09T14:17:13Z","isPatch":false,"sender":{"key":"davetron5000@gmail.com","avatar":"https://gravatar.com/avatar/9ec09086e36c4e609dfc23a4582d2c7adf7dc2fb1796f74492d52727efa6ba86?d=mp&s=160"},"body":"Following up this:\n\nhttp://groups.google.com/group/git-version-control/browse_thread/thread/aa34d04120d0c361#\n\nI'm trying to learn/examine the .git directory to see what Git thinks.\n\nWhat I'm trying to determine is how Git knows the parent of a\nparticular commit, how I can change it, and how that affects merging.\n\nMy problem is that I have two branches, and a merge between the two\nproduces conflicts in files that are unchanged on one branch.  Since\nmy branches are linked to SVN branches, I'm thinking that Git is not\nproperly clear on their shared history.\n\nAny ideas where to look?\n\n.git/info/refs has some strange data in it:\n\n5a3e01a8327c6139e9311b01548baf4a8876b5e3    refs/heads/local-FOO\n71560b15ad6a2a7542556dfdf2d6c763625d5db4    refs/heads/local-trunk\nefb2ff2ac363600a2aaae60718bc76b6c3db4228    refs/remotes/FOO\n\nThe SHA-1 for refs/heads/local-FOO (branch created via git checkout -b\nlocal-FOO FOO) doesn't show in gitk --all, but a git log of that shows\nit to be a somewhat old commit (not the head, nor the branch point).\n\nThe SHA-1 for local-trunk is a similarly old commit\n\nThe SHA-1 for refs/remotes/FOO is the commit right before the SHA-1\nfor refs/heads/local-FOO in my git log.\n"},{"id":"79231","messageId":"m3hcc2wso1.fsf@localhost.localdomain","threadId":"13873","inReplyTo":"beffea8c-fd2a-44d0-a566-3ded5d09a3d2@l42g2000hsc.googlegroups.com","subject":"Re: How does git store branchpoints?","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-06-09T15:07:17Z","receivedAt":"2008-06-09T15:07:17Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"davetron5000 <davetron5000@gmail.com> writes:\n\n> Following up this:\n> \n> http://groups.google.com/group/git-version-control/browse_thread/thread/aa34d04120d0c361#\n> \n> I'm trying to learn/examine the .git directory to see what Git thinks.\n> \n> What I'm trying to determine is how Git knows the parent of a\n> particular commit, how I can change it, and how that affects merging.\n\nThe parent (or parents in the case of merge commit) are stored in the\ncommit object itself.  You cannot change them short of rewriting\nhistory, or telling git locally via .git/info/grafts file how it should\nmodify history (see \"Repository Layout\" documentation for more info\nabout grafts).\n \n> My problem is that I have two branches, and a merge between the two\n> produces conflicts in files that are unchanged on one branch.  Since\n> my branches are linked to SVN branches, I'm thinking that Git is not\n> properly clear on their shared history.\n> \n> Any ideas where to look?\n\nUse some kind of history viewer, be it gitk, qgit, giggle, tig,\ngit-show-branch (a bit cryptic), git log --graph (not yet released),\nor similar tool.\n\n> .git/info/refs has some strange data in it:\n> \n> 5a3e01a8327c6139e9311b01548baf4a8876b5e3    refs/heads/local-FOO\n> 71560b15ad6a2a7542556dfdf2d6c763625d5db4    refs/heads/local-trunk\n> efb2ff2ac363600a2aaae60718bc76b6c3db4228    refs/remotes/FOO\n> \n> The SHA-1 for refs/heads/local-FOO (branch created via git checkout -b\n> local-FOO FOO) doesn't show in gitk --all, but a git log of that shows\n> it to be a somewhat old commit (not the head, nor the branch point).\n\n.git/info/refs is auxiliary information for \"dumb\" protocols, i.e.\nfor fetching via HTTP etc.  It is updated using git-update-server-info,\nusually in the bare public repositories run from post-update hook\n(in non-bare you would want to add it also to post-commit).\n\nWhat you should look at is \"git show-refs\" or \"git ls-remote .\"\noutput, or \"git for-each-ref\" output.\n\n> The SHA-1 for local-trunk is a similarly old commit\n> \n> The SHA-1 for refs/remotes/FOO is the commit right before the SHA-1\n> for refs/heads/local-FOO in my git log.\n\nThat said, if you have two divergent branches 'FOO' and 'trunk',\nfor example with the following history\n\n   a<---b<---c<---d<---e  <--- trunk\n             ^\n              \\---1<---2  <--- FOO\n\nyou can derive from parent info where history diverged.\n\nYou can ask git to find branch point using \"git merge-base trunk FOO\",\nwhich should return 'c' (actually, sha-1 of this commit).\n\nHTH.\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"79255","messageId":"fd42f577-60ba-4d26-85a3-7ca4ea8295db@a1g2000hsb.googlegroups.com","threadId":"13873","inReplyTo":"m3hcc2wso1.fsf@localhost.localdomain","subject":"Re: How does git store branchpoints?","fromName":"davetron5000","fromEmail":"davetron5000@gmail.com","sentAt":"2008-06-09T19:54:41Z","receivedAt":"2008-06-09T19:54:41Z","isPatch":false,"sender":{"key":"davetron5000@gmail.com","avatar":"https://gravatar.com/avatar/9ec09086e36c4e609dfc23a4582d2c7adf7dc2fb1796f74492d52727efa6ba86?d=mp&s=160"},"body":"\n>\n> You can ask git to find branch point using \"git merge-base trunk FOO\",\n> which should return 'c' (actually, sha-1 of this commit).\n\nOK, this revealed interesting results.  The commit it gave me was a\ncommit right before ANOTHER SVN branch that I was originally to work\non, but never did.  The files git-merge showed conflicts for were\nfiles modified since THAT branch (call it BAR) was created and before\nmy branch (FOO) was created.\n\nSo, any ideas why git thinks that my two branches are rooted at BAR\nand not FOO?  git-svn dcommit on local-FOO commits to FOO and not BAR.\n\nDave\n"},{"id":"79269","messageId":"m38wxewcno.fsf@localhost.localdomain","threadId":"13873","inReplyTo":"fd42f577-60ba-4d26-85a3-7ca4ea8295db@a1g2000hsb.googlegroups.com","subject":"Re: How does git store branchpoints?","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-06-09T20:53:36Z","receivedAt":"2008-06-09T20:53:36Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"davetron5000 <davetron5000@gmail.com> writes:\n\n> >\n> > You can ask git to find branch point using \"git merge-base trunk FOO\",\n> > which should return 'c' (actually, sha-1 of this commit).\n> \n> OK, this revealed interesting results.  The commit it gave me was a\n> commit right before ANOTHER SVN branch that I was originally to work\n> on, but never did.  The files git-merge showed conflicts for were\n> files modified since THAT branch (call it BAR) was created and before\n> my branch (FOO) was created.\n\nCould you write some ascii-art diagram showing the situation? It is\nhard to grasp the situation fully only from above description.\n \n> So, any ideas why git thinks that my two branches are rooted at BAR\n> and not FOO?  git-svn dcommit on local-FOO commits to FOO and not BAR.\n\nNote that the situation described below might be not related to your\nproblem; please view history carefully using some (graphical) history\nbrowser like gitk.\n\nIt could happen that commits which should be identical aren't,\ne.g. because of different timestamp, or different author, or lack of\nsvn-id: line, or something like that.  This isn't helped by the fact\nthat Subversion doesn't store information about merges; and even if it\ndoes (SVK or svnmerge extensions) I'm not sure if git-svn can use it.\n\nSo the situation might be like following:\n\n   1---2---3---4---A---B---C   <-- branch 1\n\n   1'--2'--3'--4'--a---b---c   <-- branch 2\n\nwhile you want it to be\n\n   1---2---3---4---A---B---C   <-- branch 1\n                \\\n                 \\-a---b---c   <-- branch 2\n\nUsually working with grafts, examining result in gitk, then commiting\ngrafts using git-filter-branch is the solution for such history\nrewriting.\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"79271","messageId":"1A180CD1-50C7-4CB5-A339-7C6725FEE8D4@gmail.com","threadId":"13873","inReplyTo":"m38wxewcno.fsf@localhost.localdomain","subject":"Re: How does git store branchpoints?","fromName":"David Copeland","fromEmail":"davetron5000@gmail.com","sentAt":"2008-06-09T21:15:33Z","receivedAt":"2008-06-09T21:15:33Z","isPatch":false,"sender":{"key":"davetron5000@gmail.com","avatar":"https://gravatar.com/avatar/9ec09086e36c4e609dfc23a4582d2c7adf7dc2fb1796f74492d52727efa6ba86?d=mp&s=160"},"body":"OK, I think this captures it (branches replaced with real names so the  \nimages below make sense)\n\n\n1---2---3---4---5---6---7---8---9  <- trunk\n      \\           \\\n       \\           \\-a---c---c---d  <- GLIFFY_ONLINE_REST_API (where  \nI'm working)\n        \\\n         \\-I                        <- GLIFFY_ONLINE_SSO, no commits,  \njust a branch in SVN\n\n[ I is branched off of 2 and a is branched off of 5 ]\n\nChanges at 3 and 4 show up as conflicts when I merge  \nGLIFFY_ONLINE_REST_API and trunk\n\nThe situation you describe could be it.  It's hard to tell from gitk  \njust what is going on.\n\nIn gitk, when I find the commit in SVN that created  \nGLIFFY_ONLINE_REST_API, I see this:\n\nhttp://www.naildrivin5.com/images/git_top.jpg  (The commit message i  \n\"Rest API Branch\" and \"GLIFFY_WEBSITE_MAR\" is NOT the name in SVN)\n\nWhen I find where that yellow arrow goes, I see this:\n\nhttp://www.naildrivin5.com/images/git_bottom.jpg\n\nI will look into the graft solution....\n\nDave\n\nOn Jun 9, 2008, at 4:53 PM, Jakub Narebski wrote:\n\n> davetron5000 <davetron5000@gmail.com> writes:\n>\n>>>\n>>> You can ask git to find branch point using \"git merge-base trunk  \n>>> FOO\",\n>>> which should return 'c' (actually, sha-1 of this commit).\n>>\n>> OK, this revealed interesting results.  The commit it gave me was a\n>> commit right before ANOTHER SVN branch that I was originally to work\n>> on, but never did.  The files git-merge showed conflicts for were\n>> files modified since THAT branch (call it BAR) was created and before\n>> my branch (FOO) was created.\n>\n> Could you write some ascii-art diagram showing the situation? It is\n> hard to grasp the situation fully only from above description.\n>\n>> So, any ideas why git thinks that my two branches are rooted at BAR\n>> and not FOO?  git-svn dcommit on local-FOO commits to FOO and not  \n>> BAR.\n>\n> Note that the situation described below might be not related to your\n> problem; please view history carefully using some (graphical) history\n> browser like gitk.\n>\n> It could happen that commits which should be identical aren't,\n> e.g. because of different timestamp, or different author, or lack of\n> svn-id: line, or something like that.  This isn't helped by the fact\n> that Subversion doesn't store information about merges; and even if it\n> does (SVK or svnmerge extensions) I'm not sure if git-svn can use it.\n>\n> So the situation might be like following:\n>\n>   1---2---3---4---A---B---C   <-- branch 1\n>\n>   1'--2'--3'--4'--a---b---c   <-- branch 2\n>\n> while you want it to be\n>\n>   1---2---3---4---A---B---C   <-- branch 1\n>                \\\n>                 \\-a---b---c   <-- branch 2\n>\n> Usually working with grafts, examining result in gitk, then commiting\n> grafts using git-filter-branch is the solution for such history\n> rewriting.\n>\n> -- \n> Jakub Narebski\n> Poland\n> ShadeHawk on #git\n"}]}