]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t1092: compare sparse-checkout to sparse-index
authorDerrick Stolee <dstolee@microsoft.com>
Tue, 30 Mar 2021 13:10:49 +0000 (13:10 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 30 Mar 2021 19:57:45 +0000 (12:57 -0700)
Add a new 'sparse-index' repo alongside the 'full-checkout' and
'sparse-checkout' repos in t1092-sparse-checkout-compatibility.sh. Also
add run_on_sparse and test_sparse_match helpers. These helpers will be
used when the sparse index is implemented.

Add the GIT_TEST_SPARSE_INDEX environment variable to enable the
sparse-index by default. This can be enabled across all tests, but that
will only affect cases where the sparse-checkout feature is enabled.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/README
t/t1092-sparse-checkout-compatibility.sh

index 593d4a4e270cc07b0f8e7d93e0da4d3c0b73eebd..b98bc563aab5bd5e108451ae87ac5962a404f15e 100644 (file)
--- a/t/README
+++ b/t/README
@@ -439,6 +439,9 @@ and "sha256".
 GIT_TEST_WRITE_REV_INDEX=<boolean>, when true enables the
 'pack.writeReverseIndex' setting.
 
+GIT_TEST_SPARSE_INDEX=<boolean>, when true enables index writes to use the
+sparse-index format by default.
+
 Naming Tests
 ------------
 
index 3725d3997e70797981f6e82f2753865686277fd8..de5d8461c993cc913ae8e23cb48da9c3e0ea15ec 100755 (executable)
@@ -7,6 +7,7 @@ test_description='compare full workdir to sparse workdir'
 test_expect_success 'setup' '
        git init initial-repo &&
        (
+               GIT_TEST_SPARSE_INDEX=0 &&
                cd initial-repo &&
                echo a >a &&
                echo "after deep" >e &&
@@ -87,23 +88,32 @@ init_repos () {
 
        cp -r initial-repo sparse-checkout &&
        git -C sparse-checkout reset --hard &&
-       git -C sparse-checkout sparse-checkout init --cone &&
+
+       cp -r initial-repo sparse-index &&
+       git -C sparse-index reset --hard &&
 
        # initialize sparse-checkout definitions
-       git -C sparse-checkout sparse-checkout set deep
+       git -C sparse-checkout sparse-checkout init --cone &&
+       git -C sparse-checkout sparse-checkout set deep &&
+       GIT_TEST_SPARSE_INDEX=1 git -C sparse-index sparse-checkout init --cone &&
+       GIT_TEST_SPARSE_INDEX=1 git -C sparse-index sparse-checkout set deep
 }
 
 run_on_sparse () {
        (
                cd sparse-checkout &&
-               "$@" >../sparse-checkout-out 2>../sparse-checkout-err
+               GIT_TEST_SPARSE_INDEX=0 "$@" >../sparse-checkout-out 2>../sparse-checkout-err
+       ) &&
+       (
+               cd sparse-index &&
+               GIT_TEST_SPARSE_INDEX=1 "$@" >../sparse-index-out 2>../sparse-index-err
        )
 }
 
 run_on_all () {
        (
                cd full-checkout &&
-               "$@" >../full-checkout-out 2>../full-checkout-err
+               GIT_TEST_SPARSE_INDEX=0 "$@" >../full-checkout-out 2>../full-checkout-err
        ) &&
        run_on_sparse "$@"
 }
@@ -114,6 +124,12 @@ test_all_match () {
        test_cmp full-checkout-err sparse-checkout-err
 }
 
+test_sparse_match () {
+       run_on_sparse "$@" &&
+       test_cmp sparse-checkout-out sparse-index-out &&
+       test_cmp sparse-checkout-err sparse-index-err
+}
+
 test_expect_success 'status with options' '
        init_repos &&
        test_all_match git status --porcelain=v2 &&