Skip to content

Commit a524820

Browse files
jeffhostetlergitster
authored andcommitted
fsmonitor: return invalidated cache-entry count on directory event
Teach the refresh callback helper function for directory FSEvents to return the number of cache-entries that were invalidated in response to a directory event. This will be used in a later commit to help determine if the observed pathname in the FSEvent was a (possibly) case-incorrect directory prefix (on a case-insensitive filesystem) of one or more actual cache-entries. If there exists at least one case-insensitive prefix match, then we can assume that the directory is a (case-incorrect) prefix of at least one tracked item rather than a completely unknown/untracked file or directory. Signed-off-by: Jeff Hostetler <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7c97174 commit a524820

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

fsmonitor.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,20 @@ static void handle_path_without_trailing_slash(
253253
* same way and just invalidate the cache-entry and the untracked
254254
* cache (and in this case, the forward cache-entry scan won't find
255255
* anything and it doesn't hurt to let it run).
256+
*
257+
* Return the number of cache-entries that we invalidated. We will
258+
* use this later to determine if we need to attempt a second
259+
* case-insensitive search on case-insensitive file systems. That is,
260+
* if the search using the observed-case in the FSEvent yields any
261+
* results, we assume the prefix is case-correct. If there are no
262+
* matches, we still don't know if the observed path is simply
263+
* untracked or case-incorrect.
256264
*/
257-
static void handle_path_with_trailing_slash(
265+
static size_t handle_path_with_trailing_slash(
258266
struct index_state *istate, const char *name, int pos)
259267
{
260268
int i;
269+
size_t nr_in_cone = 0;
261270

262271
/*
263272
* Mark the untracked cache dirty for this directory path
@@ -276,7 +285,10 @@ static void handle_path_with_trailing_slash(
276285
if (!starts_with(istate->cache[i]->name, name))
277286
break;
278287
istate->cache[i]->ce_flags &= ~CE_FSMONITOR_VALID;
288+
nr_in_cone++;
279289
}
290+
291+
return nr_in_cone;
280292
}
281293

282294
static void fsmonitor_refresh_callback(struct index_state *istate, char *name)

0 commit comments

Comments
 (0)