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

Function read_directory

dir.c:3135–3184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3133}
3134
3135int read_directory(struct dir_struct *dir, struct index_state *istate,
3136 const char *path, int len, const struct pathspec *pathspec)
3137{
3138 struct untracked_cache_dir *untracked;
3139
3140 trace2_region_enter("dir", "read_directory", istate->repo);
3141 dir->internal.visited_paths = 0;
3142 dir->internal.visited_directories = 0;
3143
3144 if (has_symlink_leading_path(path, len)) {
3145 trace2_region_leave("dir", "read_directory", istate->repo);
3146 return dir->nr;
3147 }
3148
3149 untracked = validate_untracked_cache(dir, len, pathspec, istate);
3150 if (!untracked)
3151 /*
3152 * make sure untracked cache code path is disabled,
3153 * e.g. prep_exclude()
3154 */
3155 dir->untracked = NULL;
3156 if (!len || treat_leading_path(dir, istate, path, len, pathspec))
3157 read_directory_recursive(dir, istate, path, len, untracked, 0, 0, pathspec);
3158 QSORT(dir->entries, dir->nr, cmp_dir_entry);
3159 QSORT(dir->ignored, dir->ignored_nr, cmp_dir_entry);
3160
3161 emit_traversal_statistics(dir, istate->repo, path, len);
3162
3163 trace2_region_leave("dir", "read_directory", istate->repo);
3164 if (dir->untracked) {
3165 static int force_untracked_cache = -1;
3166
3167 if (force_untracked_cache < 0)
3168 force_untracked_cache =
3169 git_env_bool("GIT_FORCE_UNTRACKED_CACHE", -1);
3170 if (force_untracked_cache < 0)
3171 force_untracked_cache = (istate->repo->settings.core_untracked_cache == UNTRACKED_CACHE_WRITE);
3172 if (force_untracked_cache &&
3173 dir->untracked == istate->untracked &&
3174 (dir->untracked->dir_opened ||
3175 dir->untracked->gitignore_invalidated ||
3176 dir->untracked->dir_invalidated))
3177 istate->cache_changed |= UNTRACKED_CHANGED;
3178 if (dir->untracked != istate->untracked) {
3179 FREE_AND_NULL(dir->untracked);
3180 }
3181 }
3182
3183 return dir->nr;
3184}
3185
3186int file_exists(const char *f)
3187{

Callers 2

fill_directoryFunction · 0.85

Calls 6

has_symlink_leading_pathFunction · 0.85
validate_untracked_cacheFunction · 0.85
treat_leading_pathFunction · 0.85
read_directory_recursiveFunction · 0.85
git_env_boolFunction · 0.85

Tested by

no test coverage detected