{"thread":{"id":"30702","subject":"bug in merge","startedAt":"2012-06-04T16:32:06Z","lastAt":"2012-06-05T05:23:12Z","messageCount":2,"participants":["Kevin Brannen","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"192810","messageId":"4FCCE306.9020600@corp.hrsmart.com","threadId":"30702","inReplyTo":null,"subject":"bug in merge","fromName":"Kevin Brannen","fromEmail":"kbrannen@corp.hrsmart.com","sentAt":"2012-06-04T16:32:06Z","receivedAt":"2012-06-04T16:32:06Z","isPatch":false,"sender":{"key":"kbrannen@corp.hrsmart.com","avatar":null},"body":"I believe I've just found a bug in \"merge\", specifically in the \n\"recursive\" strategy. (Or really, here's another example of and \nhopefully more info on a known bug.) Oh, this is with 1.7.2.3, the \nlatest I'm able to use on this machine.\n\nBackground:\nOver time, code as been developed and commited to our main \"dev\" branch. \nSo the present HEAD was formed by something like 30 commits since the \nlast merge. It is not corrupt in any way that I can tell.\n\nWe also have a \"production\" branch, which holds what's approved for \nproduction. From time to time, we merge \"dev\" into \"production\". There \nis no corruption, no unchecked out files, no unmerged files, and not \neven untracked files in the work area. It was totally clean.\n\nBug:\nWhen I tried to merge dev into production with \"git checkout production; \ngit merge dev\", it would fail:\n\narchive/cgi-bin/admin/addcompany.cgi: unmerged \n(2ea980aa213c6a0bfb0a7e33c8d3fce3af6be91e)\narchive/cgi-bin/admin/admineditprofile.cgi: unmerged \n(297a3a7e3229b085061668abd8d5122b48d8d53a)\nfatal: git write-tree failed to write a tree\n\nResearch:\nI had to \"git reset --hard\" to reset production and try again. After \ngoogling for this and a few tests, I found that \"git merge -s resolve \ndev\" was able to successfully merge the code. In looking at the output, \nI think it gives me a clue as to what was failing with the recursive \nstrategy.\n\nTrying really trivial in-index merge...\nerror: Merge requires file-level merging\nNope.\nTrying simple merge.\nSimple merge failed, trying Automatic merge.\nAdding archive/cgi-bin/admin/addcompany.cgi\nAdding archive/cgi-bin/admin/admineditprofile.cgi\nMerge made by resolve.\n  .gitignore                                         |    4 +-\n  archive/cgi-bin/{admin => admin/addcompany.cgi}    |    0\n...\n  rename archive/cgi-bin/{admin => admin/addcompany.cgi} (100%)\n  rename {cgi-bin => archive/cgi-bin}/admin/admineditprofile.cgi (100%)\n\nKnowing what happened to the files, I think that I ended up with a \nchange tree that recursive just couldn't handle. To the best of my \nknowledge, the changes that happened over time and over multiple \ncommits  on dev went something like (each of these being in a different \ncommit):\n\ngit mv fileA dirX\ngit mv dirA dirX/fileA\ngit mv fileB dirX/fileB\n\nSo I think the problem is just too many renames/moves of the same object \nand when \"recursive\" descends the tree, it just can't handle that \ncorrectly -- or that's my guess. :)\n\nHTH,\nKevin\n"},{"id":"192866","messageId":"20120605052312.GA16958@sigill.intra.peff.net","threadId":"30702","inReplyTo":"4FCCE306.9020600@corp.hrsmart.com","subject":"Re: bug in merge","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-06-05T05:23:12Z","receivedAt":"2012-06-05T05:23:12Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Jun 04, 2012 at 11:32:06AM -0500, Kevin Brannen wrote:\n\n> I believe I've just found a bug in \"merge\", specifically in the\n> \"recursive\" strategy. (Or really, here's another example of and\n> hopefully more info on a known bug.) Oh, this is with 1.7.2.3, the\n> latest I'm able to use on this machine.\n> [...]\n> So I think the problem is just too many renames/moves of the same\n> object and when \"recursive\" descends the tree, it just can't handle\n> that correctly -- or that's my guess. :)\n\nThere were a large number of merge-recursive corner cases fixed,\nespecially around renames, in the 1.7.3, 1.7.4, and 1.7.7 versions of\ngit. I do not recall specially a bug that matches your description, but\nI would not be surprised at all if was already fixed by existing\nchanges.\n\nCan you try to reproduce with a more recent version of git (preferably\nthe current \"master\" branch)?\n\n-Peff\n"}]}