submodule init: initialize active submodules
[gitweb.git] / t / t7400-submodule-basic.sh
index b77cce8e4066ac7f46ba1a02eab7215a4cdeaaae..fbbe932d1f76de12e148bd482352e93a9c9fc454 100755 (executable)
@@ -152,6 +152,20 @@ test_expect_success 'submodule add to .gitignored path with --force' '
        )
 '
 
+test_expect_success 'submodule add to reconfigure existing submodule with --force' '
+       (
+               cd addtest-ignore &&
+               git submodule add --force bogus-url submod &&
+               git submodule add -b initial "$submodurl" submod-branch &&
+               test "bogus-url" = "$(git config -f .gitmodules submodule.submod.url)" &&
+               test "bogus-url" = "$(git config submodule.submod.url)" &&
+               # Restore the url
+               git submodule add --force "$submodurl" submod
+               test "$submodurl" = "$(git config -f .gitmodules submodule.submod.url)" &&
+               test "$submodurl" = "$(git config submodule.submod.url)"
+       )
+'
+
 test_expect_success 'submodule add --branch' '
        echo "refs/heads/initial" >expect-head &&
        cat <<-\EOF >expect-heads &&
@@ -1116,5 +1130,62 @@ test_expect_success 'submodule helper list is not confused by common prefixes' '
        test_cmp expect actual
 '
 
+test_expect_success 'setup superproject with submodules' '
+       git init sub1 &&
+       test_commit -C sub1 test &&
+       test_commit -C sub1 test2 &&
+       git init multisuper &&
+       git -C multisuper submodule add ../sub1 sub0 &&
+       git -C multisuper submodule add ../sub1 sub1 &&
+       git -C multisuper submodule add ../sub1 sub2 &&
+       git -C multisuper submodule add ../sub1 sub3 &&
+       git -C multisuper commit -m "add some submodules"
+'
+
+cat >expect <<-EOF
+-sub0
+ sub1 (test2)
+ sub2 (test2)
+ sub3 (test2)
+EOF
+
+test_expect_success 'submodule update --init with a specification' '
+       test_when_finished "rm -rf multisuper_clone" &&
+       pwd=$(pwd) &&
+       git clone file://"$pwd"/multisuper multisuper_clone &&
+       git -C multisuper_clone submodule update --init . ":(exclude)sub0" &&
+       git -C multisuper_clone submodule status |cut -c 1,43- >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'submodule update --init with submodule.active set' '
+       test_when_finished "rm -rf multisuper_clone" &&
+       pwd=$(pwd) &&
+       git clone file://"$pwd"/multisuper multisuper_clone &&
+       git -C multisuper_clone config submodule.active "." &&
+       git -C multisuper_clone config --add submodule.active ":(exclude)sub0" &&
+       git -C multisuper_clone submodule update --init &&
+       git -C multisuper_clone submodule status |cut -c 1,43- >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'submodule update and setting submodule.<name>.active' '
+       test_when_finished "rm -rf multisuper_clone" &&
+       pwd=$(pwd) &&
+       git clone file://"$pwd"/multisuper multisuper_clone &&
+       git -C multisuper_clone config --bool submodule.sub0.active "true" &&
+       git -C multisuper_clone config --bool submodule.sub1.active "false" &&
+       git -C multisuper_clone config --bool submodule.sub2.active "true" &&
+
+       cat >expect <<-\EOF &&
+        sub0 (test2)
+       -sub1
+        sub2 (test2)
+       -sub3
+       EOF
+       git -C multisuper_clone submodule update &&
+       git -C multisuper_clone submodule status |cut -c 1,43- >actual &&
+       test_cmp expect actual
+'
 
 test_done