submodule helper: convert relative URL to absolute URL if needed
[gitweb.git] / t / t7400-submodule-basic.sh
index 894ea2f27dd9bef345d8247b19143005c66de7f0..76a7cb0af7955aa618556a43cc9f2a568d8de3e8 100755 (executable)
@@ -170,12 +170,13 @@ 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)" &&
+               bogus_url="$(pwd)/bogus-url" &&
+               git submodule add --force "$bogus_url" submod &&
+               git submodule add --force -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
+               git submodule add --force "$submodurl" submod &&
                test "$submodurl" = "$(git config -f .gitmodules submodule.submod.url)" &&
                test "$submodurl" = "$(git config submodule.submod.url)"
        )
@@ -369,7 +370,7 @@ test_expect_success 'init should register submodule url in .git/config' '
 
 test_failure_with_unknown_submodule () {
        test_must_fail git submodule $1 no-such-submodule 2>output.err &&
-       grep "^error: .*no-such-submodule" output.err
+       test_i18ngrep "^error: .*no-such-submodule" output.err
 }
 
 test_expect_success 'init should fail with unknown submodule' '
@@ -808,7 +809,7 @@ test_expect_success '../bar/a/b/c works with relative local path - ../foo/bar.gi
                cp pristine-.git-config .git/config &&
                cp pristine-.gitmodules .gitmodules &&
                mkdir -p a/b/c &&
-               (cd a/b/c; git init) &&
+               (cd a/b/c && git init) &&
                git config remote.origin.url ../foo/bar.git &&
                git submodule add ../bar/a/b/c ./a/b/c &&
                git submodule init &&
@@ -983,11 +984,6 @@ test_expect_success 'submodule deinit should remove the whole submodule section
        rmdir init
 '
 
-test_expect_success 'submodule deinit should unset core.worktree' '
-       test_path_is_file .git/modules/example/config &&
-       test_must_fail git config -f .git/modules/example/config core.worktree
-'
-
 test_expect_success 'submodule deinit from subdirectory' '
        git submodule update --init &&
        git config submodule.example.foo bar &&
@@ -1228,6 +1224,30 @@ test_expect_success 'submodule update and setting submodule.<name>.active' '
        test_cmp expect actual
 '
 
+test_expect_success 'clone active submodule without submodule url set' '
+       test_when_finished "rm -rf test/test" &&
+       mkdir test &&
+       # another dir breaks accidental relative paths still being correct
+       git clone file://"$pwd"/multisuper test/test &&
+       (
+               cd test/test &&
+               git config submodule.active "." &&
+
+               # do not pass --init flag, as the submodule is already active:
+               git submodule update &&
+               git submodule status >actual_raw &&
+
+               cut -c 1,43- actual_raw >actual &&
+               cat >expect <<-\EOF &&
+                sub0 (test2)
+                sub1 (test2)
+                sub2 (test2)
+                sub3 (test2)
+               EOF
+               test_cmp expect actual
+       )
+'
+
 test_expect_success 'clone --recurse-submodules with a pathspec works' '
        test_when_finished "rm -rf multisuper_clone" &&
        cat >expected <<-\EOF &&