| 2970 | } |
| 2971 | |
| 2972 | static struct untracked_cache_dir *validate_untracked_cache(struct dir_struct *dir, |
| 2973 | int base_len, |
| 2974 | const struct pathspec *pathspec, |
| 2975 | struct index_state *istate) |
| 2976 | { |
| 2977 | struct untracked_cache_dir *root; |
| 2978 | static int untracked_cache_disabled = -1; |
| 2979 | |
| 2980 | if (!dir->untracked) |
| 2981 | return NULL; |
| 2982 | if (untracked_cache_disabled < 0) |
| 2983 | untracked_cache_disabled = git_env_bool("GIT_DISABLE_UNTRACKED_CACHE", 0); |
| 2984 | if (untracked_cache_disabled) |
| 2985 | return NULL; |
| 2986 | |
| 2987 | /* |
| 2988 | * We only support $GIT_COMMON_DIR/info/exclude and core.excludesfile |
| 2989 | * as the global ignore rule files. Any other additions |
| 2990 | * (e.g. from command line) invalidate the cache. This |
| 2991 | * condition also catches running setup_standard_excludes() |
| 2992 | * before setting dir->untracked! |
| 2993 | */ |
| 2994 | if (dir->internal.unmanaged_exclude_files) |
| 2995 | return NULL; |
| 2996 | |
| 2997 | /* |
| 2998 | * Optimize for the main use case only: whole-tree git |
| 2999 | * status. More work involved in treat_leading_path() if we |
| 3000 | * use cache on just a subset of the worktree. pathspec |
| 3001 | * support could make the matter even worse. |
| 3002 | */ |
| 3003 | if (base_len || (pathspec && pathspec->nr)) |
| 3004 | return NULL; |
| 3005 | |
| 3006 | /* We don't support collecting ignore files */ |
| 3007 | if (dir->flags & (DIR_SHOW_IGNORED | DIR_SHOW_IGNORED_TOO | |
| 3008 | DIR_COLLECT_IGNORED)) |
| 3009 | return NULL; |
| 3010 | |
| 3011 | /* |
| 3012 | * If we use .gitignore in the cache and now you change it to |
| 3013 | * .gitexclude, everything will go wrong. |
| 3014 | */ |
| 3015 | if (dir->exclude_per_dir != dir->untracked->exclude_per_dir && |
| 3016 | strcmp(dir->exclude_per_dir, dir->untracked->exclude_per_dir)) |
| 3017 | return NULL; |
| 3018 | |
| 3019 | /* |
| 3020 | * EXC_CMDL is not considered in the cache. If people set it, |
| 3021 | * skip the cache. |
| 3022 | */ |
| 3023 | if (dir->internal.exclude_list_group[EXC_CMDL].nr) |
| 3024 | return NULL; |
| 3025 | |
| 3026 | if (!ident_in_untracked(dir->untracked)) { |
| 3027 | warning(_("untracked cache is disabled on this system or location")); |
| 3028 | return NULL; |
| 3029 | } |
no test coverage detected