Skip to content

Commit a579f1e

Browse files
derrickstoleemjcheetham
authored andcommitted
diff: ignore sparse paths in diffstat
The diff_populate_filespec() method is used to describe the diff after a merge operation is complete, especially when a conflict appears. In order to avoid expanding a sparse index, the reuse_worktree_file() needs to be adapted to ignore files that are outside of the sparse-checkout cone. The file names and OIDs used for this check come from the merged tree in the case of the ORT strategy, not the index, hence the ability to look into these paths without having already expanded the index. Signed-off-by: Derrick Stolee <[email protected]>
1 parent aa48677 commit a579f1e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

diff.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4044,6 +4044,13 @@ static int reuse_worktree_file(struct index_state *istate,
40444044
if (!FAST_WORKING_DIRECTORY && !want_file && has_object_pack(oid))
40454045
return 0;
40464046

4047+
/*
4048+
* If this path does not match our sparse-checkout definition,
4049+
* then the file will not be in the working directory.
4050+
*/
4051+
if (!path_in_sparse_checkout(name, istate))
4052+
return 0;
4053+
40474054
/*
40484055
* Similarly, if we'd have to convert the file contents anyway, that
40494056
* makes the optimization not worthwhile.

0 commit comments

Comments
 (0)