Skip to content

Commit 57e8935

Browse files
committed
status: bugfix directory diff in sparse index
Adding the `recursive` flag for `wt_status_collect_changes_index` allows the diff function to recurse into sparse directories when differences occur within them. This corrects the issue observed in the `read-tree` sparse compatibility test in which particular merges resulted in a directory appearing as "modified" for sparse index repositories, rather than showing only the modified file within the directory. The `recursive` flag, even with a non-sparse index, does not substantially change the performance of `status`. From the `p2000` performance suite: Test before after ------------------------------------------------------------------------ 2000.2: git status (full-v3) 0.68(0.27+0.34) 0.64(0.26+0.33) -5.9% 2000.3: git status (full-v4) 0.68(0.27+0.35) 0.67(0.26+0.34) -1.5% 2000.4: git status (sparse-v3) 0.45(0.09+0.63) 0.45(0.10+0.74) +0.0% 2000.5: git status (sparse-v4) 0.45(0.09+0.62) 0.45(0.10+0.73) +0.0% Signed-off-by: Victoria Dye <[email protected]>
1 parent e6a55c8 commit 57e8935

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

t/t1092-sparse-checkout-compatibility.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -866,12 +866,7 @@ test_expect_success 'read-tree --prefix outside sparse definition' '
866866
test_cmp sparse-checkout/folder2/0/a full-checkout/folder2/0/a
867867
'
868868

869-
# TODO: predating any sparse index compatibility changes to `read-tree`, this
870-
# merge fails due to a status difference between the sparse index and non-sparse
871-
# index checkouts. Specifically, `folder2/0` (a directory) appears modified in
872-
# the sparse index, but `folder2/0/a` (correctly?) appears instead as a
873-
# modified entry in the non-sparse index checkouts.
874-
test_expect_failure 'read-tree --merge with directory-file conflicts' '
869+
test_expect_success 'read-tree --merge with directory-file conflicts' '
875870
init_repos &&
876871
877872
test_all_match git checkout -b test-branch rename-base &&

wt-status.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,13 @@ static void wt_status_collect_changes_index(struct wt_status *s)
651651
rev.diffopt.detect_rename = s->detect_rename >= 0 ? s->detect_rename : rev.diffopt.detect_rename;
652652
rev.diffopt.rename_limit = s->rename_limit >= 0 ? s->rename_limit : rev.diffopt.rename_limit;
653653
rev.diffopt.rename_score = s->rename_score >= 0 ? s->rename_score : rev.diffopt.rename_score;
654+
655+
/*
656+
* The `recursive` flag must be set to properly perform a diff on sparse
657+
* directory entries, if they exist
658+
*/
659+
rev.diffopt.flags.recursive = 1;
660+
654661
copy_pathspec(&rev.prune_data, &s->pathspec);
655662
run_diff_index(&rev, 1);
656663
object_array_clear(&rev.pending);

0 commit comments

Comments
 (0)