Skip to content

Commit 2387980

Browse files
derrickstoleedscho
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 f6af0f7 commit 2387980

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
@@ -4046,6 +4046,13 @@ static int reuse_worktree_file(struct index_state *istate,
40464046
has_object_pack(istate->repo, oid))
40474047
return 0;
40484048

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

0 commit comments

Comments
 (0)