@@ -190,13 +190,34 @@ int fsmonitor_is_trivial_response(const struct strbuf *query_result)
190
190
return is_trivial ;
191
191
}
192
192
193
- static void fsmonitor_refresh_callback (struct index_state * istate , const char * name )
193
+ static void fsmonitor_refresh_callback (struct index_state * istate , char * name )
194
194
{
195
- int pos = index_name_pos (istate , name , strlen (name ));
195
+ int i , len = strlen (name );
196
+ if (name [len - 1 ] == '/' ) {
197
+
198
+ /*
199
+ * TODO We should binary search to find the first path with
200
+ * TODO this directory prefix. Then linearly update entries
201
+ * TODO while the prefix matches. Taking care to search without
202
+ * TODO the trailing slash -- because '/' sorts after a few
203
+ * TODO interesting special chars, like '.' and ' '.
204
+ */
205
+
206
+ /* Mark all entries for the folder invalid */
207
+ for (i = 0 ; i < istate -> cache_nr ; i ++ ) {
208
+ if (istate -> cache [i ]-> ce_flags & CE_FSMONITOR_VALID &&
209
+ starts_with (istate -> cache [i ]-> name , name ))
210
+ istate -> cache [i ]-> ce_flags &= ~CE_FSMONITOR_VALID ;
211
+ }
212
+ /* Need to remove the / from the path for the untracked cache */
213
+ name [len - 1 ] = '\0' ;
214
+ } else {
215
+ int pos = index_name_pos (istate , name , strlen (name ));
196
216
197
- if (pos >= 0 ) {
198
- struct cache_entry * ce = istate -> cache [pos ];
199
- ce -> ce_flags &= ~CE_FSMONITOR_VALID ;
217
+ if (pos >= 0 ) {
218
+ struct cache_entry * ce = istate -> cache [pos ];
219
+ ce -> ce_flags &= ~CE_FSMONITOR_VALID ;
220
+ }
200
221
}
201
222
202
223
/*
0 commit comments