@@ -301,9 +301,25 @@ void refresh_fsmonitor(struct index_state *istate)
301
301
core_fsmonitor , query_success ? "success" : "failure" );
302
302
}
303
303
304
- /* a fsmonitor process can return '/' to indicate all entries are invalid */
304
+ /*
305
+ * The response from FSMonitor (excluding the header token) is
306
+ * either:
307
+ *
308
+ * [a] a (possibly empty) list of NUL delimited relative
309
+ * pathnames of changed paths. This list can contain
310
+ * files and directories. Directories have a trailing
311
+ * slash.
312
+ *
313
+ * [b] a single '/' to indicate the provider had no
314
+ * information and that we should consider everything
315
+ * invalid. We call this a trivial response.
316
+ */
305
317
if (query_success && query_result .buf [bol ] != '/' ) {
306
- /* Mark all entries returned by the monitor as dirty */
318
+ /*
319
+ * Mark all pathnames returned by the monitor as dirty.
320
+ *
321
+ * This updates both the cache-entries and the untracked-cache.
322
+ */
307
323
buf = query_result .buf ;
308
324
for (i = bol ; i < query_result .len ; i ++ ) {
309
325
if (buf [i ] != '\0' )
@@ -318,19 +334,26 @@ void refresh_fsmonitor(struct index_state *istate)
318
334
if (istate -> untracked )
319
335
istate -> untracked -> use_fsmonitor = 1 ;
320
336
} else {
321
-
322
- /* We only want to run the post index changed hook if we've actually changed entries, so keep track
323
- * if we actually changed entries or not */
337
+ /*
338
+ * We received a trivial response, so invalidate everything.
339
+ *
340
+ * We only want to run the post index changed hook if
341
+ * we've actually changed entries, so keep track if we
342
+ * actually changed entries or not.
343
+ */
324
344
int is_cache_changed = 0 ;
325
- /* Mark all entries invalid */
345
+
326
346
for (i = 0 ; i < istate -> cache_nr ; i ++ ) {
327
347
if (istate -> cache [i ]-> ce_flags & CE_FSMONITOR_VALID ) {
328
348
is_cache_changed = 1 ;
329
349
istate -> cache [i ]-> ce_flags &= ~CE_FSMONITOR_VALID ;
330
350
}
331
351
}
332
352
333
- /* If we're going to check every file, ensure we save the results */
353
+ /*
354
+ * If we're going to check every file, ensure we save
355
+ * the results.
356
+ */
334
357
if (is_cache_changed )
335
358
istate -> cache_changed |= FSMONITOR_CHANGED ;
336
359
0 commit comments