submodule: properly recurse for read-tree and checkout
authorStefan Beller <sbeller@google.com>
Tue, 2 May 2017 19:32:14 +0000 (12:32 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 4 May 2017 04:42:05 +0000 (13:42 +0900)
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>
submodule.c
t/lib-submodule-update.sh
t/t1013-read-tree-submodule.sh
t/t2013-checkout-submodule.sh
index b0141a66dd73d8d2e1dafa68de54ebefe3dfe5af..b3ae642f29205655342b08343d440d7f333a39f9 100644 (file)
@@ -1446,7 +1446,7 @@ int submodule_move_head(const char *path,
 
        argv_array_pushf(&cp.args, "--super-prefix=%s%s/",
                        get_super_prefix_or_empty(), path);
-       argv_array_pushl(&cp.args, "read-tree", NULL);
+       argv_array_pushl(&cp.args, "read-tree", "--recurse-submodules", NULL);
 
        if (flags & SUBMODULE_MOVE_HEAD_DRY_RUN)
                argv_array_push(&cp.args, "-n");
@@ -1474,6 +1474,7 @@ int submodule_move_head(const char *path,
                        cp.no_stdin = 1;
                        cp.dir = path;
 
+                       prepare_submodule_repo_env(&cp.env_array);
                        argv_array_pushl(&cp.args, "update-ref", "HEAD", new, NULL);
 
                        if (run_command(&cp)) {
index fb4f7b014e10cd383ed42550f77a14ea9b0211ac..2c17826e950ce221ae9efa10cfa99dc47c042825 100755 (executable)
@@ -787,11 +787,6 @@ test_submodule_switch_recursing () {
        then
                RESULTDS=failure
        fi
-       RESULTR=success
-       if test "$KNOWN_FAILURE_SUBMODULE_RECURSIVE_NESTED" = 1
-       then
-               RESULTR=failure
-       fi
        RESULTOI=success
        if test "$KNOWN_FAILURE_SUBMODULE_OVERWRITE_IGNORED_UNTRACKED" = 1
        then
@@ -1003,7 +998,7 @@ test_submodule_switch_recursing () {
        '
 
        # recursing deeper than one level doesn't work yet.
-       test_expect_$RESULTR "$command: modified submodule updates submodule recursively" '
+       test_expect_success "$command: modified submodule updates submodule recursively" '
                prolog &&
                reset_work_tree_to_interested add_nested_sub &&
                (
index de1ba02dc5b1c76ea52eb490298bcfcefc342b51..7019d0a04feb7714f0ed8aad1d093c3a3878c78a 100755 (executable)
@@ -5,7 +5,6 @@ test_description='read-tree can handle submodules'
 . ./test-lib.sh
 . "$TEST_DIRECTORY"/lib-submodule-update.sh
 
-KNOWN_FAILURE_SUBMODULE_RECURSIVE_NESTED=1
 KNOWN_FAILURE_DIRECTORY_SUBMODULE_CONFLICTS=1
 KNOWN_FAILURE_SUBMODULE_OVERWRITE_IGNORED_UNTRACKED=1
 
index e8f70b806f110c75b9bda5bca0af6732be391fcd..aa3522336966749fbea6e8dbe6d8f32cf711a021 100755 (executable)
@@ -64,7 +64,6 @@ test_expect_success '"checkout <submodule>" honors submodule.*.ignore from .git/
 '
 
 KNOWN_FAILURE_DIRECTORY_SUBMODULE_CONFLICTS=1
-KNOWN_FAILURE_SUBMODULE_RECURSIVE_NESTED=1
 test_submodule_switch_recursing "git checkout --recurse-submodules"
 
 test_submodule_forced_switch_recursing "git checkout -f --recurse-submodules"