Over time, I have converted a number of subdirectories in a main project
into submodules, while maintaining the complete pathnames intact. Thus,
only git knows that an object at code/dir1 is a submodule or a
subdirectory of the superproject.
git has trouble merging branches across the above boundaries, the script
below demonstrates the issue. I cannot merge the main branch and a
branch that occurred before conversion to a submodule.
Paraphrasing the script, the formula is
- create a superproject with a subdirectory (sub1)
- on master, convert sub1 to a submodule (no other changes)
- on branch base (before sub1 conversion to a submodule), change a
file not in sub1 (no other changes)
- merge master into base - failure
The actual reported error message is:
fatal: cannot read object b500f4d0c6aaf40a0251da35b82c0fa5c57b6503
'sub1~master': It is a submodule!
Merge with strategy recursive failed.
Any ideas or hints on how to improve this would be greatly appreciated.
Thanks,
Mark
#!/bin/sh
#
# demonstrate issue with directory / submodule (D/S) conflict problem
mkdir dsprob || exit
cd dsprob
git init
mkdir sub1
echo hi > foo
echo hi1 > sub1/foo
git add .
git commit -m "Create base"
git checkout -b base
echo bye >> foo
git add .
git commit -m "Modify base"
git checkout master
# make sub1 a submodule
git rm -r -f sub1
git commit -m "removed sub1 directory"
git checkout base sub1
git reset
cd sub1
git init
git add .
git commit -m "Start sub1 as its own project"
cd ..
mv sub1 sub1_repo
git submodule add "$(pwd)/sub1_repo" sub1
git commit -m "Added sub1 as a submodule"
# now, go back to base and try to merge
rm -rf sub1
git checkout -f base
git merge master
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html