summaryrefslogtreecommitdiff
path: root/diff-lib.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-11-09 14:06:25 -0800
committerJunio C Hamano <gitster@pobox.com>2020-11-09 14:06:25 -0800
commitbf69da56c9e8adac1eee91b7a8b000363156c583 (patch)
tree52bb09ed0e03e9d5a415ef5b71c9cc4031acf14f /diff-lib.c
parentb3ae46a93639e083251b2dd4f1636c2a8df6a46b (diff)
parent2bfa953e5daf3253cc5fae2de2c68fbd206dfe12 (diff)
downloadgit-bf69da56c9e8adac1eee91b7a8b000363156c583.tar.gz
Merge branch 'nk/diff-files-vs-fsmonitor'
"git diff" and other commands that share the same machinery to compare with working tree files have been taught to take advantage of the fsmonitor data when available. * nk/diff-files-vs-fsmonitor: p7519-fsmonitor: add a git add benchmark p7519-fsmonitor: refactor to avoid code duplication perf lint: add make test-lint to perf tests t/perf: add fsmonitor perf test for git diff t/perf/p7519-fsmonitor.sh: warm cache on first git status t/perf/README: elaborate on output format fsmonitor: use fsmonitor data in `git diff`
Diffstat (limited to 'diff-lib.c')
-rw-r--r--diff-lib.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/diff-lib.c b/diff-lib.c
index d18a118249..082e249fc3 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -98,6 +98,8 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
diff_set_mnemonic_prefix(&revs->diffopt, "i/", "w/");
+ refresh_fsmonitor(istate);
+
if (diff_unmerged_stage < 0)
diff_unmerged_stage = 2;
entries = istate->cache_nr;
@@ -198,8 +200,17 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
if (ce_uptodate(ce) || ce_skip_worktree(ce))
continue;
- /* If CE_VALID is set, don't look at workdir for file removal */
- if (ce->ce_flags & CE_VALID) {
+ /*
+ * When CE_VALID is set (via "update-index --assume-unchanged"
+ * or via adding paths while core.ignorestat is set to true),
+ * the user has promised that the working tree file for that
+ * path will not be modified. When CE_FSMONITOR_VALID is true,
+ * the fsmonitor knows that the path hasn't been modified since
+ * we refreshed the cached stat information. In either case,
+ * we do not have to stat to see if the path has been removed
+ * or modified.
+ */
+ if (ce->ce_flags & (CE_VALID | CE_FSMONITOR_VALID)) {
changed = 0;
newmode = ce->ce_mode;
} else {