git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/3] sparse-index: sparse index is disallowed when split index is active

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
Jan 19, 2022, 17:29 UTC
Message-ID
<d5c1440d9a9c943bf195a9d158c4badbd9a022a3.1642613380.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1119.git.1642613379.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>

In 6e773527b6b (sparse-index: convert from full to sparse, 2021-03-30), we introduced initial support for a sparse index, and were careful to avoid converting to a sparse index in the presence of a split index.

However, when we _just_ read a freshly-initialized index, it might not contain a split index even if _writing_ it will add one by virtue of being asked for via the `GIT_TEST_SPLIT_INDEX` variable.

We did not notice any problems with checking _only_ for `split_index` (and not `GIT_TEST_SPLIT_INDEX`) right until both `vd/sparse-sparsity-fix-on-read` _and_ `vd/sparse-reset` were merged.

Those two topics' interplay triggers a bug in conjunction with running t1091.15 when `GIT_TEST_SPLIT_INDEX=true` in the following way: `vd/sparse-sparsity-fix-on-read` ensures that the index is made sparse right after reading, and `vd/sparse-reset` ensures that the index is made non-sparse again unless running in the `--soft` mode. Since the split index feature is incompatible with the sparse index feature, we see a symptom like this:

	fatal: position for replacement 4 exceeds base index size 4

Let's fix this by avoiding the conversion to a sparse index when `GIT_TEST_SPLIT_INDEX=true`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 sparse-index.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sparse-index.c b/sparse-index.c
index a1d505d50e9..08f54747bb4 100644
--- a/sparse-index.c
+++ b/sparse-index.c
@@ -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.
 		 */
-		if (istate->split_index)
+		if (istate->split_index || git_env_bool("GIT_TEST_SPLIT_INDEX", 0))
 			return 0;
 		/*
 		 * The GIT_TEST_SPARSE_INDEX environment variable triggers the
-- 
gitgitgadget
Previous: Johannes Schindelin via GitGitGadgetNext: Junio C Hamano
Message 2 of 10 in “[Non-critical]: sparse index vs split index fixes”
  1. 0/3 [Non-critical]: sparse index vs split index fixesJohannes Schindelin via GitGitGadget, Jan 19, 2022
  2. 1/3 sparse-index: sparse index is disallowed when split index is activeJohannes Schindelin via GitGitGadget, Jan 19, 2022
  3. Junio C HamanoJan 22, 2022
  4. Johannes SchindelinJan 22, 2022
  5. 2/3 t1091: disable split indexJohannes Schindelin via GitGitGadget, Jan 19, 2022
  6. 3/3 split-index: it really is incompatible with the sparse indexJohannes Schindelin via GitGitGadget, Jan 19, 2022
  7. Junio C HamanoJan 21, 2022
  8. Johannes SchindelinJan 22, 2022
  9. Elijah NewrenJan 22, 2022
  10. Johannes SchindelinJan 22, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.