{"thread":{"id":"9928","subject":"Problem with merge when renaming","startedAt":"2007-09-18T20:34:53Z","lastAt":"2007-09-19T21:11:11Z","messageCount":7,"participants":["David Euresti","Alex Riesen","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"53501","messageId":"95b3d0af0709181334y1e21507ey485860e4d45aa26f@mail.gmail.com","threadId":"9928","inReplyTo":null,"subject":"Problem with merge when renaming","fromName":"David Euresti","fromEmail":"evelio@gmail.com","sentAt":"2007-09-18T20:34:53Z","receivedAt":"2007-09-18T20:34:53Z","isPatch":false,"sender":{"key":"evelio@gmail.com","avatar":null},"body":"Hi,\n\nI think I found a problem when you move a file into a directory of the\nsame name.  Here's what I did.\n\nIn a repository I created a directory with a file in it.  Commit it.\nThen I move the file into a tmp name, make a directory with that name,\nand move it into the directory.\ngit-mv dir/foo dir/foo.bin\nmkdir dir/foo\ngit-mv dir/foo.bin dir/foo/foo.bin\n\nThen in another branch I make a completely unrelated change.  I create\na file in another directory.\n\nIf I try to merge in the changes from the other branch or if the other\nbranch tries to merge in these changes I get this error:\n\ndir/foo/foo.bin: unmerged (257cc5642cb1a054f08cc83f2d943e56fd3ebe99)\nfatal: git-write-tree: error building trees\nMerge with strategy recursive failed.\n\nThis is the script I've been using\n#!/bin/bash\n#\n\n# Make sure it's all clean\nrm -rf git-repo\n\nmkdir git-repo\npushd git-repo\ngit-init\nmkdir dir\ngit-add dir\npushd dir\necho foo > foo\ngit-add foo\npopd\ngit-commit -a -m \"one\"\npopd\n\n# Developer A moves file into dir of same name\npushd git-repo\ngit-checkout -b branch-a\ngit-mv dir/foo dir/foo.bin\nmkdir dir/foo\ngit-mv dir/foo.bin dir/foo/foo.bin\ngit-commit -a -m \"File renamed\"\ngit-checkout master\npopd\n\n# Developer B makes completely unrelated changes.\npushd git-repo\ngit-checkout -b branch-b\necho baz > foo.txt\necho bar > bar.txt\ngit-add bar.txt\ngit-add foo.txt\ngit-commit -a -m \"unrelated changes\"\ngit-checkout master\npopd\n\n# Developer A wants to merge changes from B\npushd git-repo\n#git-merge branch-a\necho\n#git-merge branch-b\n#popd\n"},{"id":"53506","messageId":"20070918221208.GB14488@steel.home","threadId":"9928","inReplyTo":"95b3d0af0709181334y1e21507ey485860e4d45aa26f@mail.gmail.com","subject":"[PATCH] Extend t6020 with another test for d/f interactions","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-09-18T22:12:08Z","receivedAt":"2007-09-18T22:12:08Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"A test for a merge when one of the trees has a file moved into a\ndirectory with the same name (not just file replaced by a directory).\n\nThe problem noticed and reported by David Euresti\n\nSigned-off-by: Alex Riesen <raa.lkml@gmail.com>\n\n---\n t/t6020-merge-df.sh |   17 +++++++++++++++++\n 1 files changed, 17 insertions(+), 0 deletions(-)\n\nDavid Euresti, Tue, Sep 18, 2007 22:34:53 +0200:\n> If I try to merge in the changes from the other branch or if the other\n> branch tries to merge in these changes I get this error:\n> \n> dir/foo/foo.bin: unmerged (257cc5642cb1a054f08cc83f2d943e56fd3ebe99)\n> fatal: git-write-tree: error building trees\n> Merge with strategy recursive failed.\n\nI extended the d/f merge test with the case. Have no idea how to fix\nit yet though.\n\ndiff --git a/t/t6020-merge-df.sh b/t/t6020-merge-df.sh\nindex a19d49d..c081d3f 100755\n--- a/t/t6020-merge-df.sh\n+++ b/t/t6020-merge-df.sh\n@@ -10,6 +10,7 @@ test_expect_success 'prepare repository' \\\n 'echo \"Hello\" > init &&\n git add init &&\n git commit -m \"Initial commit\" &&\n+git branch init &&\n git branch B &&\n mkdir dir &&\n echo \"foo\" > dir/foo &&\n@@ -22,4 +23,20 @@ git commit -m \"File: dir\"'\n \n test_expect_code 1 'Merge with d/f conflicts' 'git merge \"merge msg\" B master'\n \n+test_expect_success 'file moved into a dir of same name' '\n+    git reset --hard &&\n+    git checkout -b d1 init &&\n+    mkdir dir &&\n+    mv init dir/init &&\n+    mv dir init &&\n+    git add . &&\n+    git commit -a -m\"init moved into init/init\" &&\n+    git checkout -b d2 init &&\n+    echo file >file &&\n+    git add file &&\n+    git commit -m\"unrelated change\" &&\n+    git checkout d1 &&\n+    git merge d2\n+'\n+\n test_done\n-- \n1.5.3.1.173.g9a67\n"},{"id":"53512","messageId":"7v7imnvca0.fsf@gitster.siamese.dyndns.org","threadId":"9928","inReplyTo":"95b3d0af0709181334y1e21507ey485860e4d45aa26f@mail.gmail.com","subject":"Re: Problem with merge when renaming","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-09-18T22:28:39Z","receivedAt":"2007-09-18T22:28:39Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"David Euresti\" <evelio@gmail.com> writes:\n\n> I think I found a problem when you move a file into a directory of the\n> same name.  Here's what I did.\n\nTwo questions.\n\n (1) git --version?\n\n (2) if you do \"git merge -s resolve\" instead of just \"git\n     merge\", do you see a difference?\n"},{"id":"53522","messageId":"95b3d0af0709181542s43cd55c1xb0e653be4c030dab@mail.gmail.com","threadId":"9928","inReplyTo":"7v7imnvca0.fsf@gitster.siamese.dyndns.org","subject":"Re: Problem with merge when renaming","fromName":"David Euresti","fromEmail":"davi@euresti.com","sentAt":"2007-09-18T22:42:39Z","receivedAt":"2007-09-18T22:42:39Z","isPatch":false,"sender":{"key":"davi@euresti.com","avatar":null},"body":"1) git version 1.5.2.5 and 1.5.3.1.139.g9346b\n\n2)\n$ git-merge -s resolve branch-a\n$ git-merge -s resolve branch-b\nTrying really trivial in-index merge...\nfatal: Merge requires file-level merging\nNope.\nTrying simple merge.\nSimple merge failed, trying Automatic merge.\nfatal: merge program failed\nAutomatic merge failed; fix conflicts and then commit the result.\n\n$ git status\n# On branch master\n# Changes to be committed:\n#   (use \"git reset HEAD <file>...\" to unstage)\n#\n#       new file:   bar.txt\n#       new file:   foo.txt\n#\n# Changed but not updated:\n#   (use \"git add <file>...\" to update what will be committed)\n#\n#       unmerged:   dir/foo\n#       unmerged:   dir/foo/foo.bin\n#       modified:   dir/foo/foo.bin\n#\n\nBut if I do it in the other order I get this:\n$ git-merge -s resolve branch-b\n$ git-merge -s resolve branch-a\nTrying really trivial in-index merge...\nfatal: Merge requires file-level merging\nNope.\nTrying simple merge.\nSimple merge failed, trying Automatic merge.\nRemoving dir/foo\nAdding dir/foo/foo.bin\nERROR: untracked dir/foo/foo.bin is overwritten by the merge.\nfatal: merge program failed\nAutomatic merge failed; fix conflicts and then commit the result.\n\ndeuresti@deuresti-lnx /tmp/scm-rename-test/git-repo\n$ git status\n# On branch master\n# Changes to be committed:\n#   (use \"git reset HEAD <file>...\" to unstage)\n#\n#       deleted:    dir/foo\n#\n# Changed but not updated:\n#   (use \"git add <file>...\" to update what will be committed)\n#\n#       unmerged:   dir/foo/foo.bin\n#\n\nThanks,\nDavid\nOn 9/18/07, Junio C Hamano <gitster@pobox.com> wrote:\n> \"David Euresti\" <evelio@gmail.com> writes:\n>\n> > I think I found a problem when you move a file into a directory of the\n> > same name.  Here's what I did.\n>\n> Two questions.\n>\n>  (1) git --version?\n>\n>  (2) if you do \"git merge -s resolve\" instead of just \"git\n>      merge\", do you see a difference?\n>\n"},{"id":"53523","messageId":"20070918224447.GC14488@steel.home","threadId":"9928","inReplyTo":"7v7imnvca0.fsf@gitster.siamese.dyndns.org","subject":"Re: Problem with merge when renaming","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-09-18T22:44:47Z","receivedAt":"2007-09-18T22:44:47Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Junio C Hamano, Wed, Sep 19, 2007 00:28:39 +0200:\n> \"David Euresti\" <evelio@gmail.com> writes:\n> \n> > I think I found a problem when you move a file into a directory of the\n> > same name.  Here's what I did.\n> \n> Two questions.\n> \n>  (1) git --version?\n\nit happens with very recent git (as of today)\n\n>  (2) if you do \"git merge -s resolve\" instead of just \"git\n>      merge\", do you see a difference?\n\nyes: it has more error output.\n\nTrying really trivial in-index merge...\nwarning: Merge requires file-level merging\nNope, a really trivial in-index merge not possible\nTrying simple merge.\nSimple merge failed, trying Automatic merge.\nerror: init: is a directory - add individual files instead\nfatal: Unable to process path init\nfatal: merge program failed\nAutomatic merge failed; fix conflicts and then commit the result.\n"},{"id":"53529","messageId":"7vejgvtv0a.fsf@gitster.siamese.dyndns.org","threadId":"9928","inReplyTo":"20070918224447.GC14488@steel.home","subject":"Re: Problem with merge when renaming","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-09-18T23:27:01Z","receivedAt":"2007-09-18T23:27:01Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Alex Riesen <raa.lkml@gmail.com> writes:\n\n> Junio C Hamano, Wed, Sep 19, 2007 00:28:39 +0200:\n>> \"David Euresti\" <evelio@gmail.com> writes:\n>> \n>> > I think I found a problem when you move a file into a directory of the\n>> > same name.  Here's what I did.\n>> \n>> Two questions.\n>> \n>>  (1) git --version?\n>\n> it happens with very recent git (as of today)\n>\n>>  (2) if you do \"git merge -s resolve\" instead of just \"git\n>>      merge\", do you see a difference?\n>\n> yes: it has more error output.\n>\n> Trying really trivial in-index merge...\n> warning: Merge requires file-level merging\n> Nope, a really trivial in-index merge not possible\n> Trying simple merge.\n> Simple merge failed, trying Automatic merge.\n> error: init: is a directory - add individual files instead\n> fatal: Unable to process path init\n> fatal: merge program failed\n> Automatic merge failed; fix conflicts and then commit the result.\n\nIsn't this the same as the known issue here?\n\n\t<http://permalink.gmane.org/gmane.comp.version-control.git/53402>\n"},{"id":"53607","messageId":"20070919211110.GA12807@steel.home","threadId":"9928","inReplyTo":"7vejgvtv0a.fsf@gitster.siamese.dyndns.org","subject":"Re: Problem with merge when renaming","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-09-19T21:11:11Z","receivedAt":"2007-09-19T21:11:11Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Junio C Hamano, Wed, Sep 19, 2007 01:27:01 +0200:\n> > it happens with very recent git (as of today)\n> >\n> >>  (2) if you do \"git merge -s resolve\" instead of just \"git\n> >>      merge\", do you see a difference?\n> >\n> > yes: it has more error output.\n> >\n> > Trying really trivial in-index merge...\n> > warning: Merge requires file-level merging\n> > Nope, a really trivial in-index merge not possible\n> > Trying simple merge.\n> > Simple merge failed, trying Automatic merge.\n> > error: init: is a directory - add individual files instead\n> > fatal: Unable to process path init\n> > fatal: merge program failed\n> > Automatic merge failed; fix conflicts and then commit the result.\n> \n> Isn't this the same as the known issue here?\n> \n> \t<http://permalink.gmane.org/gmane.comp.version-control.git/53402>\n> \n\nYes, looks similar:\n\n    .../git/t$ ./t3031-df-3way.sh -d -v -i\n    ...\n    Created commit 992a330: side moves and makes changes\n     6 files changed, 155 insertions(+), 153 deletions(-)\n     create mode 100644 D\n     create mode 100644 D.A\n     delete mode 100644 D/A\n     delete mode 100644 D/B\n     delete mode 100644 D/C\n     create mode 100644 D0C\n    *   ok 1: setup\n\n    * expecting success: \n\n\t    git read-tree -m initial side master\n\n\n    fatal: Entry 'D/A' would be overwritten by merge. Cannot merge.\n    * FAIL 2: threeway\n\n\n\t\t    git read-tree -m initial side master\n\n    .../git/t$\n"}]}