git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Untracked files cache not used when --untracked-files is used

From
Matthew Hughes <matthewhughes934@gmail.com>
Date
Oct 6, 2025, 17:25 UTC
Message-ID
<l62blkvi5ouzhkbfmimumhzdkv6tmszsxuxhlfkmu2lkspyihy@75466fqmo6ez>
In-Reply-To
<CANM0SV38YcQ+THbAyTR5cnaX3iDfb92qG8gyAzUaJ5jMK7FfYQ@mail.gmail.com>
Show 8 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.

Previous: Devste DevsteNext: Devste Devste
Message 4 of 5 in “Untracked files cache not used when --untracked-files is used”
  1. Devste DevsteOct 3, 2025
  2. Matthew HughesOct 5, 2025
  3. Devste DevsteOct 5, 2025
  4. Matthew HughesOct 6, 2025
  5. Devste DevsteOct 7, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.