{"thread":{"id":"14428","subject":"directory / submodule merge conflcts","startedAt":"2008-07-12T16:01:37Z","lastAt":"2008-07-12T16:01:37Z","messageCount":1,"participants":["Mark Levedahl"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"83091","messageId":"4878D561.8090009@verizon.net","threadId":"14428","inReplyTo":null,"subject":"directory / submodule merge conflcts","fromName":"Mark Levedahl","fromEmail":"mlevedahl@verizon.net","sentAt":"2008-07-12T16:01:37Z","receivedAt":"2008-07-12T16:01:37Z","isPatch":false,"sender":{"key":"mlevedahl@verizon.net","avatar":null},"body":"Over time, I have converted a number of subdirectories in a main project \ninto submodules, while maintaining the complete pathnames intact. Thus, \nonly git knows that an object at code/dir1 is a submodule or a \nsubdirectory of the superproject.\n\ngit has trouble merging branches across the above boundaries, the script \nbelow demonstrates the issue. I cannot merge the main branch and a \nbranch that occurred before conversion to a submodule.\n\nParaphrasing the script, the formula is\n    - create a superproject with a subdirectory (sub1)\n    - on master, convert sub1 to a submodule (no other changes)\n    - on branch base (before sub1 conversion to a submodule), change a \nfile not in sub1 (no other changes)\n    - merge master into base - failure\n\nThe actual reported error message is:\nfatal: cannot read object b500f4d0c6aaf40a0251da35b82c0fa5c57b6503 \n'sub1~master': It is a submodule!\nMerge with strategy recursive failed.\n\nAny ideas or hints on how to improve this would be greatly appreciated.\n\nThanks,\nMark\n\n#!/bin/sh\n#\n# demonstrate issue with directory / submodule (D/S) conflict problem\n\nmkdir dsprob || exit\ncd dsprob\ngit init\nmkdir sub1\necho hi > foo\necho hi1 > sub1/foo\ngit add .\ngit commit -m \"Create base\"\ngit checkout -b base\necho bye >> foo\ngit add .\ngit commit -m \"Modify base\"\ngit checkout master\n\n# make sub1 a submodule\ngit rm -r -f sub1\ngit commit -m \"removed sub1 directory\"\ngit checkout base sub1\ngit reset\ncd sub1\ngit init\ngit add .\ngit commit -m \"Start sub1 as its own project\"\ncd ..\nmv sub1 sub1_repo\ngit submodule add \"$(pwd)/sub1_repo\" sub1\ngit commit -m \"Added sub1 as a submodule\"\n\n# now, go back to base and try to merge\nrm -rf sub1\ngit checkout -f base\ngit merge master\n"}]}