fsmonitor: force index write after full scan
authorBen Peart <benpeart@microsoft.com>
Tue, 10 Apr 2018 18:14:31 +0000 (14:14 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 11 Apr 2018 09:09:48 +0000 (18:09 +0900)
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>
fsmonitor.c
index 6d7bcd5d0ed8f2d3f5abdea2f26c6be72909b657..2b4d3bb0a250642e5ea3479fad217683bd7b0b0f 100644 (file)
@@ -185,6 +185,9 @@ void refresh_fsmonitor(struct index_state *istate)
                for (i = 0; i < istate->cache_nr; i++)
                        istate->cache[i]->ce_flags &= ~CE_FSMONITOR_VALID;
 
+               /* If we're going to check every file, ensure we save the results */
+               istate->cache_changed |= FSMONITOR_CHANGED;
+
                if (istate->untracked)
                        istate->untracked->use_fsmonitor = 0;
        }