{"thread":{"id":"437","subject":"question on merges","startedAt":"2005-05-02T15:12:00Z","lastAt":"2005-05-02T15:56:07Z","messageCount":3,"participants":["Lennert Buytenhek","Sean","Linus Torvalds"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"2363","messageId":"20050502151200.GA4592@xi.wantstofly.org","threadId":"437","inReplyTo":null,"subject":"question on merges","fromName":"Lennert Buytenhek","fromEmail":"buytenh@wantstofly.org","sentAt":"2005-05-02T15:12:00Z","receivedAt":"2005-05-02T15:12:00Z","isPatch":false,"sender":{"key":"buytenh@wantstofly.org","avatar":null},"body":"Hi,\n\nIf a git user has X as his most recent local commit, and merges in a\ncommit Y from someone else to create commit Z, shouldn't commit Z have\nboth commit X and Y as parents?  Or is is the other way round and is it\nperfectly well possible that a 'merge commit' only has one parent?\n\nIn the current linux-2.6 git tree, gregkh clones torvalds'\n7f907d7486f2519c2ff1493bfbcdc36dcacd85b7 and creates a chain of commits\nstarting with ac21e9ff08db3d6fac41d356c77fcb531c2e03e1 and ending in\ne838a0d4d5260bce452c96914a6e86b217c53c55.  torvalds merges this chain\nback into his version in a9e4820c4c170b3df0d2185f7b4130b0b2daed2c, but\nthat commit has as parents e838a0d4d5260bce452c96914a6e86b217c53c55\n(gregkh's last commit), and c0698f2f6e4839ce9463ce731c892993215ea067,\none of jejb's intermediate commits.  But now why is\n7f907d7486f2519c2ff1493bfbcdc36dcacd85b7 not a parent of\na9e4820c4c170b3df0d2185f7b4130b0b2daed2c?  I would expect it to be,\nsince it is linus' most recent local commit when he merges in gregkh's\ntree.\n\nThis pattern happens a few more times:\n- davem creates c4d541106bc5d0a2134aaf9e8735eee3c70b0db2 from torvalds'\n  561bbe3235da614562fb26bb14042af684971a2d, and torvalds merges davem's\n  tree back in at a2755a80f40e5794ddc20e00f781af9d6320fafb (v2.6.12-rc3),\n  but that commit only has one parent (even though it's a merge.)\n\nSee this image:\n\thttp://www.liacs.nl/~buytenh/graph_2cacb3da620a4a93f3a77e1d2c8c06bb3c74bcb0.png\n\n\ncheers,\nLennert\n"},{"id":"2364","messageId":"3294.10.10.10.24.1115048837.squirrel@linux1","threadId":"437","inReplyTo":"20050502151200.GA4592@xi.wantstofly.org","subject":"Re: question on merges","fromName":"Sean","fromEmail":"seanlkml@sympatico.ca","sentAt":"2005-05-02T15:47:17Z","receivedAt":"2005-05-02T15:47:17Z","isPatch":false,"sender":{"key":"seanlkml@sympatico.ca","avatar":"https://gravatar.com/avatar/f92923f54fc08c401fc59b71829d4b89e9b8087fbba45ff87c82e6a83aee02ae?d=mp&s=160"},"body":"On Mon, May 2, 2005 11:12 am, Lennert Buytenhek said:\n> Hi,\n>\n> If a git user has X as his most recent local commit, and merges in a\n> commit Y from someone else to create commit Z, shouldn't commit Z have\n> both commit X and Y as parents?  Or is is the other way round and is it\n> perfectly well possible that a 'merge commit' only has one parent?\n>\n> In the current linux-2.6 git tree, gregkh clones torvalds'\n> 7f907d7486f2519c2ff1493bfbcdc36dcacd85b7 and creates a chain of commits\n> starting with ac21e9ff08db3d6fac41d356c77fcb531c2e03e1 and ending in\n> e838a0d4d5260bce452c96914a6e86b217c53c55.  torvalds merges this chain\n> back into his version in a9e4820c4c170b3df0d2185f7b4130b0b2daed2c, but\n> that commit has as parents e838a0d4d5260bce452c96914a6e86b217c53c55\n> (gregkh's last commit), and c0698f2f6e4839ce9463ce731c892993215ea067,\n> one of jejb's intermediate commits.  But now why is\n> 7f907d7486f2519c2ff1493bfbcdc36dcacd85b7 not a parent of\n> a9e4820c4c170b3df0d2185f7b4130b0b2daed2c?  I would expect it to be,\n> since it is linus' most recent local commit when he merges in gregkh's\n> tree.\n>\n> This pattern happens a few more times:\n> - davem creates c4d541106bc5d0a2134aaf9e8735eee3c70b0db2 from torvalds'\n>   561bbe3235da614562fb26bb14042af684971a2d, and torvalds merges davem's\n>   tree back in at a2755a80f40e5794ddc20e00f781af9d6320fafb (v2.6.12-rc3),\n>   but that commit only has one parent (even though it's a merge.)\n>\n> See this image:\n> \thttp://www.liacs.nl/~buytenh/graph_2cacb3da620a4a93f3a77e1d2c8c06bb3c74bcb0.png\n\nHi Lennert,\n\nNice work, the labelled vectors are a nice touch.  How hard would it be to\nadd a format where all linear commits on a single branch were listed in a\nsingle bubble?  That would reduce the size of the graphic considerably\nwith no loss of info.\n\nAs for your question the top of Linus' tree at that merge was actually\ncommit c0698f2f6e4839ce9463ce731c892993215ea067  :\n\ntree b05fc8a950ace937460212e996441e4c05a227f6\nparent cb624029cab62e5415287d15b2ec907b8f322ff5\nparent 7f907d7486f2519c2ff1493bfbcdc36dcacd85b7\nauthor James Bottomley <jejb@titanic> 1113875709 -0500\ncommitter James Bottomley <jejb@titanic> 1113875709 -0500\n\nfully merge up to scsi-misc-2.6\n\n-----\n\nWhich includes the 7f90* parent for a9e4* you were expecting.  The graph\nkind of hides the fact that c069* actually originated in his tree and was\nactually his most recent local commit when he merged with gregkh.\n\nSean\n\n\n\n"},{"id":"2365","messageId":"Pine.LNX.4.58.0505020850500.3824@ppc970.osdl.org","threadId":"437","inReplyTo":"20050502151200.GA4592@xi.wantstofly.org","subject":"Re: question on merges","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-05-02T15:56:07Z","receivedAt":"2005-05-02T15:56:07Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Mon, 2 May 2005, Lennert Buytenhek wrote:\n> \n> If a git user has X as his most recent local commit, and merges in a\n> commit Y from someone else to create commit Z, shouldn't commit Z have\n> both commit X and Y as parents?  Or is is the other way round and is it\n> perfectly well possible that a 'merge commit' only has one parent?\n\nThere are two classes of git merges:\n - the \"totally trivial one\", where one side is fully contained within the \n   other (ie one side has not done any development at all)\n\n   In this case, the \"merge\" ends up being a no-op, and just ends up being \n   a trivial \"update\" to the bigger set of objects. There are no two \n   parents, because the merge never even creates a new commit - it just\n   takes the top commit from the other side.\n\n - a real merge, where both repositories have had concurrent development, \n   and then you see a new merge commit that has two parents (and they'll \n   be the two HEAD commits of the repositories).\n\nSo I assume you're just seeing the trivial case, but if what you're seeing \ndoesn't seem to match that pattern, then holler.\n\nNOTE! There's a real reason why the trivial merge _has_ to be just a plain \n\"fast-forward the history to the new state\", namely the fact that if you \ncreate a new merge-node for that, then you can never ever \"stabilize\": \npeople merging back and forth will always get new nodes, and you end up \nwith this run-away situation where you can never get the same tree on both \nsides.\n\n\t\tLinus\n"}]}