Skip to content

Commit 080b02c

Browse files
committed
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 fb47b56 commit 080b02c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

diff.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "parse-options.h"
2727
#include "help.h"
2828
#include "promisor-remote.h"
29+
#include "dir.h"
2930

3031
#ifdef NO_FAST_WORKING_DIRECTORY
3132
#define FAST_WORKING_DIRECTORY 0
@@ -3900,6 +3901,13 @@ static int reuse_worktree_file(struct index_state *istate,
39003901
if (!FAST_WORKING_DIRECTORY && !want_file && has_object_pack(oid))
39013902
return 0;
39023903

3904+
/*
3905+
* If this path does not match our sparse-checkout definition,
3906+
* then the file will not be in the working directory.
3907+
*/
3908+
if (!path_in_sparse_checkout(name, istate))
3909+
return 0;
3910+
39033911
/*
39043912
* Similarly, if we'd have to convert the file contents anyway, that
39053913
* makes the optimization not worthwhile.

0 commit comments

Comments
 (0)