Skip to content

Commit c92731b

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 9f8f66d commit c92731b

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
@@ -4040,6 +4040,13 @@ static int reuse_worktree_file(struct index_state *istate,
40404040
if (!FAST_WORKING_DIRECTORY && !want_file && has_object_pack(oid))
40414041
return 0;
40424042

4043+
/*
4044+
* If this path does not match our sparse-checkout definition,
4045+
* then the file will not be in the working directory.
4046+
*/
4047+
if (!path_in_sparse_checkout(name, istate))
4048+
return 0;
4049+
40434050
/*
40444051
* Similarly, if we'd have to convert the file contents anyway, that
40454052
* makes the optimization not worthwhile.

0 commit comments

Comments
 (0)