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

[PATCH 4/5] sparse-index: recompute cache-tree

From
Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
Date
Jun 29, 2021, 02:13 UTC
Message-ID
<ffe8473caab5189961ec29464629e13abbe310ed.1624932787.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.973.git.1624932786.gitgitgadget@gmail.com>
From: Derrick Stolee <dstolee@microsoft.com>

When some commands run with command_requires_full_index=1, then the index can get in a state where the in-memory cache tree is actually equal to the sparse index's cache tree instead of the full one.

This results in incorrect entry_count values. By clearing the cache tree before converting to sparse, we avoid this issue.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
---
 sparse-index.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/sparse-index.c b/sparse-index.c
index 53c8f711ccc..c6b4feec413 100644
--- a/sparse-index.c
+++ b/sparse-index.c
@@ -170,6 +170,8 @@ int convert_to_sparse(struct index_state *istate)
 	if (index_has_unmerged_entries(istate))
 		return 0;
 
+	/* Clear and recompute the cache-tree */
+	cache_tree_free(&istate->cache_tree);
 	if (cache_tree_update(istate, 0)) {
 		warning(_("unable to update cache-tree, staying full"));
 		return -1;
-- 
gitgitgadget
Previous: Derrick Stolee via GitGitGadgetNext: Derrick Stolee via GitGitGadget
Message 5 of 21 in “Sparse index: integrate with commit and checkout”
  1. 0/5 Sparse index: integrate with commit and checkoutDerrick Stolee via GitGitGadget, Jun 29, 2021
  2. 1/5 p2000: add 'git checkout -' test and decrease depthDerrick Stolee via GitGitGadget, Jun 29, 2021
  3. 2/5 p2000: compress repo namesDerrick Stolee via GitGitGadget, Jun 29, 2021
  4. 3/5 commit: integrate with sparse-indexDerrick Stolee via GitGitGadget, Jun 29, 2021
  5. 4/5 sparse-index: recompute cache-treeDerrick Stolee via GitGitGadget, Jun 29, 2021
  6. 5/5 checkout: stop expanding sparse indexesDerrick Stolee via GitGitGadget, Jun 29, 2021
  7. Elijah NewrenJul 9, 2021
  8. Derrick StoleeJul 12, 2021
  9. Derrick StoleeJul 16, 2021
  10. Elijah NewrenJul 17, 2021
  11. Derrick StoleeJul 19, 2021
  12. 0/7 Sparse index: integrate with commit and checkoutDerrick Stolee via GitGitGadget, Jul 20, 2021
  13. 2/7 p2000: compress repo namesDerrick Stolee via GitGitGadget, Jul 20, 2021
  14. 1/7 p2000: add 'git checkout -' test and decrease depthDerrick Stolee via GitGitGadget, Jul 20, 2021
  15. 5/7 checkout: stop expanding sparse indexesDerrick Stolee via GitGitGadget, Jul 20, 2021
  16. 6/7 t1092: document bad 'git checkout' behaviorDerrick Stolee via GitGitGadget, Jul 20, 2021
  17. 7/7 unpack-trees: resolve sparse-directory/file conflictsDerrick Stolee via GitGitGadget, Jul 20, 2021
  18. Elijah NewrenJul 22, 2021
  19. 3/7 commit: integrate with sparse-indexDerrick Stolee via GitGitGadget, Jul 20, 2021
  20. 4/7 sparse-index: recompute cache-treeDerrick Stolee via GitGitGadget, Jul 20, 2021
  21. Elijah NewrenJul 22, 2021

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.