Skip to content

Commit 48f4cd7

Browse files
jeffhostetlergitster
authored andcommitted
fsmonitor: refactor untracked-cache invalidation
Update fsmonitor_refresh_callback() to use the new untracked_cache_invalidate_trimmed_path() to invalidate the cache using the observed pathname without needing to modify the caller's buffer. Previously, we modified the caller's buffer when the observed pathname contained a trailing slash (and did not restore it). This wasn't a problem for the single use-case caller, but felt dirty nontheless. In a later commit we will want to invalidate case-corrected versions of the pathname (using possibly borrowed pathnames from the name-hash or dir-name-hash) and we may not want to keep the tradition of altering the passed-in pathname. Signed-off-by: Jeff Hostetler <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3e4ffda commit 48f4cd7

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

fsmonitor.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -271,21 +271,16 @@ static void fsmonitor_refresh_callback(struct index_state *istate, char *name)
271271

272272
if (name[len - 1] == '/') {
273273
handle_path_with_trailing_slash(istate, name, pos);
274-
275-
/*
276-
* We need to remove the traling "/" from the path
277-
* for the untracked cache.
278-
*/
279-
name[len - 1] = '\0';
280274
} else {
281275
handle_path_without_trailing_slash(istate, name, pos);
282276
}
283277

284278
/*
285279
* Mark the untracked cache dirty even if it wasn't found in the index
286-
* as it could be a new untracked file.
280+
* as it could be a new untracked file. (Let the untracked cache
281+
* layer silently deal with any trailing slash.)
287282
*/
288-
untracked_cache_invalidate_path(istate, name, 0);
283+
untracked_cache_invalidate_trimmed_path(istate, name, 0);
289284
}
290285

291286
/*

0 commit comments

Comments
 (0)