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

Function valid_cached_dir

dir.c:2523–2569  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2521}
2522
2523static int valid_cached_dir(struct dir_struct *dir,
2524 struct untracked_cache_dir *untracked,
2525 struct index_state *istate,
2526 struct strbuf *path,
2527 int check_only)
2528{
2529 struct stat st;
2530
2531 if (!untracked)
2532 return 0;
2533
2534 /*
2535 * With fsmonitor, we can trust the untracked cache's valid field.
2536 */
2537 refresh_fsmonitor(istate);
2538 if (!(dir->untracked->use_fsmonitor && untracked->valid)) {
2539 if (lstat(path->len ? path->buf : ".", &st)) {
2540 memset(&untracked->stat_data, 0, sizeof(untracked->stat_data));
2541 return 0;
2542 }
2543 if (!untracked->valid ||
2544 match_stat_data_racy(istate, &untracked->stat_data, &st)) {
2545 fill_stat_data(&untracked->stat_data, &st);
2546 return 0;
2547 }
2548 }
2549
2550 if (untracked->check_only != !!check_only)
2551 return 0;
2552
2553 /*
2554 * prep_exclude will be called eventually on this directory,
2555 * but it's called much later in last_matching_pattern(). We
2556 * need it now to determine the validity of the cache for this
2557 * path. The next calls will be nearly no-op, the way
2558 * prep_exclude() is designed.
2559 */
2560 if (path->len && path->buf[path->len - 1] != '/') {
2561 strbuf_addch(path, '/');
2562 prep_exclude(dir, istate, path->buf, path->len);
2563 strbuf_setlen(path, path->len - 1);
2564 } else
2565 prep_exclude(dir, istate, path->buf, path->len);
2566
2567 /* hopefully prep_exclude() haven't invalidated this entry... */
2568 return untracked->valid;
2569}
2570
2571static int open_cached_dir(struct cached_dir *cdir,
2572 struct dir_struct *dir,

Callers 1

open_cached_dirFunction · 0.85

Calls 6

refresh_fsmonitorFunction · 0.85
match_stat_data_racyFunction · 0.85
fill_stat_dataFunction · 0.85
strbuf_addchFunction · 0.85
prep_excludeFunction · 0.85
strbuf_setlenFunction · 0.85

Tested by

no test coverage detected