* Use the dir-name-hash to find the correct-case spelling of the * directory. Use the canonical spelling to invalidate all of the * cache-entries within the matching cone. * * Returns the number of cache-entries that we invalidated. */
| 266 | * Returns the number of cache-entries that we invalidated. |
| 267 | */ |
| 268 | static size_t handle_using_dir_name_hash_icase( |
| 269 | struct index_state *istate, const char *name) |
| 270 | { |
| 271 | struct strbuf canonical_path = STRBUF_INIT; |
| 272 | int pos; |
| 273 | size_t len = strlen(name); |
| 274 | size_t nr_in_cone; |
| 275 | |
| 276 | if (name[len - 1] == '/') |
| 277 | len--; |
| 278 | |
| 279 | if (!index_dir_find(istate, name, len, &canonical_path)) |
| 280 | return 0; /* name is untracked */ |
| 281 | |
| 282 | if (!memcmp(name, canonical_path.buf, canonical_path.len)) { |
| 283 | strbuf_release(&canonical_path); |
| 284 | /* |
| 285 | * NEEDSWORK: Our caller already tried an exact match |
| 286 | * and failed to find one. They called us to do an |
| 287 | * ICASE match, so we should never get an exact match, |
| 288 | * so we could promote this to a BUG() here if we |
| 289 | * wanted to. It doesn't hurt anything to just return |
| 290 | * 0 and go on because we should never get here. Or we |
| 291 | * could just get rid of the memcmp() and this "if" |
| 292 | * clause completely. |
| 293 | */ |
| 294 | BUG("handle_using_dir_name_hash_icase(%s) did not exact match", |
| 295 | name); |
| 296 | } |
| 297 | |
| 298 | trace_printf_key(&trace_fsmonitor, |
| 299 | "fsmonitor_refresh_callback MAP: '%s' '%s'", |
| 300 | name, canonical_path.buf); |
| 301 | |
| 302 | /* |
| 303 | * The dir-name-hash only tells us the corrected spelling of |
| 304 | * the prefix. We have to use this canonical path to do a |
| 305 | * lookup in the cache-entry array so that we repeat the |
| 306 | * original search using the case-corrected spelling. |
| 307 | */ |
| 308 | strbuf_addch(&canonical_path, '/'); |
| 309 | pos = index_name_pos(istate, canonical_path.buf, |
| 310 | canonical_path.len); |
| 311 | nr_in_cone = handle_path_with_trailing_slash( |
| 312 | istate, canonical_path.buf, pos); |
| 313 | strbuf_release(&canonical_path); |
| 314 | return nr_in_cone; |
| 315 | } |
| 316 | |
| 317 | /* |
| 318 | * The daemon sent an observed pathname without a trailing slash. |
no test coverage detected