summaryrefslogtreecommitdiff
path: root/diff-lib.c
diff options
context:
space:
mode:
authorVictoria Dye <vdye@github.com>2022-08-08 19:07:50 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-08-08 20:21:49 (GMT)
commit56d8a27124b9bdfcaece7728649104c9121141a6 (patch)
treee48a4822dc879a2d2238aa9cf56592db193a7123 /diff-lib.c
parent49ff3cb90fee9d0591b59a4c40ac2330163cab87 (diff)
downloadgit-56d8a27124b9bdfcaece7728649104c9121141a6.zip
git-56d8a27124b9bdfcaece7728649104c9121141a6.tar.gz
git-56d8a27124b9bdfcaece7728649104c9121141a6.tar.bz2
oneway_diff: handle removed sparse directories
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff-lib.c')
-rw-r--r--diff-lib.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/diff-lib.c b/diff-lib.c
index 7eb66a4..2edea41 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;