Skip to content

Commit 1b82b93

Browse files
committed
Merge branch 'js/sparse-vs-split-index'
Mark in various places in the code that the sparse index and the split index features are mutually incompatible. * js/sparse-vs-split-index: split-index: it really is incompatible with the sparse index t1091: disable split index sparse-index: sparse index is disallowed when split index is active
2 parents d991df4 + 451b66c commit 1b82b93

File tree

4 files changed

+33
-29
lines changed

4 files changed

+33
-29
lines changed

read-cache.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3010,6 +3010,9 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
30103010
!is_null_oid(&istate->split_index->base_oid)) {
30113011
struct strbuf sb = STRBUF_INIT;
30123012

3013+
if (istate->sparse_index)
3014+
die(_("cannot write split index for a sparse index"));
3015+
30133016
err = write_link_extension(&sb, istate) < 0 ||
30143017
write_index_ext_header(f, eoie_c, CACHE_EXT_LINK,
30153018
sb.len) < 0;

sparse-index.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ static int is_sparse_index_allowed(struct index_state *istate, int flags)
136136
/*
137137
* The sparse index is not (yet) integrated with a split index.
138138
*/
139-
if (istate->split_index)
139+
if (istate->split_index || git_env_bool("GIT_TEST_SPLIT_INDEX", 0))
140140
return 0;
141141
/*
142142
* The GIT_TEST_SPARSE_INDEX environment variable triggers the

split-index.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
struct split_index *init_split_index(struct index_state *istate)
66
{
77
if (!istate->split_index) {
8+
if (istate->sparse_index)
9+
die(_("cannot use split index with a sparse index"));
10+
811
CALLOC_ARRAY(istate->split_index, 1);
912
istate->split_index->refcount = 1;
1013
}

t/t1091-sparse-checkout-builtin.sh

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ test_description='sparse checkout builtin tests'
55
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
66
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
77

8+
GIT_TEST_SPLIT_INDEX=false
9+
export GIT_TEST_SPLIT_INDEX
10+
811
. ./test-lib.sh
912

1013
list_files() {
@@ -234,36 +237,31 @@ test_expect_success 'sparse-checkout disable' '
234237
'
235238

236239
test_expect_success 'sparse-index enabled and disabled' '
237-
(
238-
sane_unset GIT_TEST_SPLIT_INDEX &&
239-
git -C repo update-index --no-split-index &&
240-
241-
git -C repo sparse-checkout init --cone --sparse-index &&
242-
test_cmp_config -C repo true index.sparse &&
243-
git -C repo ls-files --sparse >sparse &&
244-
git -C repo sparse-checkout disable &&
245-
git -C repo ls-files --sparse >full &&
246-
247-
cat >expect <<-\EOF &&
248-
@@ -1,4 +1,7 @@
249-
a
250-
-deep/
251-
-folder1/
252-
-folder2/
253-
+deep/a
254-
+deep/deeper1/a
255-
+deep/deeper1/deepest/a
256-
+deep/deeper2/a
257-
+folder1/a
258-
+folder2/a
259-
EOF
240+
git -C repo sparse-checkout init --cone --sparse-index &&
241+
test_cmp_config -C repo true index.sparse &&
242+
git -C repo ls-files --sparse >sparse &&
243+
git -C repo sparse-checkout disable &&
244+
git -C repo ls-files --sparse >full &&
260245
261-
diff -u sparse full | tail -n +3 >actual &&
262-
test_cmp expect actual &&
246+
cat >expect <<-\EOF &&
247+
@@ -1,4 +1,7 @@
248+
a
249+
-deep/
250+
-folder1/
251+
-folder2/
252+
+deep/a
253+
+deep/deeper1/a
254+
+deep/deeper1/deepest/a
255+
+deep/deeper2/a
256+
+folder1/a
257+
+folder2/a
258+
EOF
259+
260+
diff -u sparse full | tail -n +3 >actual &&
261+
test_cmp expect actual &&
263262
264-
git -C repo config --list >config &&
265-
! grep index.sparse config
266-
)
263+
git -C repo config --list >config &&
264+
! grep index.sparse config
267265
'
268266

269267
test_expect_success 'cone mode: init and set' '

0 commit comments

Comments
 (0)