Skip to content

Commit d9fa67f

Browse files
jeffhostetlerdscho
authored andcommitted
fsmonitor: enhance existing comments
Signed-off-by: Jeff Hostetler <[email protected]>
1 parent d562690 commit d9fa67f

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
@@ -301,9 +301,25 @@ void refresh_fsmonitor(struct index_state *istate)
301301
core_fsmonitor, query_success ? "success" : "failure");
302302
}
303303

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+
*/
305317
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+
*/
307323
buf = query_result.buf;
308324
for (i = bol; i < query_result.len; i++) {
309325
if (buf[i] != '\0')
@@ -318,19 +334,26 @@ void refresh_fsmonitor(struct index_state *istate)
318334
if (istate->untracked)
319335
istate->untracked->use_fsmonitor = 1;
320336
} 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+
*/
324344
int is_cache_changed = 0;
325-
/* Mark all entries invalid */
345+
326346
for (i = 0; i < istate->cache_nr; i++) {
327347
if (istate->cache[i]->ce_flags & CE_FSMONITOR_VALID) {
328348
is_cache_changed = 1;
329349
istate->cache[i]->ce_flags &= ~CE_FSMONITOR_VALID;
330350
}
331351
}
332352

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+
*/
334357
if (is_cache_changed)
335358
istate->cache_changed |= FSMONITOR_CHANGED;
336359

0 commit comments

Comments
 (0)