MCPcopy Create free account
hub / github.com/git/git / handle_using_name_hash_icase

Function handle_using_name_hash_icase

fsmonitor.c:216–259  ·  view source on GitHub ↗

* Use the name-hash to do a case-insensitive cache-entry lookup with * the pathname and invalidate the cache-entry. * * Returns the number of cache-entries that we invalidated. */

Source from the content-addressed store, hash-verified

214 * Returns the number of cache-entries that we invalidated.
215 */
216static size_t handle_using_name_hash_icase(
217 struct index_state *istate, const char *name)
218{
219 struct cache_entry *ce = NULL;
220
221 ce = index_file_exists(istate, name, strlen(name), 1);
222 if (!ce)
223 return 0;
224
225 /*
226 * A case-insensitive search in the name-hash using the
227 * observed pathname found a cache-entry, so the observed path
228 * is case-incorrect. Invalidate the cache-entry and use the
229 * correct spelling from the cache-entry to invalidate the
230 * untracked-cache. Since we now have sparse-directories in
231 * the index, the observed pathname may represent a regular
232 * file or a sparse-index directory.
233 *
234 * Note that we should not have seen FSEvents for a
235 * sparse-index directory, but we handle it just in case.
236 *
237 * Either way, we know that there are not any cache-entries for
238 * children inside the cone of the directory, so we don't need to
239 * do the usual scan.
240 */
241 trace_printf_key(&trace_fsmonitor,
242 "fsmonitor_refresh_callback MAP: '%s' '%s'",
243 name, ce->name);
244
245 /*
246 * NEEDSWORK: We used the name-hash to find the correct
247 * case-spelling of the pathname in the cache-entry[], so
248 * technically this is a tracked file or a sparse-directory.
249 * It should not have any entries in the untracked-cache, so
250 * we should not need to use the case-corrected spelling to
251 * invalidate the untracked-cache. So we may not need to
252 * do this. For now, I'm going to be conservative and always
253 * do it; we can revisit this later.
254 */
255 untracked_cache_invalidate_trimmed_path(istate, ce->name, 0);
256
257 invalidate_ce_fsm(ce);
258 return 1;
259}
260
261/*
262 * Use the dir-name-hash to find the correct-case spelling of the

Callers 1

Calls 3

index_file_existsFunction · 0.85
invalidate_ce_fsmFunction · 0.85

Tested by

no test coverage detected