summary refs log tree commit diff
path: root/diff-lib.c
diff options
context:
space:
mode:
authorNipunn Koorapati <nipunn@dropbox.com>2021-03-17 21:22:21 +0000
committerJunio C Hamano <gitster@pobox.com>2021-03-18 13:31:11 -0700
commit4f3d6d026176a48991c4e5ff95c8db583af38148 (patch)
tree119a96236731fba661b8ee962f215ef7963e8510 /diff-lib.c
parenta5828ae6b52137b913b978e16cd2334482eb4c1f (diff)
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 <nipunn@dropbox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff-lib.c')
-rw-r--r--diff-lib.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/diff-lib.c b/diff-lib.c
index b73cc1859a..3fb538ad18 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -30,7 +30,7 @@
  */
 static int check_removed(const struct cache_entry *ce, struct stat *st)
 {
-	if (lstat(ce->name, st) < 0) {
+	if (!(ce->ce_flags & CE_FSMONITOR_VALID) && lstat(ce->name, st) < 0) {
 		if (!is_missing_file_error(errno))
 			return -1;
 		return 1;
@@ -574,6 +574,7 @@ int run_diff_index(struct rev_info *revs, unsigned int option)
 	struct object_id oid;
 	const char *name;
 	char merge_base_hex[GIT_MAX_HEXSZ + 1];
+	struct index_state *istate = revs->diffopt.repo->index;
 
 	if (revs->pending.nr != 1)
 		BUG("run_diff_index must be passed exactly one tree");
@@ -581,6 +582,8 @@ int run_diff_index(struct rev_info *revs, unsigned int option)
 	trace_performance_enter();
 	ent = revs->pending.objects;
 
+	refresh_fsmonitor(istate);
+
 	if (merge_base) {
 		diff_get_merge_base(revs, &oid);
 		name = oid_to_hex_r(merge_base_hex, &oid);