]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t/2NNNN: allow local submodules
authorTaylor Blau <me@ttaylorr.com>
Fri, 29 Jul 2022 19:20:03 +0000 (15:20 -0400)
committerTaylor Blau <me@ttaylorr.com>
Sat, 1 Oct 2022 04:23:38 +0000 (00:23 -0400)
To prepare for the default value of `protocol.file.allow` to change to
"user", ensure tests that rely on local submodules can initialize them
over the file protocol.

Tests that only need to interact with submodules in a limited capacity
have individual Git commands annotated with the appropriate
configuration via `-c`. Tests that interact with submodules a handful of
times use `test_config_global` instead. Test scripts that rely on
submodules throughout use a `git config --global` during a setup test
towards the beginning of the script.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
t/t2400-worktree-add.sh
t/t2403-worktree-move.sh
t/t2405-worktree-submodule.sh

index 5a7495474aa8723f77b296813381151ca39b4b8b..cd02f7854d4084169c6bd89833c231b67c6e9955 100755 (executable)
@@ -597,6 +597,7 @@ test_expect_success '"add" should not fail because of another bad worktree' '
 '
 
 test_expect_success '"add" with uninitialized submodule, with submodule.recurse unset' '
+       test_config_global protocol.file.allow always &&
        test_create_repo submodule &&
        test_commit -C submodule first &&
        test_create_repo project &&
@@ -612,6 +613,7 @@ test_expect_success '"add" with uninitialized submodule, with submodule.recurse
 '
 
 test_expect_success '"add" with initialized submodule, with submodule.recurse unset' '
+       test_config_global protocol.file.allow always &&
        git -C project-clone submodule update --init &&
        git -C project-clone worktree add ../project-4
 '
index a4e1a178e0a00335affa95d566728e3085804b47..e8246eed9c60472fc259691213fdf0b3b4fd03d5 100755 (executable)
@@ -138,7 +138,8 @@ test_expect_success 'move a repo with uninitialized submodule' '
        (
                cd withsub &&
                test_commit initial &&
-               git submodule add "$PWD"/.git sub &&
+               git -c protocol.file.allow=always \
+                       submodule add "$PWD"/.git sub &&
                git commit -m withsub &&
                git worktree add second HEAD &&
                git worktree move second third
@@ -148,7 +149,7 @@ test_expect_success 'move a repo with uninitialized submodule' '
 test_expect_success 'not move a repo with initialized submodule' '
        (
                cd withsub &&
-               git -C third submodule update &&
+               git -c protocol.file.allow=always -C third submodule update &&
                test_must_fail git worktree move third forth
        )
 '
@@ -227,6 +228,7 @@ test_expect_success 'remove cleans up .git/worktrees when empty' '
 '
 
 test_expect_success 'remove a repo with uninitialized submodule' '
+       test_config_global protocol.file.allow always &&
        (
                cd withsub &&
                git worktree add to-remove HEAD &&
@@ -235,6 +237,7 @@ test_expect_success 'remove a repo with uninitialized submodule' '
 '
 
 test_expect_success 'not remove a repo with initialized submodule' '
+       test_config_global protocol.file.allow always &&
        (
                cd withsub &&
                git worktree add to-remove HEAD &&
index e1b2bfd87e0d598139ad974db4d546d6d01397b2..51120d5debe9ecff908112c673415aefbc60f147 100755 (executable)
@@ -7,6 +7,7 @@ test_description='Combination of submodules and multiple worktrees'
 base_path=$(pwd -P)
 
 test_expect_success 'setup: create origin repos'  '
+       git config --global protocol.file.allow always &&
        git init origin/sub &&
        test_commit -C origin/sub file1 &&
        git init origin/main &&