Repository navigation
fix(git): filter git show <rev>:<path> blob reads past a size threshold - #3154
Closed
albatrossflyon-coder wants to merge 1 commit into
Closed
albatrossflyon-coder wants to merge 1 commit into
albatrossflyon-coder wants to merge 1 commit into
Conversation
`git show <rev>:<path>` prints a file's content at a revision (not a diff), but the handler routed it to raw passthrough unconditionally — telemetry from a 5-week history DB showed 436 calls, 3.82M input tokens, 0.6% savings, vs. 50%+ for the diff form of the same command. Blobs at or under 200 lines still pass through untouched. Past that, run the same comment-stripping filter `rtk read -l minimal` uses, keyed off the path's extension, guarded by the existing never_worse check so filtering can never cost more than raw output. Fixes rtk-ai#3116
Collaborator
|
Thanks for working on this. Blob reads with |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3116
Root cause
git show <rev>:<path>(blob read form) was routed to raw passthrough unconditionally inrun_show, same as--stat/--prettyoutput. Unlike the diff form ofgit show, which auto-compacts below in the same function, the blob form never went through any filtering — confirmed against a real 5-week command-history DB: 436 calls, 3.82M input tokens, 0.6% aggregate savings vs. 50%+ for the<rev> -- <path>diff form.Fix
BLOB_FILTER_LINE_THRESHOLD) stay byte-identical passthrough — not worth a filter pass, per the issue's own suggested conservative threshold.MinimalFilter(the same comment/blank-line-stripping filterrtk read -l minimaluses), with the language detected from the path segment of therev:patharg.never_worse(already used everywhere else in this file) guards the result — if filtering doesn't actually shrink the output, raw is shown instead.(blob-filtered)vs(passthrough)depending on whether filtering actually reduced size, so telemetry can distinguish the two going forward.Verification
cargo test— 2474 passed, 0 failed (3 new tests added: under-threshold passthrough stays byte-identical, over-threshold strips comments while preserving code, unknown-extension blobs are still bounded bynever_worse).cargo fmt --check/cargo clippy -- -D warnings— clean.git.rs(3367 lines): rawgit show HEAD:src/cmds/git/git.rsis 113,289 bytes;rtk git showof the same blob is 105,016 bytes (comments/blank-lines stripped, code untouched — diffed to confirm no code lines were removed, only//comment lines).Cargo.toml, well under the threshold) is confirmed byte-identical betweengit showandrtk git show.The 200-line threshold is a first cut per the issue's own suggestion ("so tiny files stay passthrough") — happy to tune it if you'd rather key off byte size or make it configurable.