Repository navigation
Conversation
Git Cache TTL exists for edits to work tree files, which HEAD and index modification times cannot show. When the TTL ended, every git command ran again, including commands that never read the work tree. With Git Branch and Git Changes, this ran four git processes when only one could change its answer. Keep the successful output of these commands past the TTL, for up to five minutes: - Repository location checks: rev-parse --is-inside-work-tree, --show-toplevel, and --git-dir --git-common-dir. - Commands that read only HEAD, its ref, and the index: symbolic-ref, rev-parse --short HEAD, diff --cached --shortstat, and ls-files --unmerged. These also run again when one of those files changes. git reset --soft moves a branch without touching HEAD or the index, so the checks now also read the modification times of the ref and packed-refs. The plain TTL rules stay for a TTL of 0, failed commands, reftable repositories, and sessions that set GIT_DIR, GIT_WORK_TREE, GIT_COMMON_DIR, or GIT_INDEX_FILE.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3220df31e4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Sorry, I am no longer working with ccstatusline for now and have no bandwidth to shepherd the changes here |
Relates to #397 and #384, and to item 2 of #571. #798 is a separate change that removes another git process in partial clones.
What
With Git Branch and Git Changes enabled in an unchanged repository, a render after Git Cache TTL expires starts two Git processes, down from four. The rendered output is the same.
main.git/indexchangedWhy
Each Claude Code session starts the status line again and again, so the cost of each git process grows with the number of sessions. Starting a process is also much slower on some machines, for example when endpoint security software checks each one.
As #384 says, the TTL covers unstaged and untracked edits, which do not change the modification times of
.git/HEADor.git/index. Both diff commands follow the configured TTL. An unstaged.gitattributesedit can change the staged line counts that Git reports.How
Git stays the source of truth. This only changes when git is asked again. Successful output is kept for up to five minutes in two cases:
rev-parse --is-inside-work-tree,--show-toplevel, and--git-dir --git-common-dir) depend on where the directory is in the repository, and each persistent cache file already belongs to one git dir and directory. A change to HEAD or the index does not run them again.symbolic-ref HEAD,symbolic-ref --short HEAD,rev-parse --short HEAD, andls-files --unmerged -z) run again when one of those changes.git reset --softmoves the branch without touching.git/HEADor.git/index, so these entries also record the modification times of the ref file andpacked-refs. For a linked worktree, those files are in the main repository.The plain TTL rules stay in these cases:
0, so its "no age-based expiry" meaning does not change.HEADis a placeholder and refs are not in files.GIT_DIR,GIT_WORK_TREE,GIT_COMMON_DIR, orGIT_INDEX_FILEset. The cache stamp records whether the producer ran without these overrides.Older cache entries follow the configured TTL until Git refreshes them and records the new stamp.
Downsides
core.bare, and a branch that is a symbolic ref to another branch. The five-minute limit exists for these cases.HEADandcommondirand checks two more files. This starts no process.What this does not change
diff --shortstat,diff --cached --shortstat,status,rev-list, and remote lookups keep the configured TTL.I did not merge commands into one
git status --porcelain=v2 --branchcall as #571 suggests. #571 lists behavior changes for that, and it would replace commands that do not read the work tree with one that does.Width detection is not part of this. #765 removed the
psandsttywalk whenCOLUMNSis set, and #728 and #629 cover the rest.Testing
On Linux with Bun 1.4.3 and Git 2.56, the cache tests cover both review cases. A Git wrapper around the built CLI confirmed the two-process render and identical output after the TTL. Lint, type checking, and the build completed on Linux. The real-Git cache tests also ran under Vitest on Node.
The full Bun run had failures in hook dispatch, dev reload, account email, Powerline installation, and usage fetch. The first four passed on targeted reruns. The same usage-fetch timeout reproduced on the PR base.
I counted processes for one render with a fixed JSON payload, a fresh cache directory,
COLUMNSset, and these widgets: Context Length, Git Branch, Git Changes, Model, Output Speed, and Thinking Effort. The repository is small and has staged and unstaged changes. The runs used the builtdistunder Node 26 on macOS. A preload aroundchild_processlogged each call, and agitwrapper onPATHgave the same counts. The rendered output matchedmainin each scenario.To repeat the count from the root of a checkout, run the following. The log shows which Git commands ran on the second render. It lists four on
mainand both shortstat commands on this branch.What I checked:
bun run lint,bun run build, andbun teston macOS with Bun 1.4.3. Process starts are slow on this laptop, so I used--timeout 60000. The remaining failures were in the custom command capture and account email concurrency tests. Both also fail intermittently onmainon this laptop, with a different set each run.0, and the environment variables.What I did not check:
git.test.tsthat use its temporary home helper fail there withCannot redefine property: homedir, and they fail the same way onmain.