submodule.c: uninitialized submodules are ignored in recursive commands
authorStefan Beller <sbeller@google.com>
Tue, 18 Apr 2017 21:37:23 +0000 (14:37 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 19 Apr 2017 04:18:29 +0000 (21:18 -0700)
This was an oversight when working on the working tree modifying commands
recursing into submodules.

To test for uninitialized submodules, introduce another submodule
"uninitialized_sub". Adding it via `submodule add` will activate the
submodule in the preparation area (in create_lib_submodule_repo we
setup all the things in submodule_update_repo), but the later tests
will use a new testing repo that clones the preparation repo
in which the new submodule is not initialized.

By adding it to the branch "add_sub1", which is the starting point of
all other branches, we have wide coverage.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
submodule.c
t/lib-submodule-update.sh
index 7c3c4b17fb10b45536bc0680b85d19a8b811f919..ccf89327315bde39bb02ad71bb8b529c4fdbfacb 100644 (file)
@@ -1333,6 +1333,9 @@ int submodule_move_head(const char *path,
        struct child_process cp = CHILD_PROCESS_INIT;
        const struct submodule *sub;
 
+       if (!is_submodule_initialized(path))
+               return 0;
+
        sub = submodule_from_path(null_sha1, path);
 
        if (!sub)
index fb4f7b014e10cd383ed42550f77a14ea9b0211ac..22dd9e060cffae345ff90e21d0ebf5af45a6e879 100755 (executable)
@@ -73,6 +73,7 @@ create_lib_submodule_repo () {
 
                git checkout -b "add_sub1" &&
                git submodule add ../submodule_update_sub1 sub1 &&
+               git submodule add ../submodule_update_sub1 uninitialized_sub &&
                git config -f .gitmodules submodule.sub1.ignore all &&
                git config submodule.sub1.ignore all &&
                git add .gitmodules &&