Skip to content

Commit 1ec372a

Browse files
committed
fsmonitor: enhance existing comments
Signed-off-by: Jeff Hostetler <[email protected]>
1 parent 56056fc commit 1ec372a

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

fsmonitor.c

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,25 @@ void refresh_fsmonitor(struct index_state *istate)
351351
}
352352

353353
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+
*/
355367
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+
*/
357373
buf = query_result.buf;
358374
for (i = bol; i < query_result.len; i++) {
359375
if (buf[i] != '\0')
@@ -368,19 +384,26 @@ void refresh_fsmonitor(struct index_state *istate)
368384
if (istate->untracked)
369385
istate->untracked->use_fsmonitor = 1;
370386
} 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+
*/
374394
int is_cache_changed = 0;
375-
/* Mark all entries invalid */
395+
376396
for (i = 0; i < istate->cache_nr; i++) {
377397
if (istate->cache[i]->ce_flags & CE_FSMONITOR_VALID) {
378398
is_cache_changed = 1;
379399
istate->cache[i]->ce_flags &= ~CE_FSMONITOR_VALID;
380400
}
381401
}
382402

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+
*/
384407
if (is_cache_changed)
385408
istate->cache_changed |= FSMONITOR_CHANGED;
386409

0 commit comments

Comments
 (0)