Skip to content

perf(git): look for filter sections, not the word filter - #798

Closed
bvolpato wants to merge 1 commit into
sirmalloc:mainfrom
bvolpato:bvolpato/git-filter-probe-sections
Closed

bvolpato wants to merge 1 commit into
sirmalloc:mainfrom
bvolpato:bvolpato/git-filter-probe-sections

Conversation

@bvolpato

@bvolpato bvolpato commented Nov 3, 2026 •

Copy link
Copy Markdown

Relates to #397. Separate from #797, which removes other git processes. The two can merge in either order. Together they merge cleanly, and a render after the TTL in a partial clone goes from 5 git processes to 1.

What

Before status or diff runs, ccstatusline reads the repository's config files to decide if it must ask git about filter drivers. That check matched the words filter or include anywhere in those files. It now looks for a section that starts with [filter or [include, in any case. This removes one git process each time status or diff runs in a repository that only has those words somewhere else.

Git Branch and Git Changes in a partial clone, with no other change applied:

Render main This branch
Empty cache 5 4
Within the TTL 0 0
TTL ended, nothing changed 5 4

A repository with neither word in its config runs 4 on both.

Why

git clone --filter=blob:none writes partialclonefilter into .git/config, so each partial clone pays for this process. So does a tracked branch named filter-work, or a remote URL that contains include. The answer is not kept between renders, so the process runs on each render where status or diff misses the cache.

Each Claude Code session starts the status line again and again, so needless processes add up across sessions. They cost more on machines where process starts are slow, for example when endpoint security software checks each one.

Why the protection stays

This check is part of the hardening from GHSA-rf4f-gc2h-c9vp, so a missed filter would be a security problem. An extra match only costs one process. A filter driver or an include can only come from a section, and git reads the section name straight after the opening bracket. This is how git 2.54 read each form:

Config text Git reads This check
[filter "x"] filter.x.clean Matches
[FILTER "x"] filter.x.clean Matches
[filter.x] filter.x.clean Matches
[core][filter "x"] filter.x.clean Matches
[core] [filter "x"] clean = cmd filter.x.clean Matches
[include], [includeIf "gitdir:/"] an include Matches
[ filter "x"] fatal: bad config line 1 No match, and git fails with or without the check
filter.x.clean = cmd with no section fatal: bad config line 1 No match, and git fails with or without the check
partialclonefilter = blob:none no filter No match
[branch "filter-x"] no filter No match

Repositories with a real filter or include section, such as a local Git LFS install, still run this process each time. That is the same as before.

Testing

I counted processes for one render with a fixed JSON payload, a fresh cache directory, COLUMNS set, and these widgets: Context Length, Git Branch, Git Changes, Model, Output Speed, and Thinking Effort. The runs used the built dist under Node 26 on macOS, and a preload around child_process logged each call. The fixture is a real partial clone. The rendered output matched main in each scenario.

What I checked:

  • bun run lint, bun run build, and bun test on 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 tests, which also fail intermittently on main on this laptop, with a different set each run. One earlier run also failed the Git LFS and the filter name hardening tests. Later repeated runs on this branch and on main did not reproduce that. Both of those tests have [filter in their config, so this check gives the same answer as before for them.
  • The real git hardening tests now also plant a filter in upper case, in the dotted form, and as a second section on one line. Each test checks that the status line does not run the filter and that plain git does, so the setup is a real attack.
  • Mocked tests cover which config text asks git and which does not. They fail with the old check, with a case-sensitive check, and without include.

What I did not check:

  • Git versions other than 2.54 for the table above. The hardening tests ran with git 2.56.
  • Linux and Windows on my machine. CI covers Linux.
  • A live Claude Code session. All renders used a fixed payload.

Before status or diff runs, a check reads the repository's config files to
decide if git must be asked about filter drivers. It matched "filter" or
"include" anywhere in those files. A partial clone's partialclonefilter, a
branch named filter-work, and a remote URL that contains "include" all matched,
which added one git process each time status or diff ran.

A filter driver or an include can only come from a section, and git reads the
section name straight after the opening bracket: `[ filter "x"]` is a fatal
config error. So look for `[filter` and `[include`, in any case. This also
matches `[filter.x]` and a second section on one line, such as
`[core] [filter "x"]`.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T05:02:22.828446Z 8d9534e Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@bvolpato

bvolpato commented Dec 5, 2026

Copy link
Copy Markdown
Author

Sorry, I am no longer working with ccstatusline for now and have no bandwidth to shepherd the changes here

@bvolpato bvolpato closed this Dec 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant