untracked-cache: write index when populating empty untracked cache
It is expected that an empty/unpopulated untracked cache structure can be written to the index - by update-index, or by a "git status" call that sees the untracked cache should be enabled and is not, but is running with options that make the untracked cache non-applicable in that run (eg a pathspec). Currently, if that happens, then subsequent "git status" calls end up populating the untracked cache, but not writing the index (not saving their work) - so the performance outcome is almost identical to the cache being altogether disabled. This continues until the index gets written with the untracked cache populated, for some *other* reason, such as a working tree change. Detect the condition where an empty untracked cache exists in the index and we will collect the list of untracked paths, and queue an index write under that condition, so that the collected untracked paths can be written out to the untracked cache extension in the index. This change depends on previous fixes to t7519 for the "ignore .git changes when invalidating UNTR" test case to pass - before this fix, the test never actually did anything as it was not set up correctly. Signed-off-by: Tao Klerks <tao@klerks.biz> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
37482b4080
commit
317956d912
10
dir.c
10
dir.c
@ -2781,7 +2781,8 @@ void remove_untracked_cache(struct index_state *istate)
|
||||
|
||||
static struct untracked_cache_dir *validate_untracked_cache(struct dir_struct *dir,
|
||||
int base_len,
|
||||
const struct pathspec *pathspec)
|
||||
const struct pathspec *pathspec,
|
||||
struct index_state *istate)
|
||||
{
|
||||
struct untracked_cache_dir *root;
|
||||
static int untracked_cache_disabled = -1;
|
||||
@ -2845,8 +2846,11 @@ static struct untracked_cache_dir *validate_untracked_cache(struct dir_struct *d
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!dir->untracked->root)
|
||||
if (!dir->untracked->root) {
|
||||
/* Untracked cache existed but is not initialized; fix that */
|
||||
FLEX_ALLOC_STR(dir->untracked->root, name, "");
|
||||
istate->cache_changed |= UNTRACKED_CHANGED;
|
||||
}
|
||||
|
||||
/* Validate $GIT_DIR/info/exclude and core.excludesfile */
|
||||
root = dir->untracked->root;
|
||||
@ -2916,7 +2920,7 @@ int read_directory(struct dir_struct *dir, struct index_state *istate,
|
||||
return dir->nr;
|
||||
}
|
||||
|
||||
untracked = validate_untracked_cache(dir, len, pathspec);
|
||||
untracked = validate_untracked_cache(dir, len, pathspec, istate);
|
||||
if (!untracked)
|
||||
/*
|
||||
* make sure untracked cache code path is disabled,
|
||||
|
Loading…
Reference in New Issue
Block a user