Skip to content

Commit 4f3d6d0

Browse files
nipunn1313gitster
authored andcommitted
fsmonitor: skip lstat deletion check during git diff-index
Teach git to honor fsmonitor rather than issuing an lstat when checking for dirty local deletes. Eliminates O(files) lstats during `git diff HEAD` Signed-off-by: Nipunn Koorapati <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a5828ae commit 4f3d6d0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

diff-lib.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
*/
3131
static int check_removed(const struct cache_entry *ce, struct stat *st)
3232
{
33-
if (lstat(ce->name, st) < 0) {
33+
if (!(ce->ce_flags & CE_FSMONITOR_VALID) && lstat(ce->name, st) < 0) {
3434
if (!is_missing_file_error(errno))
3535
return -1;
3636
return 1;
@@ -574,13 +574,16 @@ int run_diff_index(struct rev_info *revs, unsigned int option)
574574
struct object_id oid;
575575
const char *name;
576576
char merge_base_hex[GIT_MAX_HEXSZ + 1];
577+
struct index_state *istate = revs->diffopt.repo->index;
577578

578579
if (revs->pending.nr != 1)
579580
BUG("run_diff_index must be passed exactly one tree");
580581

581582
trace_performance_enter();
582583
ent = revs->pending.objects;
583584

585+
refresh_fsmonitor(istate);
586+
584587
if (merge_base) {
585588
diff_get_merge_base(revs, &oid);
586589
name = oid_to_hex_r(merge_base_hex, &oid);

0 commit comments

Comments
 (0)