Repository navigation
Description
Measurement
Post-v0.1.8 24h dashboard (2026-05-18):
| Subcmd | Calls | Savings | Input | Saved |
|---|---|---|---|---|
| status | 184 | 18.3% | 41K | 7.5K |
| branch | 24 | 46.2% | 27.7K | 12.8K |
| log | 134 | 3.2% | 23K | 0.7K |
| show | 24 | 1.6% | 16.8K | 0.3K |
| commit | 38 | 97.5% | 2.8K | 2.7K |
| pull | 2 | 99.4% | 1.8K | 1.8K |
Three concrete bugs in src/cmds/git/git.rs account for most of the underperformance.
Bug 1: git branch -r is effectively unfiltered
filter_branch_output recognises remote-branch lines only when they begin with remotes/ (the format git branch -a emits). git branch -r instead emits lines like origin/main directly — no remotes/ prefix. These fall through the if let Some(branch) = line.strip_prefix("remotes/") branch into else { local.push(line) }, so all remote-only branches are emitted unchanged AND tagged as "local". The output then gets a useless * header (current is empty since git branch -r doesn't include *).
Reproduced on real data — git branch -r raw output = filtered output, byte-for-byte, plus * \n prefix. Three calls in 24h, all at 0% savings, ~1.7K tokens each.
Fix: detect remote-branch lines by checking for the origin/ (or any <remote>/) prefix, and route them into the remote bucket. Also: when caller passed -r, don't emit the * <current> header.
Bug 2: git log auto-adds --no-merges even when user set -N
git log --oneline -5
The user asked for 5 commits, including merges (they didn't pass --no-merges). The filter unconditionally appends --no-merges, so they get 5 different commits (the merges scrolled past). Reproduced: raw git log --oneline -5 = 295 bytes; contextcrawler git log --oneline -5 = 343 bytes — negative compression because the un-merged commits had longer subject lines than the merges.
This is a correctness bug, not just savings. We're changing the semantics of the user's explicit query.
Fix: only auto-add --no-merges when we're also setting the default limit (i.e., user_set_limit == false). When the user explicitly says -5, respect their query.
Lift estimate: untainted log queries would compress at typical filter rates (~70%+). Current 3.2% includes a population of explicit -N calls where the un-merge changed the output enough to LOSE savings.
Bug 3: git show <hash>:<path> is full passthrough
This is the file-extraction form (read a file at a specific commit). Output is the raw file contents at that revision. We currently passthrough — 0% savings on 16.8K input.
Route through the same filter as contextcrawler read <path>: extract extension, detect Language::from_extension, apply the read-level filter with the standard cap. The file path is right there in the <hash>:<path> argument.
Fix: in run_show, detect the <hash>:<path> form (presence of : in a single positional arg, no --patch / --stat), extract the path, feed the stdout through cmds::system::read::render_output with the appropriate Language.
What's out of scope for this PR
git status --short(184 calls / 41K input / 0% saved) — output is structurally compact already. Compressing it further would mean grouping by directory or capping at N changes; that's a larger UX decision, deserves its own issue.git statusnon-short (184 calls — overlaps with above; the 18.3% pct is the weighted average across all forms) — minor lift from better hint-stripping, but the big win is in the explicit-short path above.
Success criteria (re-measurement after merge + 24h)
git branch -rsavings: 0% → ≥60%git log(esp. user-set-Nforms): 3.2% → ≥60%git show <hash>:<file>: 1.6% → ≥40% (depends on file type)- Aggregate
gitrow in dashboard: 22.9% → ≥45%
Tests
- Pinning regression for the auto-
--no-mergesbehavior (must NOT fire onuser_set_limit=true) - Snapshot tests for
filter_branch_outputagainst-r,-a, and bare formats - Round-trip test for
git show <hash>:<path>→ filtered Rust content
Trace
- Discipline:
[[feedback-metrics-before-claims]] - Parent measurement:
[[contextcrawler-state-2026-05-18-post-v0_1_8]] - The user explicitly said: "git compression — 641 calls at 22.9% (115K input, only 26K saved). Largest under-performing wrapped tool." — this PR is the per-subcommand drill identified in that lever ranking.
Activity
Merge pull request #56 from thehoff/feat/git-filter-leaks-55
perf(git): fix branch -r passthrough + log --no-merges semantics + sh…