]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t1091-sparse-checkout-builtin.sh
worktree: copy sparse-checkout patterns and config on add
[thirdparty/git.git] / t / t1091-sparse-checkout-builtin.sh
index be6ea4ffe3343285e54ee5a51f34e6647d29d8b6..8a757b43e6cc4545ce7bfc9d99379a3f0e3857eb 100755 (executable)
@@ -146,9 +146,9 @@ test_expect_success 'interaction with clone --no-checkout (unborn index)' '
 '
 
 test_expect_success 'set enables config' '
-       git init empty-config &&
+       git init worktree-config &&
        (
-               cd empty-config &&
+               cd worktree-config &&
                test_commit test file &&
                test_path_is_missing .git/config.worktree &&
                git sparse-checkout set nothing &&
@@ -201,6 +201,21 @@ test_expect_success 'add to sparse-checkout' '
        check_files repo "a folder1 folder2"
 '
 
+test_expect_success 'worktree: add copies sparse-checkout patterns' '
+       cat repo/.git/info/sparse-checkout >old &&
+       test_when_finished cp old repo/.git/info/sparse-checkout &&
+       test_when_finished git -C repo worktree remove ../worktree &&
+       git -C repo sparse-checkout set --no-cone "/*" &&
+       git -C repo worktree add --quiet ../worktree 2>err &&
+       test_must_be_empty err &&
+       new="$(git -C worktree rev-parse --git-path info/sparse-checkout)" &&
+       test_path_is_file "$new" &&
+       test_cmp repo/.git/info/sparse-checkout "$new" &&
+       git -C worktree sparse-checkout set --cone &&
+       test_cmp_config -C worktree true core.sparseCheckoutCone &&
+       test_must_fail git -C repo core.sparseCheckoutCone
+'
+
 test_expect_success 'cone mode: match patterns' '
        git -C repo config --worktree core.sparseCheckoutCone true &&
        rm -rf repo/a repo/folder1 repo/folder2 &&
@@ -520,13 +535,13 @@ test_expect_success 'interaction with submodules' '
 '
 
 test_expect_success 'different sparse-checkouts with worktrees' '
+       git -C repo sparse-checkout set --cone deep folder1 &&
        git -C repo worktree add --detach ../worktree &&
-       check_files worktree "a deep folder1 folder2" &&
-       git -C worktree sparse-checkout init --cone &&
-       git -C repo sparse-checkout set folder1 &&
-       git -C worktree sparse-checkout set deep/deeper1 &&
-       check_files repo a folder1 &&
-       check_files worktree a deep
+       check_files worktree "a deep folder1" &&
+       git -C repo sparse-checkout set --cone folder1 &&
+       git -C worktree sparse-checkout set --cone deep/deeper1 &&
+       check_files repo "a folder1" &&
+       check_files worktree "a deep"
 '
 
 test_expect_success 'set using filename keeps file on-disk' '