submodule: properly recurse for read-tree and checkout

We forgot to prepare the submodule env, which is only a problem for nested submodules. See 2e5d6503bd (ls-files: fix recurse-submodules with nested submodules, 2017-04-13) for further explanation. To come up with a proper test for this, we'd need to look at nested submodules just as in that given commit. It turns out we're lucky and these tests already exist, but are marked as failing. We need to pass `--recurse-submodules` to read-tree additionally to make these tests pass. Passing that flag alone would not make the tests pass, such that this covers testing for the bug fix of the submodule env as well. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stefan Beller committed May 2, 2017 at 12:32 UTC 218c883783ee7c23a0955507f5b7ac4027428d63
4 files changed +3 -9
submodule.c
+2 -1
@@ -1446,7 +1446,7 @@ int submodule_move_head(const char *path,
1446
1447 argv_array_pushf(&cp.args, "--super-prefix=%s%s/",
1448 get_super_prefix_or_empty(), path);
1449 - argv_array_pushl(&cp.args, "read-tree", NULL);
1449 + argv_array_pushl(&cp.args, "read-tree", "--recurse-submodules", NULL);
1450
1451 if (flags & SUBMODULE_MOVE_HEAD_DRY_RUN)
1452 argv_array_push(&cp.args, "-n");
@@ -1474,6 +1474,7 @@ int submodule_move_head(const char *path,
1474 cp.no_stdin = 1;
1475 cp.dir = path;
1476
1477 + prepare_submodule_repo_env(&cp.env_array);
1478 argv_array_pushl(&cp.args, "update-ref", "HEAD", new, NULL);
1479
1480 if (run_command(&cp)) {
t/lib-submodule-update.sh
+1 -6
@@ -787,11 +787,6 @@ test_submodule_switch_recursing () {
787 then
788 RESULTDS=failure
789 fi
790 - RESULTR=success
791 - if test "$KNOWN_FAILURE_SUBMODULE_RECURSIVE_NESTED" = 1
792 - then
793 - RESULTR=failure
794 - fi
790 RESULTOI=success
791 if test "$KNOWN_FAILURE_SUBMODULE_OVERWRITE_IGNORED_UNTRACKED" = 1
792 then
@@ -1003,7 +998,7 @@ test_submodule_switch_recursing () {
998 '
999
1000 # recursing deeper than one level doesn't work yet.
1006 - test_expect_$RESULTR "$command: modified submodule updates submodule recursively" '
1001 + test_expect_success "$command: modified submodule updates submodule recursively" '
1002 prolog &&
1003 reset_work_tree_to_interested add_nested_sub &&
1004 (
t/t1013-read-tree-submodule.sh
-1
@@ -5,7 +5,6 @@ test_description='read-tree can handle submodules'
5 . ./test-lib.sh
6 . "$TEST_DIRECTORY"/lib-submodule-update.sh
7
8 -KNOWN_FAILURE_SUBMODULE_RECURSIVE_NESTED=1
8 KNOWN_FAILURE_DIRECTORY_SUBMODULE_CONFLICTS=1
9 KNOWN_FAILURE_SUBMODULE_OVERWRITE_IGNORED_UNTRACKED=1
10
t/t2013-checkout-submodule.sh
-1
@@ -64,7 +64,6 @@ test_expect_success '"checkout <submodule>" honors submodule.*.ignore from .git/
64 '
65
66 KNOWN_FAILURE_DIRECTORY_SUBMODULE_CONFLICTS=1
67 -KNOWN_FAILURE_SUBMODULE_RECURSIVE_NESTED=1
67 test_submodule_switch_recursing "git checkout --recurse-submodules"
68
69 test_submodule_forced_switch_recursing "git checkout -f --recurse-submodules"