Re: [PATCH] Solve git-submodule issues with detached work trees
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:54:19
Jens Lehmann [off-list ref] writes:
Not inside the submodule, me thinks they only make sense in the superproject (that's why we clean the environment before working inside the submodule).
Yes, that is fundamental and the only sane behaviour that comes from what submodules are. They are free-standing projects. Not clearing these environments when Git recurses into submodule was simply a bug (the original bug was that we added recursion without thinking these things through). Hence...
But setting the superproject's GIT_WORK_TREE to something else won't work for an already initialized submodule,
... if you point the _root_ of the toplevel superproject with GIT_WORK_TREE (and the repository of the superproject with GIT_DIR), and chdir into one of its submodule's working tree, we shouldn't say $GIT_WORK_TREE/$smpath is the submodule world. That will make it impossible to work only on submodules by setting GIT_WORK_TREE to point at its root level (and the submodule repository with GIT_DIR).