false directory/file merge conflict
- From
- Jeffrey Middleton <jefromi@gmail.com>
- Date
- Dec 8, 2009, 22:55 UTC
- Message-ID
- <4389ce950912081455g2f6ad1c3i72386073e5154d6@mail.gmail.com>
When a directory (with contents) has changed into a file on one branch, and another branch attempts to merge it, there's a false conflict - the directory is processed before its contents are removed. This is particularly nasty, because "resolving" the non-existent conflict results in no changes, so future merges will fail in exactly the same way. Test script and failed merge output below.
Jeffrey
-- 8< --
rm -rf directory-file mkdir directory-file cd directory-file git init
mkdir foo echo bar > foo/bar echo bas > foo/baz git add foo/bar foo/baz git commit -m "check in files"
git branch foo_unchanged
git rm -r foo echo foo > foo git add foo git commit -m "foo changes from directory to file"
git checkout foo_unchanged echo foobar > foobar git add foobar git commit -m "make a separate change"
git merge master
-- 8< --
CONFLICT (directory/file): There is a directory with name foo in HEAD. Adding foo as foo~master Removing foo/bar Removing foo/baz Automatic merge failed; fix conflicts and then commit the result.