@@ -351,9 +351,25 @@ void refresh_fsmonitor(struct index_state *istate)
351
351
}
352
352
353
353
apply_results :
354
- /* a fsmonitor process can return '/' to indicate all entries are invalid */
354
+ /*
355
+ * The response from FSMonitor (excluding the header token) is
356
+ * either:
357
+ *
358
+ * [a] a (possibly empty) list of NUL delimited relative
359
+ * pathnames of changed paths. This list can contain
360
+ * files and directories. Directories have a trailing
361
+ * slash.
362
+ *
363
+ * [b] a single '/' to indicate the provider had no
364
+ * information and that we should consider everything
365
+ * invalid. We call this a trivial response.
366
+ */
355
367
if (query_success && query_result .buf [bol ] != '/' ) {
356
- /* Mark all entries returned by the monitor as dirty */
368
+ /*
369
+ * Mark all pathnames returned by the monitor as dirty.
370
+ *
371
+ * This updates both the cache-entries and the untracked-cache.
372
+ */
357
373
buf = query_result .buf ;
358
374
for (i = bol ; i < query_result .len ; i ++ ) {
359
375
if (buf [i ] != '\0' )
@@ -368,19 +384,26 @@ void refresh_fsmonitor(struct index_state *istate)
368
384
if (istate -> untracked )
369
385
istate -> untracked -> use_fsmonitor = 1 ;
370
386
} else {
371
-
372
- /* We only want to run the post index changed hook if we've actually changed entries, so keep track
373
- * if we actually changed entries or not */
387
+ /*
388
+ * We received a trivial response, so invalidate everything.
389
+ *
390
+ * We only want to run the post index changed hook if
391
+ * we've actually changed entries, so keep track if we
392
+ * actually changed entries or not.
393
+ */
374
394
int is_cache_changed = 0 ;
375
- /* Mark all entries invalid */
395
+
376
396
for (i = 0 ; i < istate -> cache_nr ; i ++ ) {
377
397
if (istate -> cache [i ]-> ce_flags & CE_FSMONITOR_VALID ) {
378
398
is_cache_changed = 1 ;
379
399
istate -> cache [i ]-> ce_flags &= ~CE_FSMONITOR_VALID ;
380
400
}
381
401
}
382
402
383
- /* If we're going to check every file, ensure we save the results */
403
+ /*
404
+ * If we're going to check every file, ensure we save
405
+ * the results.
406
+ */
384
407
if (is_cache_changed )
385
408
istate -> cache_changed |= FSMONITOR_CHANGED ;
386
409
0 commit comments