push: add option to push only submodules
[gitweb.git] / t / t5531-deep-submodule-push.sh
index 198ce8475416be494fc023de3835828332da424d..f55137f76ffac4c6f8333444b444aef65da8b3fd 100755 (executable)
@@ -427,7 +427,52 @@ test_expect_success 'push unpushable submodule recursively fails' '
                cd submodule.git &&
                git rev-parse master >../actual
        ) &&
+       test_when_finished git -C work reset --hard master^ &&
        test_cmp expected actual
 '
 
+test_expect_success 'push --dry-run does not recursively update submodules' '
+       (
+               cd work/gar/bage &&
+               git checkout master &&
+               git rev-parse master >../../../expected_submodule &&
+               > junk9 &&
+               git add junk9 &&
+               git commit -m "Ninth junk" &&
+
+               # Go up to 'work' directory
+               cd ../.. &&
+               git checkout master &&
+               git rev-parse master >../expected_pub &&
+               git add gar/bage &&
+               git commit -m "Ninth commit for gar/bage" &&
+               git push --dry-run --recurse-submodules=on-demand ../pub.git master
+       ) &&
+       git -C submodule.git rev-parse master >actual_submodule &&
+       git -C pub.git rev-parse master >actual_pub &&
+       test_cmp expected_pub actual_pub &&
+       test_cmp expected_submodule actual_submodule
+'
+
+test_expect_success 'push --dry-run does not recursively update submodules' '
+       git -C work push --dry-run --recurse-submodules=only ../pub.git master &&
+
+       git -C submodule.git rev-parse master >actual_submodule &&
+       git -C pub.git rev-parse master >actual_pub &&
+       test_cmp expected_pub actual_pub &&
+       test_cmp expected_submodule actual_submodule
+'
+
+test_expect_success 'push only unpushed submodules recursively' '
+       git -C work/gar/bage rev-parse master >expected_submodule &&
+       git -C pub.git rev-parse master >expected_pub &&
+
+       git -C work push --recurse-submodules=only ../pub.git master &&
+
+       git -C submodule.git rev-parse master >actual_submodule &&
+       git -C pub.git rev-parse master >actual_pub &&
+       test_cmp expected_submodule actual_submodule &&
+       test_cmp expected_pub actual_pub
+'
+
 test_done