split-index: it really is incompatible with the sparse index

... at least for now. So let's error out if we are even trying to
initialize the split index when the index is sparse, or when trying to
write the split index extension for a sparse index.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Johannes Schindelin 2022-01-19 17:29:39 +00:00 коммит произвёл Junio C Hamano
Родитель ac873c2bff
Коммит 451b66c533
2 изменённых файлов: 6 добавлений и 0 удалений

Просмотреть файл

@ -3009,6 +3009,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;

Просмотреть файл

@ -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;
} }