Skip to content

Commit 9e34e56

Browse files
jeffhostetlergitster
authored andcommitted
fsmonitor: return invalidated cache-entry count on non-directory event
Teach the refresh callback helper function for unqualified FSEvents (pathnames without a trailing slash) to return the number of cache-entries that were invalided in response to the event. This will be used in a later commit to help determine if the observed pathname was (possibly) case-incorrect when (on a case-insensitive file system). Signed-off-by: Jeff Hostetler <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 558d146 commit 9e34e56

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

fsmonitor.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,10 @@ static size_t handle_path_with_trailing_slash(
196196
* do not know it is case-correct or -incorrect.
197197
*
198198
* Assume it is case-correct and try an exact match.
199+
*
200+
* Return the number of cache-entries that we invalidated.
199201
*/
200-
static void handle_path_without_trailing_slash(
202+
static size_t handle_path_without_trailing_slash(
201203
struct index_state *istate, const char *name, int pos)
202204
{
203205
/*
@@ -218,7 +220,9 @@ static void handle_path_without_trailing_slash(
218220
* at that directory. (That is, assume no D/F conflicts.)
219221
*/
220222
istate->cache[pos]->ce_flags &= ~CE_FSMONITOR_VALID;
223+
return 1;
221224
} else {
225+
size_t nr_in_cone;
222226
struct strbuf work_path = STRBUF_INIT;
223227

224228
/*
@@ -232,8 +236,10 @@ static void handle_path_without_trailing_slash(
232236
strbuf_add(&work_path, name, strlen(name));
233237
strbuf_addch(&work_path, '/');
234238
pos = index_name_pos(istate, work_path.buf, work_path.len);
235-
handle_path_with_trailing_slash(istate, work_path.buf, pos);
239+
nr_in_cone = handle_path_with_trailing_slash(
240+
istate, work_path.buf, pos);
236241
strbuf_release(&work_path);
242+
return nr_in_cone;
237243
}
238244
}
239245

0 commit comments

Comments
 (0)