Skip to content

Commit 3ca5d4c

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 <dstolee@microsoft.com>
1 parent 1a38d33 commit 3ca5d4c

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
@@ -4065,6 +4065,13 @@ static int reuse_worktree_file(struct index_state *istate,
40654065
has_object_pack(istate->repo, oid))
40664066
return 0;
40674067

4068+
/*
4069+
* If this path does not match our sparse-checkout definition,
4070+
* then the file will not be in the working directory.
4071+
*/
4072+
if (!path_in_sparse_checkout(name, istate))
4073+
return 0;
4074+
40684075
/*
40694076
* Similarly, if we'd have to convert the file contents anyway, that
40704077
* makes the optimization not worthwhile.

0 commit comments

Comments
 (0)