Re: Untracked files cache not used when --untracked-files is used
- From
- Devste Devste <devstemail@gmail.com>
- Date
- Oct 7, 2025, 09:14 UTC
- Message-ID
- <CANM0SV1p3auirRoHTfh2r=JuP-QU7uyK4o1+PZNVPT1mCVSqXw@mail.gmail.com>
- In-Reply-To
- <l62blkvi5ouzhkbfmimumhzdkv6tmszsxuxhlfkmu2lkspyihy@75466fqmo6ez>
Which means essentially, I have to run git status --untracked-files once a day to keep the untracked cache up to date, since I can't change the git commands SourceTree uses
On Mon, 6 Oct 2025 at 19:25, Matthew Hughes <matthewhughes934@gmail.com> wrote:
Show 33 quoted lines
> > > One of --no-optional-locks --porcelain --ignore-submodules=dirty > > --no-ahead-behind causes it to not update the cache it seems. > > Unfortunately, I cannot tell which exactly, because now, even when > > unsetting status.showUntrackedFiles it uses the cache for > > --untracked-files=all > > This means, that if the untracked cache was created with > > status.showUntrackedFiles all, it will always use the untracked-files > > cache for --untracked-files > > You can disable the untracked cache with `git update-index > --no-untracked-cache`. Experimenting with that, on my machine the culprit looks > to be `--no-optional-locks`: > > time GIT_CONFIG_GLOBAL=/dev/null git \ > --no-optional-locks \ > -c 'diff.mnemonicprefix=false' \ > -c 'core.quotepath=false' \ > -c 'core.untrackedCache=true' \ > -c 'status.showUntrackedFiles=all' \ > status \ > --porcelain \ > --ignore-submodules=dirty \ > --no-ahead-behind \ > --untracked-files=all >/dev/null > > Will consistently, on repeated runs, take >1s. After removing > `--no-optional-locks` one more run is still slow, but after that it drops to > ~300ms. > > Glancing at the code: the likely cause is the `repo_update_index_if_able` call > in `cmd_status` is only called when `use_optional_locks` returns a truthy > value.