This adds a test for "submodule update", wich calls "submodule update"
from an untracked repository in the superproject. When doing creating
the parent patch a similar test failed for "submodule sync", but
all tests passed for "submodule update". It took me a long time
to figure out this was a difference in test coverage instead of
commands behaving differently. Let's improve the test coverage such
to make it a better place.

When trying to fix the issue in the parent patch I could get
the test suite passing when removing the $@ argument from module_list
in the sync command. This also indicates a low test coverage, so
fix that.

Signed-off-by: Stefan Beller <[email protected]>
---
 t/t7403-submodule-sync.sh   | 13 +++++++++----
 t/t7406-submodule-update.sh | 12 ++++++++++++
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/t/t7403-submodule-sync.sh b/t/t7403-submodule-sync.sh
index 79bc135..5dde123 100755
--- a/t/t7403-submodule-sync.sh
+++ b/t/t7403-submodule-sync.sh
@@ -28,6 +28,9 @@ test_expect_success setup '
                git submodule add ../submodule submodule &&
                test_tick &&
                git commit -m "submodule"
+               git submodule add ../submodule submodule2 &&
+               test_tick &&
+               git commit -m "second submodule"
        ) &&
        git clone super super-clone &&
        (
@@ -149,15 +152,16 @@ test_expect_success 'reset submodule URLs' '
        reset_submodule_urls super-clone
 '
 
-test_expect_success '"git submodule sync" should update submodule URLs - 
subdirectory' '
+test_expect_success '"git submodule sync" should update specified submodule 
URLs - subdirectory' '
        (
                cd super-clone &&
                git pull --no-recurse-submodules &&
                mkdir -p sub &&
                cd sub &&
-               git submodule sync >../../output
+               git submodule sync ../submodule >../../output
        ) &&
        grep "\\.\\./submodule" output &&
+       ! grep submodule2 output &&
        test -d "$(
                cd super-clone/submodule &&
                git config remote.origin.url
@@ -177,7 +181,7 @@ test_expect_success '"git submodule sync" should update 
submodule URLs - subdire
        )
 '
 
-test_expect_success '"git submodule sync --recursive" should update all 
submodule URLs - subdirectory' '
+test_expect_success '"git submodule sync --recursive" should update all 
specified submodule URLs - subdirectory' '
        (
                cd super-clone &&
                (
@@ -186,9 +190,10 @@ test_expect_success '"git submodule sync --recursive" 
should update all submodul
                ) &&
                mkdir -p sub &&
                cd sub &&
-               git submodule sync --recursive >../../output
+               git submodule sync --recursive ../submodule >../../output
        ) &&
        grep "\\.\\./submodule/sub-submodule" output &&
+       ! grep submodule2 output &&
        test -d "$(
                cd super-clone/submodule &&
                git config remote.origin.url
diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh
index 68ea31d..628da7f 100755
--- a/t/t7406-submodule-update.sh
+++ b/t/t7406-submodule-update.sh
@@ -774,4 +774,16 @@ test_expect_success 'submodule update --recursive drops 
module name before recur
         test_i18ngrep "Submodule path .deeper/submodule/subsubmodule.: checked 
out" actual
        )
 '
+
+test_expect_success 'submodule update --recursive works from subdirectory' '
+       (cd super2 &&
+        (cd deeper/submodule/subsubmodule &&
+         git checkout HEAD^
+        ) &&
+        mkdir untracked &&
+        cd untracked &&
+        git submodule update --recursive >actual &&
+        test_i18ngrep "Submodule path .../deeper/submodule/subsubmodule.: 
checked out" actual
+       )
+'
 test_done
-- 
2.8.0.rc4.10.g52f3f33

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to