Re: [PATCH 08/16] update submodules: add depopulate_submodule
From: Stefan Beller <hidden>
Date: 2016-11-17 22:42:18
On Thu, Nov 17, 2016 at 2:29 PM, Brandon Williams [off-list ref] wrote:
On 11/17, Stefan Beller wrote:quoted
Well first you get the warning: "cannot remove submodule '%s' because it (or one of " "its nested submodules) uses a .git directory"), and in case a d/f/ conflict arises in a later stage (e.g. when the submodule is replaced by a file or symlink), you get another related error with less helpful description how to debug it.Maybe a warning isn't the right thing? Shouldn't the checkout fail if there are any issues? This would force the user to stash/commit their changes and then retry.
Well if the path is not reused, e.g. you just delete a submodule in a commit without anything else, you could proceed and have the submodule laying around dirty?
quoted
quoted
All other submodules will actually be removed? Couldn't you end up in an undesirable state with a checkout effecting one submodule but not another?Yes you could. Maybe it's time to add "git submodule intern-git-dir", which can be given as a helpful hint or even run here first.That would be a good idea, does that functionality already exist in one form or another? I'm assuming it must since git update does just that when cloning a submodule.
No it doesn't (it is roughly these three steps):
mv ${SUBMODULE_PATH}/.git ${GIT_DIR}/modules/${SUBMODULE_NAME}
git config -f ${GIT_DIR}/modules/${SUBMODULE_NAME}/config
core.worktree ${SUBMODULE_PATH}
echo "gitdir: ${GIT_DIR}/modules/${SUBMODULE_NAME}" >
${SUBMODULE_PATH}/.git
The last 2 steps are done via
void connect_work_tree_and_git_dir(const char *work_tree, const
char *git_dir);
in submodule.{c,h}
However we'd need to make sure the first step is performed correctly. (and make
damn sure we don't loose that git dir), so I think rename(2) does the
correct thing
for directories, except when these two locations are on a different mount point.
I think I'll just write this functionality in C and optionally expose
it via the submodule--helper,
such that the user facing git-submodule.sh only has to call that helper.