When deleting a submodule, we need to keep the actual git directory around,
such that we do not lose local changes in there and at a later checkout
of the submodule we don't need to clone it again.
Now that the functionality is available to absorb the git directory of a
submodule, rewrite the checking in git-rm to not complain, but rather
relocate the git directories inside the superproject.
An alternative solution was discussed to have a function
`depopulate_submodule`. That would couple the check for its git directory
and possible relocation before the the removal, such that it is less
likely to miss the check in the future. But the indirection with such
a function added seemed also complex. The reason for that was that this
possible move of the git directory was also implemented in
`ok_to_remove_submodule`, such that this function could truthfully
answer whether it is ok to remove the submodule.
The solution proposed here defers all these checks to the caller.
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Stefan Beller8 years agocommitted byJunio C Hamano
git status -s -uno --ignore-submodules=none > actual &&
! test -s actual &&
test_must_fail git rm -f submod &&
test -d submod &&
test -d submod/.git &&
git status -s -uno --ignore-submodules=none > actual &&
! test -s actual &&
rm -rf submod
git rm submod 2>output.err &&
! test -d submod &&
! test -d submod/.git &&
git status -s -uno --ignore-submodules=none >actual &&
test -s actual &&
test_i18ngrep Migrating output.err
'
cat >expect.deepmodified <<EOF
@ -689,24 +685,19 @@ test_expect_success 'rm of a populated nested submodule with a nested .git direc
@@ -689,24 +685,19 @@ test_expect_success 'rm of a populated nested submodule with a nested .git direc
git submodule update --recursive &&
(cd submod/subsubmod &&
rm .git &&
cp -R ../../.git/modules/sub/modules/sub .git &&
mv ../../.git/modules/sub/modules/sub .git &&
GIT_WORK_TREE=. git config --unset core.worktree
) &&
test_must_fail git rm submod &&
test -d submod &&
test -d submod/subsubmod/.git &&
git status -s -uno --ignore-submodules=none > actual &&
! test -s actual &&
test_must_fail git rm -f submod &&
test -d submod &&
test -d submod/subsubmod/.git &&
git status -s -uno --ignore-submodules=none > actual &&
! test -s actual &&
rm -rf submod
git rm submod 2>output.err &&
! test -d submod &&
! test -d submod/subsubmod/.git &&
git status -s -uno --ignore-submodules=none >actual &&
test -s actual &&
test_i18ngrep Migrating output.err
'
test_expect_success 'checking out a commit after submodule removal needs manual updates' '