Problem with merge when renaming

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Problem with merge when renaming

From: David Euresti <hidden>
Date: 2016-06-15 22:43:35

Hi,

I think I found a problem when you move a file into a directory of the
same name.  Here's what I did.

In a repository I created a directory with a file in it.  Commit it.
Then I move the file into a tmp name, make a directory with that name,
and move it into the directory.
git-mv dir/foo dir/foo.bin
mkdir dir/foo
git-mv dir/foo.bin dir/foo/foo.bin

Then in another branch I make a completely unrelated change.  I create
a file in another directory.

If I try to merge in the changes from the other branch or if the other
branch tries to merge in these changes I get this error:

dir/foo/foo.bin: unmerged (257cc5642cb1a054f08cc83f2d943e56fd3ebe99)
fatal: git-write-tree: error building trees
Merge with strategy recursive failed.

This is the script I've been using
#!/bin/bash
#

# Make sure it's all clean
rm -rf git-repo

mkdir git-repo
pushd git-repo
git-init
mkdir dir
git-add dir
pushd dir
echo foo > foo
git-add foo
popd
git-commit -a -m "one"
popd

# Developer A moves file into dir of same name
pushd git-repo
git-checkout -b branch-a
git-mv dir/foo dir/foo.bin
mkdir dir/foo
git-mv dir/foo.bin dir/foo/foo.bin
git-commit -a -m "File renamed"
git-checkout master
popd

# Developer B makes completely unrelated changes.
pushd git-repo
git-checkout -b branch-b
echo baz > foo.txt
echo bar > bar.txt
git-add bar.txt
git-add foo.txt
git-commit -a -m "unrelated changes"
git-checkout master
popd

# Developer A wants to merge changes from B
pushd git-repo
#git-merge branch-a
echo
#git-merge branch-b
#popd

[PATCH] Extend t6020 with another test for d/f interactions

From: Alex Riesen <hidden>
Date: 2016-06-15 22:43:35

A test for a merge when one of the trees has a file moved into a
directory with the same name (not just file replaced by a directory).

The problem noticed and reported by David Euresti

Signed-off-by: Alex Riesen <redacted>

---
 t/t6020-merge-df.sh |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

David Euresti, Tue, Sep 18, 2007 22:34:53 +0200:
If I try to merge in the changes from the other branch or if the other
branch tries to merge in these changes I get this error:

dir/foo/foo.bin: unmerged (257cc5642cb1a054f08cc83f2d943e56fd3ebe99)
fatal: git-write-tree: error building trees
Merge with strategy recursive failed.
I extended the d/f merge test with the case. Have no idea how to fix
it yet though.
diff --git a/t/t6020-merge-df.sh b/t/t6020-merge-df.sh
index a19d49d..c081d3f 100755
--- a/t/t6020-merge-df.sh
+++ b/t/t6020-merge-df.sh
@@ -10,6 +10,7 @@ test_expect_success 'prepare repository' \
 'echo "Hello" > init &&
 git add init &&
 git commit -m "Initial commit" &&
+git branch init &&
 git branch B &&
 mkdir dir &&
 echo "foo" > dir/foo &&
@@ -22,4 +23,20 @@ git commit -m "File: dir"'
 
 test_expect_code 1 'Merge with d/f conflicts' 'git merge "merge msg" B master'
 
+test_expect_success 'file moved into a dir of same name' '
+    git reset --hard &&
+    git checkout -b d1 init &&
+    mkdir dir &&
+    mv init dir/init &&
+    mv dir init &&
+    git add . &&
+    git commit -a -m"init moved into init/init" &&
+    git checkout -b d2 init &&
+    echo file >file &&
+    git add file &&
+    git commit -m"unrelated change" &&
+    git checkout d1 &&
+    git merge d2
+'
+
 test_done
-- 
1.5.3.1.173.g9a67
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help