MCPcopy Index your code
hub / github.com/git/git / treat_path

Function treat_path

dir.c:2426–2512  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2424}
2425
2426static 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 */

Callers 2

read_directory_recursiveFunction · 0.85
treat_leading_pathFunction · 0.85

Calls 12

treat_path_fastFunction · 0.85
is_dot_or_dotdotFunction · 0.85
strbuf_setlenFunction · 0.85
strbuf_addstrFunction · 0.85
simplify_awayFunction · 0.85
resolve_dtypeFunction · 0.85
index_file_existsFunction · 0.85
is_excludedFunction · 0.85
strbuf_addchFunction · 0.85
treat_directoryFunction · 0.85
match_pathspecFunction · 0.85

Tested by

no test coverage detected