Re: Untracked files cache not used when --untracked-files is used
- From
Matthew Hughes <matthewhughes934@gmail.com>
- Date
- Oct 5, 2025, 00:20 UTC
- Message-ID
- <lrahpvp3nj4rtewf3zbf67qsvwhc4mg6irbmrhklbizxbhqwom@cc25oeqex4il>
- In-Reply-To
- <CANM0SV3+4k5tsgRw0g8-HoVSFGb1AwZr+2hCUXLriFGSd33WQQ@mail.gmail.com>
Devste Devste wrote:
Show 5 quoted lines
> It seems that using --untracked-files(=all) causes it to either not > use the untracked files cache (or untracked files are not stored in > the untracked files cache if they are in an untracked directory?) > Since various tools and IDEs use that hardcoded, fixing this would be > a massive performance boost for many users
What's the value of your `status.showUntrackedFiles` config var? I ask because I looked around a bit and found commit e6a653554bb49c26d105f3b478cbdbb1c0648f65 (untracked-cache: support '--untracked-files=all' if configured), which includes:
> For most users there will be no change in behavior. Users who need > '--untracked-files=all' to perform well will now have the option of > setting "status.showuntrackedfiles" to "all" for better / more > consistent performance.
Testing this out on a big repo (on my Linux machine):
$ git init .
# create ~100_000 files with plenty of directories
$ for i in {1..10000}; do echo dir_$i/{1,2,3,4}/nested_{1,2}; done | xargs mkdir -p
$ for i in {1..10000}; do echo dir_$i/{foo,bar,baz}/file.txt; done | xargs touch
$ git add .As expected, status with untracked files and no untracked cache is rather slow:
$ time GIT_CONFIG_GLOBAL=/dev/null git status --untracked-files=all >/dev/null
real 0m1.237s
user 0m0.484s
sys 0m1.150sStatus with untracked files and `core.untrackedCache=true` is just as slow:
$ time GIT_CONFIG_GLOBAL=/dev/null git -c 'core.untrackedCache=true' status --untracked-files=all >/dev/null
real 0m1.250s
user 0m0.435s
sys 0m1.216sHowever, with `status.untrackedFiles=all` (i.e. matching the `--untracked-files` flag) it's much quicker:
$ time GIT_CONFIG_GLOBAL=/dev/null git -c 'core.untrackedCache=true' -c 'status.showUntrackedFiles=all' status --untracked-files=all >/dev/null
real 0m0.382s
user 0m0.214s
sys 0m0.568s