diff options
author | Junio C Hamano <gitster@pobox.com> | 2022-03-16 17:53:07 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-03-16 17:53:07 -0700 |
commit | 47e0380289b4d60c6fc6a86935686233113aa001 (patch) | |
tree | 3fcd15ff026f0dea31ce972a8546b8387ac406a7 /dir.c | |
parent | 5b9c98b4915eb3f27fbc887cf3f751c9777a0149 (diff) | |
parent | 317956d91239e86b26ce95735451698b042dbe5d (diff) |
Merge branch 'tk/empty-untracked-cache'
The untracked cache newly computed weren't written back to the on-disk index file when there is no other change to the index, which has been corrected. * tk/empty-untracked-cache: untracked-cache: write index when populating empty untracked cache t7519: populate untracked cache before test t7519: avoid file to index mtime race for untracked cache
Diffstat (limited to 'dir.c')
-rw-r--r-- | dir.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/dir.c b/dir.c index 79a5f6918c..eb3f24bf5d 100644 --- a/dir.c +++ b/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, |