{"thread":{"id":"48257","subject":"[PATCH v1] fsmonitor: force index write after full scan","startedAt":"2018-04-10T18:15:06Z","lastAt":"2018-04-10T18:15:06Z","messageCount":1,"participants":["Ben Peart"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"344360","messageId":"20180410181431.21024-1-benpeart@microsoft.com","threadId":"48257","inReplyTo":null,"subject":"[PATCH v1] fsmonitor: force index write after full scan","fromName":"Ben Peart","fromEmail":"benpeart@microsoft.com","sentAt":"2018-04-10T18:14:31Z","receivedAt":"2018-04-10T18:15:06Z","isPatch":true,"sender":{"key":"benpeart@microsoft.com","avatar":"https://avatars.githubusercontent.com/u/15252029?v=4"},"body":"fsmonitor currently only flags the index as dirty if the extension is being\nadded or removed. This is a performance optimization that recognizes you can\nstat() a lot of files in less time than it takes to write out an updated index.\n\nThis patch makes a small enhancement and flags the index dirty if we end up\nhaving to stat() all files and scan the entire working directory.  The assumption\nbeing that must be expensive or you would not have turned on the feature.\n\nSigned-off-by: Ben Peart <benpeart@microsoft.com>\n---\n\nNotes:\n    Base Ref:\n    Web-Diff: https://github.com/benpeart/git/commit/4d39ddc2f9\n    Checkout: git fetch https://github.com/benpeart/git fsmonitor-perf-v1 && git checkout 4d39ddc2f9\n\n fsmonitor.c | 3 +++\n 1 file changed, 3 insertions(+)\n\ndiff --git a/fsmonitor.c b/fsmonitor.c\nindex eb4e642256..ed3d1a074d 100644\n--- a/fsmonitor.c\n+++ b/fsmonitor.c\n@@ -185,6 +185,9 @@ void refresh_fsmonitor(struct index_state *istate)\n \t\tfor (i = 0; i < istate->cache_nr; i++)\n \t\t\tistate->cache[i]->ce_flags &= ~CE_FSMONITOR_VALID;\n \n+\t\t/* If we're going to check every file, ensure we save the results */\n+\t\tistate->cache_changed |= FSMONITOR_CHANGED;\n+\n \t\tif (istate->untracked)\n \t\t\tistate->untracked->use_fsmonitor = 0;\n \t}\n\nbase-commit: 0ac4dfac5000ef8de7966a3b7229275567d2d707\n-- \n2.17.0.windows.1\n\n"}]}