summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorDerrick Stolee <derrickstolee@github.com>2022-02-17 21:00:29 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-02-17 22:47:13 (GMT)
commit26b89464219d3cfb0af7dc2274751eff641dea8d (patch)
tree5948c40e71e1bfe8b4460f1e8c76314b7b6952f2 /dir.c
parent45fe28c951c3e70666ee4ef8379772851a8e4d32 (diff)
downloadgit-26b89464219d3cfb0af7dc2274751eff641dea8d.zip
git-26b89464219d3cfb0af7dc2274751eff641dea8d.tar.gz
git-26b89464219d3cfb0af7dc2274751eff641dea8d.tar.bz2
dir: force untracked cache with core.untrackedCache
The GIT_FORCE_UNTRACKED_CACHE environment variable writes the untracked cache more frequently than the core.untrackedCache config variable. This is due to how read_directory() handles the creation of an untracked cache. Before this change, Git would not create the untracked cache extension for an index that did not already have one. Users would need to run a command such as 'git update-index --untracked-cache' before the index would actually contain an untracked cache. In particular, users noticed that the untracked cache would not appear even with core.untrackedCache=true. Some users reported setting GIT_FORCE_UNTRACKED_CACHE=1 in their engineering system environment to ensure the untracked cache would be created. The decision to not write the untracked cache without an environment variable tracks back to fc9ecbeb9 (dir.c: don't flag the index as dirty for changes to the untracked cache, 2018-02-05). The motivation of that change is that writing the index is expensive, and if the untracked cache is the only thing that needs to be written, then it is more expensive than the benefit of the cache. However, this also means that the untracked cache never gets populated, so the user who enabled it via config does not actually get the extension until running 'git update-index --untracked-cache' manually or using the environment variable. We have had a version of this change in the microsoft/git fork for a few major releases now. It has been working well to get users into a good state. Yes, that first index write is slow, but the remaining index writes are much faster than they would be without this change. Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/dir.c b/dir.c
index d91295f..79a5f69 100644
--- a/dir.c
+++ b/dir.c
@@ -2936,7 +2936,9 @@ int read_directory(struct dir_struct *dir, struct index_state *istate,
if (force_untracked_cache < 0)
force_untracked_cache =
- git_env_bool("GIT_FORCE_UNTRACKED_CACHE", 0);
+ git_env_bool("GIT_FORCE_UNTRACKED_CACHE", -1);
+ if (force_untracked_cache < 0)
+ force_untracked_cache = (istate->repo->settings.core_untracked_cache == UNTRACKED_CACHE_WRITE);
if (force_untracked_cache &&
dir->untracked == istate->untracked &&
(dir->untracked->dir_opened ||