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 <jeffhostetler@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff Hostetler committed
Feb 26, 2024 at 21:39 UTC
9e34e562805986b1ed0d1518a5822b9ec495960b
1 file changed
+8
-2
fsmonitor.c
+8
-2
@@ -196,8 +196,10 @@ static size_t handle_path_with_trailing_slash(
196
* do not know it is case-correct or -incorrect.
197
*
198
* Assume it is case-correct and try an exact match.
199
+ *
200
+ * Return the number of cache-entries that we invalidated.
201
*/
200
-static void handle_path_without_trailing_slash(
202
+static size_t handle_path_without_trailing_slash(
203
struct index_state *istate, const char *name, int pos)
204
{
205
/*
@@ -218,7 +220,9 @@ static void handle_path_without_trailing_slash(
220
* at that directory. (That is, assume no D/F conflicts.)
221
*/
222
istate->cache[pos]->ce_flags &= ~CE_FSMONITOR_VALID;
223
+ return 1;
224
} else {
225
+ size_t nr_in_cone;
226
struct strbuf work_path = STRBUF_INIT;
227
228
/*
@@ -232,8 +236,10 @@ static void handle_path_without_trailing_slash(
236
strbuf_add(&work_path, name, strlen(name));
237
strbuf_addch(&work_path, '/');
238
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);
241
strbuf_release(&work_path);
242
+ return nr_in_cone;
243
}
244
}
245