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

[PATCH v2 2/4] oneway_diff: handle removed sparse directories

From
Victoria Dye via GitGitGadget <gitgitgadget@gmail.com>
Date
Aug 7, 2022, 02:57 UTC
Message-ID
<55c77ba4b291fffe3031fbef67dcee9aa91a105c.1659841030.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1312.v2.git.1659841030.gitgitgadget@gmail.com>
From: Victoria Dye <vdye@github.com>

Update 'do_oneway_diff()' to perform a 'diff_tree_oid()' on removed sparse directories, as it does for added or modified sparse directories (see 9eb00af562 (diff-lib: handle index diffs with sparse dirs, 2021-07-14)).

At the moment, this update is unreachable code because 'unpack_trees()' (currently the only way 'oneway_diff()' can be called, via 'diff_cache()') will always traverse trees down to the individual removed files of a deleted sparse directory. A subsequent patch will change this to better preserve a sparse index in other uses of 'unpack_tree()', e.g. 'git reset --hard'. However, making that change without this patch would result in (among other issues) 'git status' printing only the name of a deleted sparse directory, not its contents. To avoid introducing that bug, 'do_oneway_diff()' is updated before modifying 'unpack_trees()'.

Signed-off-by: Victoria Dye <vdye@github.com>
---
 diff-lib.c | 5 +++++
 1 file changed, 5 insertions(+)
diff --git a/diff-lib.c b/diff-lib.c
index 7eb66a417aa..2edea41a234 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -466,6 +466,11 @@ static void do_oneway_diff(struct unpack_trees_options *o,
 	 * Something removed from the tree?
 	 */
 	if (!idx) {
+		if (S_ISSPARSEDIR(tree->ce_mode)) {
+			diff_tree_oid(&tree->oid, NULL, tree->name, &revs->diffopt);
+			return;
+		}
+
 		diff_index_show_file(revs, "-", tree, &tree->oid, 1,
 				     tree->ce_mode, 0);
 		return;
-- 
gitgitgadget
Previous: Victoria Dye via GitGitGadgetNext: Victoria Dye via GitGitGadget
Message 13 of 23 in “reset/checkout: fix miscellaneous sparse index bugs”
  1. 0/4 reset/checkout: fix miscellaneous sparse index bugsVictoria Dye via GitGitGadget, Aug 4, 2022
  2. 1/4 checkout: fix nested sparse directory diff in sparse indexVictoria Dye via GitGitGadget, Aug 4, 2022
  3. Derrick StoleeAug 5, 2022
  4. 3/4 cache.h: replace 'index_entry_exists()' with 'index_name_pos_sparse()'Victoria Dye via GitGitGadget, Aug 4, 2022
  5. Junio C HamanoAug 4, 2022
  6. Junio C HamanoAug 6, 2022
  7. 2/4 oneway_diff: handle removed sparse directoriesVictoria Dye via GitGitGadget, Aug 4, 2022
  8. 4/4 unpack-trees: handle missing sparse directoriesVictoria Dye via GitGitGadget, Aug 4, 2022
  9. Junio C HamanoAug 4, 2022
  10. Victoria DyeAug 5, 2022
  11. Junio C HamanoAug 5, 2022
  12. 0/4 reset/checkout: fix miscellaneous sparse index bugsVictoria Dye via GitGitGadget, Aug 7, 2022
  13. 2/4 oneway_diff: handle removed sparse directoriesVictoria Dye via GitGitGadget, Aug 7, 2022
  14. 1/4 checkout: fix nested sparse directory diff in sparse indexVictoria Dye via GitGitGadget, Aug 7, 2022
  15. 3/4 cache.h: create 'index_name_pos_sparse()'Victoria Dye via GitGitGadget, Aug 7, 2022
  16. 4/4 unpack-trees: unpack new trees as sparse directoriesVictoria Dye via GitGitGadget, Aug 7, 2022
  17. 0/4 reset/checkout: fix miscellaneous sparse index bugsVictoria Dye via GitGitGadget, Aug 8, 2022
  18. 1/4 checkout: fix nested sparse directory diff in sparse indexVictoria Dye via GitGitGadget, Aug 8, 2022
  19. 2/4 oneway_diff: handle removed sparse directoriesVictoria Dye via GitGitGadget, Aug 8, 2022
  20. 3/4 cache.h: create 'index_name_pos_sparse()'Victoria Dye via GitGitGadget, Aug 8, 2022
  21. 4/4 unpack-trees: unpack new trees as sparse directoriesVictoria Dye via GitGitGadget, Aug 8, 2022
  22. Junio C HamanoAug 8, 2022
  23. Derrick StoleeAug 9, 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.