@@ -183,6 +183,35 @@ static int query_fsmonitor_hook(struct repository *r,
183
183
return result ;
184
184
}
185
185
186
+ static void handle_path_with_trailing_slash (
187
+ struct index_state * istate , const char * name , int pos )
188
+ {
189
+ int i ;
190
+
191
+ /*
192
+ * The daemon can decorate directory events, such as
193
+ * moves or renames, with a trailing slash if the OS
194
+ * FS Event contains sufficient information, such as
195
+ * MacOS.
196
+ *
197
+ * Use this to invalidate the entire cone under that
198
+ * directory.
199
+ *
200
+ * We do not expect an exact match because the index
201
+ * does not normally contain directory entries, so we
202
+ * start at the insertion point and scan.
203
+ */
204
+ if (pos < 0 )
205
+ pos = - pos - 1 ;
206
+
207
+ /* Mark all entries for the folder invalid */
208
+ for (i = pos ; i < istate -> cache_nr ; i ++ ) {
209
+ if (!starts_with (istate -> cache [i ]-> name , name ))
210
+ break ;
211
+ istate -> cache [i ]-> ce_flags &= ~CE_FSMONITOR_VALID ;
212
+ }
213
+ }
214
+
186
215
static void fsmonitor_refresh_callback (struct index_state * istate , char * name )
187
216
{
188
217
int i , len = strlen (name );
@@ -193,28 +222,7 @@ static void fsmonitor_refresh_callback(struct index_state *istate, char *name)
193
222
name , pos );
194
223
195
224
if (name [len - 1 ] == '/' ) {
196
- /*
197
- * The daemon can decorate directory events, such as
198
- * moves or renames, with a trailing slash if the OS
199
- * FS Event contains sufficient information, such as
200
- * MacOS.
201
- *
202
- * Use this to invalidate the entire cone under that
203
- * directory.
204
- *
205
- * We do not expect an exact match because the index
206
- * does not normally contain directory entries, so we
207
- * start at the insertion point and scan.
208
- */
209
- if (pos < 0 )
210
- pos = - pos - 1 ;
211
-
212
- /* Mark all entries for the folder invalid */
213
- for (i = pos ; i < istate -> cache_nr ; i ++ ) {
214
- if (!starts_with (istate -> cache [i ]-> name , name ))
215
- break ;
216
- istate -> cache [i ]-> ce_flags &= ~CE_FSMONITOR_VALID ;
217
- }
225
+ handle_path_with_trailing_slash (istate , name , pos );
218
226
219
227
/*
220
228
* We need to remove the traling "/" from the path
0 commit comments