| 2424 | } |
| 2425 | |
| 2426 | static enum path_treatment treat_path(struct dir_struct *dir, |
| 2427 | struct untracked_cache_dir *untracked, |
| 2428 | struct cached_dir *cdir, |
| 2429 | struct index_state *istate, |
| 2430 | struct strbuf *path, |
| 2431 | int baselen, |
| 2432 | const struct pathspec *pathspec) |
| 2433 | { |
| 2434 | int has_path_in_index, dtype, excluded; |
| 2435 | |
| 2436 | if (!cdir->d_name) |
| 2437 | return treat_path_fast(dir, cdir, istate, path, |
| 2438 | baselen, pathspec); |
| 2439 | if (is_dot_or_dotdot(cdir->d_name) || !fspathcmp(cdir->d_name, ".git")) |
| 2440 | return path_none; |
| 2441 | strbuf_setlen(path, baselen); |
| 2442 | strbuf_addstr(path, cdir->d_name); |
| 2443 | if (simplify_away(path->buf, path->len, pathspec)) |
| 2444 | return path_none; |
| 2445 | |
| 2446 | dtype = resolve_dtype(cdir->d_type, istate, path->buf, path->len); |
| 2447 | |
| 2448 | /* Always exclude indexed files */ |
| 2449 | has_path_in_index = !!index_file_exists(istate, path->buf, path->len, |
| 2450 | ignore_case); |
| 2451 | if (dtype != DT_DIR && has_path_in_index) |
| 2452 | return path_none; |
| 2453 | |
| 2454 | /* |
| 2455 | * When we are looking at a directory P in the working tree, |
| 2456 | * there are three cases: |
| 2457 | * |
| 2458 | * (1) P exists in the index. Everything inside the directory P in |
| 2459 | * the working tree needs to go when P is checked out from the |
| 2460 | * index. |
| 2461 | * |
| 2462 | * (2) P does not exist in the index, but there is P/Q in the index. |
| 2463 | * We know P will stay a directory when we check out the contents |
| 2464 | * of the index, but we do not know yet if there is a directory |
| 2465 | * P/Q in the working tree to be killed, so we need to recurse. |
| 2466 | * |
| 2467 | * (3) P does not exist in the index, and there is no P/Q in the index |
| 2468 | * to require P to be a directory, either. Only in this case, we |
| 2469 | * know that everything inside P will not be killed without |
| 2470 | * recursing. |
| 2471 | */ |
| 2472 | if ((dir->flags & DIR_COLLECT_KILLED_ONLY) && |
| 2473 | (dtype == DT_DIR) && |
| 2474 | !has_path_in_index && |
| 2475 | (directory_exists_in_index(istate, path->buf, path->len) == index_nonexistent)) |
| 2476 | return path_none; |
| 2477 | |
| 2478 | excluded = is_excluded(dir, istate, path->buf, &dtype); |
| 2479 | |
| 2480 | /* |
| 2481 | * Excluded? If we don't explicitly want to show |
| 2482 | * ignored files, ignore it |
| 2483 | */ |
no test coverage detected