fsmonitor: force index write after full scan

fsmonitor currently only flags the index as dirty if the extension is being added or removed. This is a performance optimization that recognizes you can stat() a lot of files in less time than it takes to write out an updated index. This patch makes a small enhancement and flags the index dirty if we end up having to stat() all files and scan the entire working directory. The assumption being that must be expensive or you would not have turned on the feature. Signed-off-by: Ben Peart <benpeart@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ben Peart committed Apr 10, 2018 at 14:14 UTC ca598d5f2ab988935a5b882b44122cbfa5fd99f5
1 file changed +3
fsmonitor.c
+3
@@ -185,6 +185,9 @@ void refresh_fsmonitor(struct index_state *istate)
185 for (i = 0; i < istate->cache_nr; i++)
186 istate->cache[i]->ce_flags &= ~CE_FSMONITOR_VALID;
187
188 + /* If we're going to check every file, ensure we save the results */
189 + istate->cache_changed |= FSMONITOR_CHANGED;
190 +
191 if (istate->untracked)
192 istate->untracked->use_fsmonitor = 0;
193 }