Skip to content

Commit cdda65a

Browse files
committed
Merge branch 'bp/untracked-cache-noflush'
Writing out the index file when the only thing that changed in it is the untracked cache information is often wasteful, and this has been optimized out. * bp/untracked-cache-noflush: untracked cache: use git_env_bool() not getenv() for customization dir.c: don't flag the index as dirty for changes to the untracked cache
2 parents 74735c9 + 026336c commit cdda65a

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

dir.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2172,8 +2172,13 @@ static struct untracked_cache_dir *validate_untracked_cache(struct dir_struct *d
21722172
const struct pathspec *pathspec)
21732173
{
21742174
struct untracked_cache_dir *root;
2175+
static int untracked_cache_disabled = -1;
21752176

2176-
if (!dir->untracked || getenv("GIT_DISABLE_UNTRACKED_CACHE"))
2177+
if (!dir->untracked)
2178+
return NULL;
2179+
if (untracked_cache_disabled < 0)
2180+
untracked_cache_disabled = git_env_bool("GIT_DISABLE_UNTRACKED_CACHE", 0);
2181+
if (untracked_cache_disabled)
21772182
return NULL;
21782183

21792184
/*
@@ -2297,7 +2302,12 @@ int read_directory(struct dir_struct *dir, struct index_state *istate,
22972302

22982303
trace_performance_since(start, "read directory %.*s", len, path);
22992304
if (dir->untracked) {
2305+
static int force_untracked_cache = -1;
23002306
static struct trace_key trace_untracked_stats = TRACE_KEY_INIT(UNTRACKED_STATS);
2307+
2308+
if (force_untracked_cache < 0)
2309+
force_untracked_cache =
2310+
git_env_bool("GIT_FORCE_UNTRACKED_CACHE", 0);
23012311
trace_printf_key(&trace_untracked_stats,
23022312
"node creation: %u\n"
23032313
"gitignore invalidation: %u\n"
@@ -2307,7 +2317,8 @@ int read_directory(struct dir_struct *dir, struct index_state *istate,
23072317
dir->untracked->gitignore_invalidated,
23082318
dir->untracked->dir_invalidated,
23092319
dir->untracked->dir_opened);
2310-
if (dir->untracked == istate->untracked &&
2320+
if (force_untracked_cache &&
2321+
dir->untracked == istate->untracked &&
23112322
(dir->untracked->dir_opened ||
23122323
dir->untracked->gitignore_invalidated ||
23132324
dir->untracked->dir_invalidated))

t/t7063-status-untracked-cache.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ test_description='test untracked cache'
1414
# See <[email protected]> if you want to know
1515
# more.
1616

17+
GIT_FORCE_UNTRACKED_CACHE=true
18+
export GIT_FORCE_UNTRACKED_CACHE
19+
1720
sync_mtime () {
1821
find . -type d -ls >/dev/null
1922
}

0 commit comments

Comments
 (0)