Skip to content

Commit ecfc47c

Browse files
derrickstoleegitster
authored andcommitted
t1092: compare sparse-checkout to sparse-index
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>
1 parent 4300f84 commit ecfc47c

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

t/README

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,9 @@ and "sha256".
439439
GIT_TEST_WRITE_REV_INDEX=<boolean>, when true enables the
440440
'pack.writeReverseIndex' setting.
441441

442+
GIT_TEST_SPARSE_INDEX=<boolean>, when true enables index writes to use the
443+
sparse-index format by default.
444+
442445
Naming Tests
443446
------------
444447

t/t1092-sparse-checkout-compatibility.sh

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ test_description='compare full workdir to sparse workdir'
77
test_expect_success 'setup' '
88
git init initial-repo &&
99
(
10+
GIT_TEST_SPARSE_INDEX=0 &&
1011
cd initial-repo &&
1112
echo a >a &&
1213
echo "after deep" >e &&
@@ -87,23 +88,32 @@ init_repos () {
8788

8889
cp -r initial-repo sparse-checkout &&
8990
git -C sparse-checkout reset --hard &&
90-
git -C sparse-checkout sparse-checkout init --cone &&
91+
92+
cp -r initial-repo sparse-index &&
93+
git -C sparse-index reset --hard &&
9194

9295
# initialize sparse-checkout definitions
93-
git -C sparse-checkout sparse-checkout set deep
96+
git -C sparse-checkout sparse-checkout init --cone &&
97+
git -C sparse-checkout sparse-checkout set deep &&
98+
GIT_TEST_SPARSE_INDEX=1 git -C sparse-index sparse-checkout init --cone &&
99+
GIT_TEST_SPARSE_INDEX=1 git -C sparse-index sparse-checkout set deep
94100
}
95101

96102
run_on_sparse () {
97103
(
98104
cd sparse-checkout &&
99-
"$@" >../sparse-checkout-out 2>../sparse-checkout-err
105+
GIT_TEST_SPARSE_INDEX=0 "$@" >../sparse-checkout-out 2>../sparse-checkout-err
106+
) &&
107+
(
108+
cd sparse-index &&
109+
GIT_TEST_SPARSE_INDEX=1 "$@" >../sparse-index-out 2>../sparse-index-err
100110
)
101111
}
102112

103113
run_on_all () {
104114
(
105115
cd full-checkout &&
106-
"$@" >../full-checkout-out 2>../full-checkout-err
116+
GIT_TEST_SPARSE_INDEX=0 "$@" >../full-checkout-out 2>../full-checkout-err
107117
) &&
108118
run_on_sparse "$@"
109119
}
@@ -114,6 +124,12 @@ test_all_match () {
114124
test_cmp full-checkout-err sparse-checkout-err
115125
}
116126

127+
test_sparse_match () {
128+
run_on_sparse "$@" &&
129+
test_cmp sparse-checkout-out sparse-index-out &&
130+
test_cmp sparse-checkout-err sparse-index-err
131+
}
132+
117133
test_expect_success 'status with options' '
118134
init_repos &&
119135
test_all_match git status --porcelain=v2 &&

0 commit comments

Comments
 (0)