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
maint
Junio C Hamano 2022-02-09 14:21:01 -08:00
commit 1b82b936e3
4 changed files with 32 additions and 28 deletions

View File

@ -3010,6 +3010,9 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
!is_null_oid(&istate->split_index->base_oid)) { !is_null_oid(&istate->split_index->base_oid)) {
struct strbuf sb = STRBUF_INIT; struct strbuf sb = STRBUF_INIT;


if (istate->sparse_index)
die(_("cannot write split index for a sparse index"));

err = write_link_extension(&sb, istate) < 0 || err = write_link_extension(&sb, istate) < 0 ||
write_index_ext_header(f, eoie_c, CACHE_EXT_LINK, write_index_ext_header(f, eoie_c, CACHE_EXT_LINK,
sb.len) < 0; sb.len) < 0;

View File

@ -136,7 +136,7 @@ static int is_sparse_index_allowed(struct index_state *istate, int flags)
/* /*
* The sparse index is not (yet) integrated with a split index. * The sparse index is not (yet) integrated with a split index.
*/ */
if (istate->split_index) if (istate->split_index || git_env_bool("GIT_TEST_SPLIT_INDEX", 0))
return 0; return 0;
/* /*
* The GIT_TEST_SPARSE_INDEX environment variable triggers the * The GIT_TEST_SPARSE_INDEX environment variable triggers the

View File

@ -5,6 +5,9 @@
struct split_index *init_split_index(struct index_state *istate) struct split_index *init_split_index(struct index_state *istate)
{ {
if (!istate->split_index) { if (!istate->split_index) {
if (istate->sparse_index)
die(_("cannot use split index with a sparse index"));

CALLOC_ARRAY(istate->split_index, 1); CALLOC_ARRAY(istate->split_index, 1);
istate->split_index->refcount = 1; istate->split_index->refcount = 1;
} }

View File

@ -5,6 +5,9 @@ test_description='sparse checkout builtin tests'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME


GIT_TEST_SPLIT_INDEX=false
export GIT_TEST_SPLIT_INDEX

. ./test-lib.sh . ./test-lib.sh


list_files() { list_files() {
@ -234,10 +237,6 @@ test_expect_success 'sparse-checkout disable' '
' '


test_expect_success 'sparse-index enabled and disabled' ' test_expect_success 'sparse-index enabled and disabled' '
(
sane_unset GIT_TEST_SPLIT_INDEX &&
git -C repo update-index --no-split-index &&

git -C repo sparse-checkout init --cone --sparse-index && git -C repo sparse-checkout init --cone --sparse-index &&
test_cmp_config -C repo true index.sparse && test_cmp_config -C repo true index.sparse &&
git -C repo ls-files --sparse >sparse && git -C repo ls-files --sparse >sparse &&
@ -263,7 +262,6 @@ test_expect_success 'sparse-index enabled and disabled' '


git -C repo config --list >config && git -C repo config --list >config &&
! grep index.sparse config ! grep index.sparse config
)
' '


test_expect_success 'cone mode: init and set' ' test_expect_success 'cone mode: init and set' '