{"thread":{"id":"16301","subject":"[BUG] fatal error during merge","startedAt":"2008-11-13T09:22:14Z","lastAt":"2008-11-14T09:16:04Z","messageCount":14,"participants":["Anders Melchiorsen","Samuel Tardieu","SZEDER Gábor","Junio C Hamano","Alex Riesen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"95671","messageId":"53328.bFoQE3daRhY=.1226568134.squirrel@webmail.hotelhot.dk","threadId":"16301","inReplyTo":null,"subject":"[BUG] fatal error during merge","fromName":"Anders Melchiorsen","fromEmail":"mail@cup.kalibalik.dk","sentAt":"2008-11-13T09:22:14Z","receivedAt":"2008-11-13T09:22:14Z","isPatch":false,"sender":{"key":"mail@cup.kalibalik.dk","avatar":null},"body":"It took a while to make a minimal test case for this, but I think that all\nthe below steps are required. It ends up with this message:\n\nafter/one: unmerged (e69de29bb2d1d6434b8b29ae775ad8c2e48c5391)\nfatal: git write-tree failed to write a tree\n\nand the file that was moved has disappeared from the working tree.\n\nI have tested the script with Git 1.6.0.2, but the real scenario that made\nthis appear seems to also fail with master and next from git.git.\n\nCheers,\nAnders.\n\n\nTest script:\n\nmkdir am-merge-fail\ncd am-merge-fail\ngit init\n\nmkdir before\ntouch before/one after\ngit add -A\ngit commit -minitial\n\nrm -f after\ngit mv before after\ngit commit -mmove\n\ngit checkout -b parallel HEAD~\ntouch another\ngit add -A\ngit commit -mparallel\n\ngit merge master\n"},{"id":"95685","messageId":"2008-11-13-14-23-19+trackit+sam@rfc1149.net","threadId":"16301","inReplyTo":"53328.bFoQE3daRhY=.1226568134.squirrel@webmail.hotelhot.dk","subject":"Re: [BUG] fatal error during merge","fromName":"Samuel Tardieu","fromEmail":"sam@rfc1149.net","sentAt":"2008-11-13T13:23:19Z","receivedAt":"2008-11-13T13:23:19Z","isPatch":false,"sender":{"key":"sam@rfc1149.net","avatar":"https://avatars.githubusercontent.com/u/44656?v=4"},"body":">>>>> \"Anders\" == Anders Melchiorsen <mail@cup.kalibalik.dk> writes:\n\nAnders> I have tested the script with Git 1.6.0.2, but the real\nAnders> scenario that made this appear seems to also fail with master\nAnders> and next from git.git.\n\nI confirm that your test case also fails with the current \"next\".\n\n  Sam\n-- \nSamuel Tardieu -- sam@rfc1149.net -- http://www.rfc1149.net/\n"},{"id":"95687","messageId":"20081113140323.GA10267@neumann","threadId":"16301","inReplyTo":"2008-11-13-14-23-19+trackit+sam@rfc1149.net","subject":"Re: [BUG] fatal error during merge","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2008-11-13T14:03:23Z","receivedAt":"2008-11-13T14:03:23Z","isPatch":false,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"Hi,\n\nOn Thu, Nov 13, 2008 at 02:23:19PM +0100, Samuel Tardieu wrote:\n> >>>>> \"Anders\" == Anders Melchiorsen <mail@cup.kalibalik.dk> writes:\n> \n> Anders> I have tested the script with Git 1.6.0.2, but the real\n> Anders> scenario that made this appear seems to also fail with master\n> Anders> and next from git.git.\n> \n> I confirm that your test case also fails with the current \"next\".\n\nYeah, and it can be bisected to commit 621ff675 (rev-parse: fix\nmeaning of rev~ vs rev~0, 2008-03-14), which is from Linus, so put him\non Cc.\n\n\nBest,\nGábor\n"},{"id":"95688","messageId":"44684.bFoQE3daRhY=.1226586339.squirrel@webmail.hotelhot.dk","threadId":"16301","inReplyTo":"20081113140323.GA10267@neumann","subject":"Re: [BUG] fatal error during merge","fromName":"Anders Melchiorsen","fromEmail":"mail@cup.kalibalik.dk","sentAt":"2008-11-13T14:25:39Z","receivedAt":"2008-11-13T14:25:39Z","isPatch":false,"sender":{"key":"mail@cup.kalibalik.dk","avatar":null},"body":"SZEDER Gábor wrote:\n>\n> On Thu, Nov 13, 2008 at 02:23:19PM +0100, Samuel Tardieu wrote:\n>> >>>>> \"Anders\" == Anders Melchiorsen <mail@cup.kalibalik.dk> writes:\n>>\n>> Anders> I have tested the script with Git 1.6.0.2, but the real\n>> Anders> scenario that made this appear seems to also fail with master\n>> Anders> and next from git.git.\n>>\n>> I confirm that your test case also fails with the current \"next\".\n>\n> Yeah, and it can be bisected to commit 621ff675 (rev-parse: fix\n> meaning of rev~ vs rev~0, 2008-03-14), which is from Linus, so put him\n> on Cc.\n\nI guess that is due to using HEAD~ in the test script? If you are\nbisecting, here is a version that does not use the HEAD~ notation:\n\n\nmkdir am-merge-fail\ncd am-merge-fail\ngit init\n\nmkdir before\ntouch before/one after\ngit add before after\ngit commit -minitial\n\ngit branch parallel\n\nrm -f after\ngit mv before after\ngit commit -mmove\n\ngit checkout parallel\ntouch other\ngit add other\ngit commit -mparallel\n\ngit merge master\n"},{"id":"95689","messageId":"2008-11-13-15-26-33+trackit+sam@rfc1149.net","threadId":"16301","inReplyTo":"20081113140323.GA10267@neumann","subject":"Re: [BUG] fatal error during merge","fromName":"Samuel Tardieu","fromEmail":"sam@rfc1149.net","sentAt":"2008-11-13T14:26:33Z","receivedAt":"2008-11-13T14:26:33Z","isPatch":false,"sender":{"key":"sam@rfc1149.net","avatar":"https://avatars.githubusercontent.com/u/44656?v=4"},"body":"* SZEDER Gábor <szeder@ira.uka.de> [2008-11-13 15:03:23 +0100]\n\n| On Thu, Nov 13, 2008 at 02:23:19PM +0100, Samuel Tardieu wrote:\n| > >>>>> \"Anders\" == Anders Melchiorsen <mail@cup.kalibalik.dk> writes:\n| > \n| > Anders> I have tested the script with Git 1.6.0.2, but the real\n| > Anders> scenario that made this appear seems to also fail with master\n| > Anders> and next from git.git.\n| > \n| > I confirm that your test case also fails with the current \"next\".\n| \n| Yeah, and it can be bisected to commit 621ff675 (rev-parse: fix\n| meaning of rev~ vs rev~0, 2008-03-14), which is from Linus, so put him\n| on Cc.\n\nI think your pinpointed a change of behaviour in \"HEAD~\", which is\nprobably not the problem at hand. To find the real bug, you should\nupdate the test script so that it uses \"HEAD~1\" instead of \"HEAD~\".\n"},{"id":"95690","messageId":"20081113145325.GD29274@neumann","threadId":"16301","inReplyTo":"2008-11-13-15-26-33+trackit+sam@rfc1149.net","subject":"Re: [BUG] fatal error during merge","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2008-11-13T14:53:25Z","receivedAt":"2008-11-13T14:53:25Z","isPatch":false,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"Hi,\n\nOn Thu, Nov 13, 2008 at 03:26:33PM +0100, Samuel Tardieu wrote:\n> * SZEDER Gábor <szeder@ira.uka.de> [2008-11-13 15:03:23 +0100]\n> | Yeah, and it can be bisected to commit 621ff675 (rev-parse: fix\n> | meaning of rev~ vs rev~0, 2008-03-14), which is from Linus, so put him\n> | on Cc.\n> \n> I think your pinpointed a change of behaviour in \"HEAD~\", which is\n> probably not the problem at hand.  To find the real bug, you should\n> update the test script so that it uses \"HEAD~1\" instead of \"HEAD~\".\n\nIt doesn't matter.  The test script errors out at the merge, and not\nat the checkout.  Furthermore, it doesn't matter, whether HEAD~,\nHEAD~, or HEAD^ is checked out, the results are the same.\n\nBut yes, it's possible that not the bisected commit is the culprit,\nbut something in or behind merge relies on the old undocumented and\nillogical behaviour.\n\nGábor\n"},{"id":"95699","messageId":"57814.N1gUGH5fRhE=.1226596012.squirrel@webmail.hotelhot.dk","threadId":"16301","inReplyTo":"20081113145325.GD29274@neumann","subject":"Re: [BUG] fatal error during merge","fromName":"Anders Melchiorsen","fromEmail":"mail@cup.kalibalik.dk","sentAt":"2008-11-13T17:06:52Z","receivedAt":"2008-11-13T17:06:52Z","isPatch":false,"sender":{"key":"mail@cup.kalibalik.dk","avatar":null},"body":"SZEDER Gábor wrote:\n\n> It doesn't matter.  The test script errors out at the merge, and not\n> at the checkout.  Furthermore, it doesn't matter, whether HEAD~,\n> HEAD~, or HEAD^ is checked out, the results are the same.\n\nJust to be sure, I tried reverting the commit that you bisected -- and my\ntest case still fails.\n\n\nAnders.\n"},{"id":"95705","messageId":"20081113180931.GE29274@neumann","threadId":"16301","inReplyTo":"57814.N1gUGH5fRhE=.1226596012.squirrel@webmail.hotelhot.dk","subject":"Re: [BUG] fatal error during merge","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2008-11-13T18:09:31Z","receivedAt":"2008-11-13T18:09:31Z","isPatch":false,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Thu, Nov 13, 2008 at 06:06:52PM +0100, Anders Melchiorsen wrote:\n> SZEDER Gábor wrote:\n> > It doesn't matter.  The test script errors out at the merge, and not\n> > at the checkout.  Furthermore, it doesn't matter, whether HEAD~,\n> > HEAD~, or HEAD^ is checked out, the results are the same.\n> \n> Just to be sure, I tried reverting the commit that you bisected -- and my\n> test case still fails.\n\nWell, oddly enough, your second test case behaves somewhat differently\nthan the first one, at least as far as bisect is concerned.  Bisect\nnails down the second test case to 0d5e6c97 (Ignore merged status of\nthe file-level merge, 2007-04-26; put Alex on Cc).  Reverting this\ncommit on master makes both of your test cases pass.\n\nGábor\n"},{"id":"95734","messageId":"55583.N1gUGH5fRhE=.1226615119.squirrel@webmail.hotelhot.dk","threadId":"16301","inReplyTo":"20081113180931.GE29274@neumann","subject":"Re: [BUG] fatal error during merge","fromName":"Anders Melchiorsen","fromEmail":"mail@cup.kalibalik.dk","sentAt":"2008-11-13T22:25:19Z","receivedAt":"2008-11-13T22:25:19Z","isPatch":false,"sender":{"key":"mail@cup.kalibalik.dk","avatar":null},"body":"SZEDER Gábor wrote:\n\n> Well, oddly enough, your second test case behaves somewhat differently\n> than the first one, at least as far as bisect is concerned.  Bisect\n> nails down the second test case to 0d5e6c97 (Ignore merged status of\n> the file-level merge, 2007-04-26; put Alex on Cc).  Reverting this\n> commit on master makes both of your test cases pass.\n\nHmm. With that one reverted, git prints out this error instead:\n\nerror: failed to create path 'after/one': perhaps a D/F conflict?\n\nand still has the moved file disapper in the working tree. The merge is\nsuccessful, though, and the moved file is in the committed tree.\n\n\nAnders.\n"},{"id":"95994","messageId":"20081113230932.GA8552@blimp.localdomain","threadId":"16301","inReplyTo":"20081113180931.GE29274@neumann","subject":"Re: [BUG] fatal error during merge","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2008-11-13T23:09:32Z","receivedAt":"2008-11-13T23:09:32Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"SZEDER Gábor, Thu, Nov 13, 2008 19:09:31 +0100:\n> On Thu, Nov 13, 2008 at 06:06:52PM +0100, Anders Melchiorsen wrote:\n> > SZEDER Gábor wrote:\n> > > It doesn't matter.  The test script errors out at the merge, and not\n> > > at the checkout.  Furthermore, it doesn't matter, whether HEAD~,\n> > > HEAD~, or HEAD^ is checked out, the results are the same.\n> > \n> > Just to be sure, I tried reverting the commit that you bisected -- and my\n> > test case still fails.\n> \n> Well, oddly enough, your second test case behaves somewhat differently\n> than the first one, at least as far as bisect is concerned.  Bisect\n> nails down the second test case to 0d5e6c97 (Ignore merged status of\n> the file-level merge, 2007-04-26; put Alex on Cc).  Reverting this\n> commit on master makes both of your test cases pass.\n\nWell, the case is a bit unfair: all files have the same SHA-1!\n\nWhatever, the code pointed by the commit you bisected does look like a\nproblem: it does not update the index after refusing to rewrite the\nworktree file (because its SHA-1 matches the SHA-1 of the data it\nwould be rewritten with. So updating the file would be a no-op, just\nwasted effort). Instead of reverting the commit, I suggest the\nattached patch. It is a long time ago since I looked at the code\n(and it is a mess, which I'm feeling a bit ashamed of), so another\nlot of reviewing eyeglasses is definitely in order.\n\nFrom c395f4234ca5492206923e1821a316a777c651cd Mon Sep 17 00:00:00 2001\nFrom: Alex Riesen <raa.lkml@gmail.com>\nDate: Thu, 13 Nov 2008 23:55:04 +0100\nSubject: [PATCH] Update index after refusing to rewrite unchanged files\n\nSpecifically, which were not changed during recursive merge.\nOtherwise the path can stay marked as unresolved in the index,\ncausing the merge to fail.\n\nSigned-off-by: Alex Riesen <raa.lkml@gmail.com>\n\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 7472d3e..28f9e12 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -944,14 +944,15 @@ static int process_renames(struct merge_options *o,\n \n \t\t\t\tif (mfi.clean &&\n \t\t\t\t    sha_eq(mfi.sha, ren1->pair->two->sha1) &&\n-\t\t\t\t    mfi.mode == ren1->pair->two->mode)\n+\t\t\t\t    mfi.mode == ren1->pair->two->mode) {\n \t\t\t\t\t/*\n \t\t\t\t\t * This messaged is part of\n \t\t\t\t\t * t6022 test. If you change\n \t\t\t\t\t * it update the test too.\n \t\t\t\t\t */\n \t\t\t\t\toutput(o, 3, \"Skipped %s (merged same as existing)\", ren1_dst);\n-\t\t\t\telse {\n+\t\t\t\t\tadd_cacheinfo(mfi.mode, mfi.sha, ren1_dst, 0, 0, ADD_CACHE_OK_TO_ADD);\n+\t\t\t\t} else {\n \t\t\t\t\tif (mfi.merge || !mfi.clean)\n \t\t\t\t\t\toutput(o, 1, \"Renaming %s => %s\", ren1_src, ren1_dst);\n \t\t\t\t\tif (mfi.merge)\n"},{"id":"95739","messageId":"48332.N1gUGH5fRhE=.1226619243.squirrel@webmail.hotelhot.dk","threadId":"16301","inReplyTo":"20081113230932.GA8552@blimp.localdomain","subject":"Re: [BUG] fatal error during merge","fromName":"Anders Melchiorsen","fromEmail":"mail@cup.kalibalik.dk","sentAt":"2008-11-13T23:34:03Z","receivedAt":"2008-11-13T23:34:03Z","isPatch":false,"sender":{"key":"mail@cup.kalibalik.dk","avatar":null},"body":"Alex Riesen wrote:\n\n> Well, the case is a bit unfair: all files have the same SHA-1!\n\nHere is an updated test, where all files have different SHA-1. It still\nfails.\n\nYour patch got rid of the errors and it commits the merged tree. But the\nworking tree is not updated correctly, so the moved file disappears.\n\n\nCheers,\nAnders.\n\n\nmkdir am-merge-fail\ncd am-merge-fail\ngit init\n\nmkdir before\nyes | head -n100 >before/100\ntouch after\ngit add before/100 after\ngit commit -minitial\ngit branch parallel\n\ngit rm before/100 after\nmkdir after\nyes | head -n99 >after/99\ngit add after/99\ngit commit -mmove\n\ngit checkout parallel\necho \"Just to cause a non-ff\" >other\ngit add other\ngit commit -mparallel\n\ngit merge master\n"},{"id":"95748","messageId":"7vfxlvf8up.fsf@gitster.siamese.dyndns.org","threadId":"16301","inReplyTo":"48332.N1gUGH5fRhE=.1226619243.squirrel@webmail.hotelhot.dk","subject":"Re: [BUG] fatal error during merge","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-11-14T00:29:34Z","receivedAt":"2008-11-14T00:29:34Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Anders Melchiorsen\" <mail@cup.kalibalik.dk> writes:\n\n> Your patch got rid of the errors and it commits the merged tree. But the\n> working tree is not updated correctly, so the moved file disappears.\n\nIsn't this a long known breakage of D/F conflict check logic in\nmerge-recursive backend?\n"},{"id":"95768","messageId":"20081114071636.GA4013@blimp.localdomain","threadId":"16301","inReplyTo":"7vfxlvf8up.fsf@gitster.siamese.dyndns.org","subject":"Re: [BUG] fatal error during merge","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2008-11-14T07:16:36Z","receivedAt":"2008-11-14T07:16:36Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Junio C Hamano, Fri, Nov 14, 2008 01:29:34 +0100:\n> \"Anders Melchiorsen\" <mail@cup.kalibalik.dk> writes:\n> \n> > Your patch got rid of the errors and it commits the merged tree. But the\n> > working tree is not updated correctly, so the moved file disappears.\n> \n> Isn't this a long known breakage of D/F conflict check logic in\n> merge-recursive backend?\n\nCould be, but there is no conflicting entries in the merged branches.\nAll file names are different and the D/F transition happens completely\non one branch.\n\nAnd the patch isn't enough: the file Anders noticed missing is in the\nindex (correctly) but somehow removed from worktree.  Which is maybe\nbecause it _still_ was a rename: 99% similarity. Well, just\n\"yes | tail -nNN\" usually producess very similar data :)\n\nStill broken, of course...\n"},{"id":"95772","messageId":"38773.bFoQE3daRhY=.1226654164.squirrel@webmail.hotelhot.dk","threadId":"16301","inReplyTo":"20081114071636.GA4013@blimp.localdomain","subject":"Re: [BUG] fatal error during merge","fromName":"Anders Melchiorsen","fromEmail":"mail@cup.kalibalik.dk","sentAt":"2008-11-14T09:16:04Z","receivedAt":"2008-11-14T09:16:04Z","isPatch":false,"sender":{"key":"mail@cup.kalibalik.dk","avatar":null},"body":"Alex Riesen wrote:\n\n> And the patch isn't enough: the file Anders noticed missing is in the\n> index (correctly) but somehow removed from worktree.  Which is maybe\n> because it _still_ was a rename: 99% similarity. Well, just\n> \"yes | tail -nNN\" usually producess very similar data :)\n\nMaybe reducing the example all the way down to \"touch\" lost the implicit\ninformation that, indeed, it has to be a rename for this to fail.\n\n\nAnders.\n"}]}