Skip to content

Commit 56d8a27

Browse files
vdyegitster
authored andcommitted
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 9eb00af (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 49ff3cb commit 56d8a27

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

diff-lib.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,11 @@ static void do_oneway_diff(struct unpack_trees_options *o,
466466
* Something removed from the tree?
467467
*/
468468
if (!idx) {
469+
if (S_ISSPARSEDIR(tree->ce_mode)) {
470+
diff_tree_oid(&tree->oid, NULL, tree->name, &revs->diffopt);
471+
return;
472+
}
473+
469474
diff_index_show_file(revs, "-", tree, &tree->oid, 1,
470475
tree->ce_mode, 0);
471476
return;

0 commit comments

Comments
 (0)