* The daemon sent an observed pathname without a trailing slash. * (This is the normal case.) We do not know if it is a tracked or * untracked file, a sparse-directory, or a populated directory (on a * platform such as Windows where FSEvents are not qualified). * * The pathname contains the observed case reported by the FS. We * do not know it is case-correct or -incorrect. * * Assume it
| 328 | * Return the number of cache-entries that we invalidated. |
| 329 | */ |
| 330 | static size_t handle_path_without_trailing_slash( |
| 331 | struct index_state *istate, const char *name, int pos) |
| 332 | { |
| 333 | /* |
| 334 | * Mark the untracked cache dirty for this path (regardless of |
| 335 | * whether or not we find an exact match for it in the index). |
| 336 | * Since the path is unqualified (no trailing slash hint in the |
| 337 | * FSEvent), it may refer to a file or directory. So we should |
| 338 | * not assume one or the other and should always let the untracked |
| 339 | * cache decide what needs to invalidated. |
| 340 | */ |
| 341 | untracked_cache_invalidate_trimmed_path(istate, name, 0); |
| 342 | |
| 343 | if (pos >= 0) { |
| 344 | /* |
| 345 | * An exact match on a tracked file. We assume that we |
| 346 | * do not need to scan forward for a sparse-directory |
| 347 | * cache-entry with the same pathname, nor for a cone |
| 348 | * at that directory. (That is, assume no D/F conflicts.) |
| 349 | */ |
| 350 | invalidate_ce_fsm(istate->cache[pos]); |
| 351 | return 1; |
| 352 | } else { |
| 353 | size_t nr_in_cone; |
| 354 | struct strbuf work_path = STRBUF_INIT; |
| 355 | |
| 356 | /* |
| 357 | * The negative "pos" gives us the suggested insertion |
| 358 | * point for the pathname (without the trailing slash). |
| 359 | * We need to see if there is a directory with that |
| 360 | * prefix, but there can be lots of pathnames between |
| 361 | * "foo" and "foo/" like "foo-" or "foo-bar", so we |
| 362 | * don't want to do our own scan. |
| 363 | */ |
| 364 | strbuf_add(&work_path, name, strlen(name)); |
| 365 | strbuf_addch(&work_path, '/'); |
| 366 | pos = index_name_pos(istate, work_path.buf, work_path.len); |
| 367 | nr_in_cone = handle_path_with_trailing_slash( |
| 368 | istate, work_path.buf, pos); |
| 369 | strbuf_release(&work_path); |
| 370 | return nr_in_cone; |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | /* |
| 375 | * The daemon can decorate directory events, such as a move or rename, |
no test coverage detected