Skip to content

Commit 846f34d

Browse files
phil-blaingitster
authored andcommitted
t/lib-submodule-update: add test removing nested submodules
The previous commit fixed a bug with the (no submodule) -> (nested submodules) transition for commands in the unpack-trees machinery. Let's add a test for the reverse transition (going from nested submodules to no submodule), as it is not being tested currently. While at it, uniformize the capitalization in the list of tests. Signed-off-by: Philippe Blain <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e84704f commit 846f34d

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

t/lib-submodule-update.sh

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ test_submodule_content () {
297297
# - Directory containing tracked files replaced by submodule
298298
# - Submodule replaced by tracked files in directory
299299
# - Submodule replaced by tracked file with the same name
300-
# - tracked file replaced by submodule
300+
# - Tracked file replaced by submodule
301301
#
302302
# The default is that submodule contents aren't changed until "git submodule
303303
# update" is run. And even then that command doesn't delete the work tree of
@@ -621,12 +621,13 @@ test_submodule_forced_switch () {
621621
# - Directory containing tracked files replaced by submodule
622622
# - Submodule replaced by tracked files in directory
623623
# - Submodule replaced by tracked file with the same name
624-
# - tracked file replaced by submodule
624+
# - Tracked file replaced by submodule
625625
#
626626
# New test cases
627627
# - Removing a submodule with a git directory absorbs the submodules
628628
# git directory first into the superproject.
629629
# - Switching from no submodule to nested submodules
630+
# - Switching from nested submodules to no submodule
630631

631632
# Internal function; use test_submodule_switch_recursing_with_args() or
632633
# test_submodule_forced_switch_recursing_with_args() instead.
@@ -760,6 +761,21 @@ test_submodule_recursing_with_args_common() {
760761
)
761762
'
762763

764+
# Switching to a commit without nested submodules removes their worktrees
765+
test_expect_success "$command: worktrees of nested submodules are removed" '
766+
prolog &&
767+
reset_work_tree_to_interested add_nested_sub &&
768+
(
769+
cd submodule_update &&
770+
git branch -t no_submodule origin/no_submodule &&
771+
$command no_submodule &&
772+
test_superproject_content origin/no_submodule &&
773+
! test_path_is_dir sub1 &&
774+
test_must_fail git config -f .git/modules/sub1/config core.worktree &&
775+
test_must_fail git config -f .git/modules/sub1/modules/sub2/config core.worktree
776+
)
777+
'
778+
763779
########################## Modified submodule #########################
764780
# Updating a submodule sha1 updates the submodule's work tree
765781
test_expect_success "$command: modified submodule updates submodule work tree" '

0 commit comments

Comments
 (0)