Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xt/lib-submodule-update.sh14
-rw-r--r--unpack-trees.c4
2 files changed, 16 insertions, 2 deletions
diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh
index 417da3602a..ab30b2da24 100755
--- a/t/lib-submodule-update.sh
+++ b/t/lib-submodule-update.sh
@@ -626,6 +626,7 @@ test_submodule_forced_switch () {
# New test cases
# - Removing a submodule with a git directory absorbs the submodules
# git directory first into the superproject.
+# - Switching from no submodule to nested submodules
# Internal function; use test_submodule_switch_recursing_with_args() or
# test_submodule_forced_switch_recursing_with_args() instead.
@@ -683,6 +684,19 @@ test_submodule_recursing_with_args_common() {
test_submodule_content sub1 origin/replace_directory_with_sub1
)
'
+ # Switching to a commit with nested submodules recursively checks them out
+ test_expect_success "$command: nested submodules are checked out" '
+ prolog &&
+ reset_work_tree_to_interested no_submodule &&
+ (
+ cd submodule_update &&
+ git branch -t modify_sub1_recursively origin/modify_sub1_recursively &&
+ $command modify_sub1_recursively &&
+ test_superproject_content origin/modify_sub1_recursively &&
+ test_submodule_content sub1 origin/modify_sub1_recursively &&
+ test_submodule_content -C sub1 sub2 origin/modify_sub1_recursively
+ )
+ '
######################## Disappearing submodule #######################
# Removing a submodule removes its work tree ...
diff --git a/unpack-trees.c b/unpack-trees.c
index 4ff9077c87..eff499e8d7 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -2060,7 +2060,7 @@ static int merged_entry(const struct cache_entry *ce,
}
invalidate_ce_path(merge, o);
- if (submodule_from_ce(ce)) {
+ if (submodule_from_ce(ce) && file_exists(ce->name)) {
int ret = check_submodule_move_head(ce, NULL,
oid_to_hex(&ce->oid),
o);
@@ -2089,7 +2089,7 @@ static int merged_entry(const struct cache_entry *ce,
invalidate_ce_path(old, o);
}
- if (submodule_from_ce(ce)) {
+ if (submodule_from_ce(ce) && file_exists(ce->name)) {
int ret = check_submodule_move_head(ce, oid_to_hex(&old->oid),
oid_to_hex(&ce->oid),
o);