Repository navigation
fix(git): announce the cap on the filtered git log path - #4152
Conversation
📊 Automated PR Analysis
SummaryFixes rtk's filtered Review Checklist
Analyzed automatically by wshm · This is an automated analysis, not a human review. |
2679b9d to
063904e
Compare
063904e to
1833884
Compare
aeppling
left a comment
There was a problem hiding this comment.
The goal is right, and the commit-cap notice is correct. Fuzzed against develop on log/diff/show/pipe: no stdout or exit-code regressions, and the notices match what git selects.
Blocking: on multi-line formats the cap is in lines, and RTK already holds the output it drops. git log --pretty=full makes one git call that returns 566 lines (50 commits), then shows 50 lines (3 commits, the last cut mid-body). The -n hint sends the agent back to git, and it re-reads output it already saw: 550 lines, now including merges, because a user-given limit drops the injected --no-merges. That case should go through the shared recall helper, force_tee_tail_hint, which stores into the sqlite recall store by default ([+N hidden: rtk recall …], as git stash show does). Keep the -n notice only as the fallback when recall is disabled.
#4148 lands first, so this needs a rebase on it: drop the duplicated --skip hunk.
1833884 to
040ba7e
Compare
|
Thanks for the review. Both points are in
CI is green apart from |
2f135bf to
407a34d
Compare
aeppling
left a comment
There was a problem hiding this comment.
Both points from the last round are in, thanks.
Blocking: when the 50-line cut and the 50-commit cap both hit, only the recall hint shows. On git log --format='%h %s%n%b' v0.49.0..v0.50.0 (182 commits), 3 are shown, 47 are recallable, and nothing mentions the other 132. filtered_log_cut returns before its probe in that branch; running the probe there too and printing the commit notice beside the hint would close it.
Nit: under --oneline, asking git for 51 commits would avoid the second git process, which doubles --oneline -G here.
407a34d to
48e9d11
Compare
|
Thanks @aeppling. Both are in
The PR body has the updated cost table and drops the limit this closes. |
aeppling
left a comment
There was a problem hiding this comment.
Thanks, both are in: v0.49.0..v0.50.0 shows the hint and the commit notice, and --oneline -G is back to develop's time.
Blocking: the recall hint is added after never_worse, so stdout can exceed raw when the hidden lines are shorter than the hint. In a test repo, --pretty=full on 9 commits gives 929 bytes against 926, and --format=%h%n%h HEAD~26..HEAD gives 441 against 416. Send the hint case through emit_guarded, as CONTRIBUTING asks; raw then wins and matches git's output. Leave the no-hint path as it is (moving it changes stdout against develop), keep the commit notice when raw wins, and add a test, since the current ones pass either way.
`rtk git log` without a raw-shape flag injects a limit of its own, 10 commits by default and 50 lines under a format, and said nothing about it, so a walk of 80 commits read as a history of 10. Announce it as the raw-shape path does: a notice on stderr when the cap cut commits. A format of several lines per commit is cut by lines instead: the hidden lines are stored as shown, cut at 80 columns, and named by `[+N hidden: rtk recall <id>]` (`[see remaining: tail -n +51 <path>]` in tee mode). When the history goes on past the 50 commits git was asked for, the commit notice is printed beside the hint. The hint is weighed with the lines it closes, so when git's own output costs fewer tokens than the lines shown with the hint, git's output is printed instead. The lines notice is the fallback when recall cannot store them. With RTK's own format, git is asked for one commit more than is shown and the format opens each commit, so the run answers whether the cap cut and costs no second walk. `--oneline` does the same with one line to a commit, unless a flag adds lines of its own, which the arguments or the run show. Another user format answers from its own lines where they settle it. The rest ask git through `walk_exceeds_limit`: `--reverse`, `--boundary`, `--log-size`, `--output=<file>`, and a run that prints text of its own ahead of a commit (`--show-signature`, `--show-linear-break`, `log.showSignature` given with `-c` or in the environment), which would otherwise stay in the walk shown. A walk git refused owes nothing. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
48e9d11 to
1973c4a
Compare
|
Thanks. In
One point on the 9-commit case: the guard weighs tokens and a tie keeps the composed form, so where the two sides round to the same count the hint stays. With the test repo's |
What this changes
rtk git logwithout a raw-shape flag injects a limit of its own and said nothing about it:-10by default, and-50with the first 50 lines kept under--oneline,--prettyor--format. #4117 added the notice to the raw-shape path; this adds it to the filtered path, which most invocations take.What a user newly sees
rtk git logon 80 commits: stderr gets[rtk] capped at 10 commits; pass -n <count> for more.--onelinesays 50. Stdout is unchanged.rtk git log --pretty=fullon 25 commits: stdout ends with[+N hidden: rtk recall <id>], andrtk recall <id>returns those lines as shown, cut at 80 columns. With[retriever] mode = "tee"the hint is[see remaining: tail -n +51 <path>]. When the history goes on past the 50 commits git was asked for, stderr also getscapped at 50 commits. When git's own output costs fewer tokens than the lines shown with the hint, stdout is git's output instead, and the commit notice still goes to stderr when it is owed. If recall is off or the store cannot be written, stderr sayscapped at 50 linesinstead.rtk git log HEAD~20..HEADannounces, since this path caps a range too.How
With RTK's own format, git is asked for one commit more than is shown and each commit opens with a marker, so the run answers whether the cap cut and costs no second walk.
--onelinedoes the same with its 51st line, one line to a commit. A flag that adds lines under each commit takes it out of that: the ones known from the arguments (--notes,--stat-count,-Land the like) ask git for 50 straight away, and any other one shows in the run, which is then set aside and asked for again with 50.The other shapes ask git through
walk_exceeds_limit: a user format where the printed lines leave the question open, a multi-line format whose cut was stored,--reverse,--boundary,--log-sizeand--output=<file>always. So does a run that prints text of its own ahead of a commit, because that text would stay in the walk shown:--show-signature,--show-linear-break, andlog.showSignaturegiven with-cor in the environment.Known limits
Left for a follow-up:
log.showSignatureset only in a git config file is not seen. If the commit past the cap is signed, the raw fallback prints its verdict and the savings ledger counts it.-zwith--onelineor a one-line format prints the walk on one line and is not announced.--checkon a history with whitespace errors, prints nothing on stdout, as on develop. rtk git log / git show print nothing when git exits non-zero with output on stdout #4547 tracks it.--graph, a-Lcontext line that holds a full commit opening behind the rails is read as a commit. Outside--graphit is content.Cost
Release builds,
hyperfine -N, a shallow clone of this repository with 2409 commits:rtk git logrtk git log --reversertk git log --onelinertk git log --oneline -G 'fn 'rtk git log --pretty=fullrtk git log --format='%h %s%n%b' -G 'fn 'The default format and
--onelinestart one git process, as develop does. A multi-line format the cap cuts starts a second one once the cut is stored, to ask whether commits lie past the 50 git returned, and under a diff filter such as-Gthat second walk scans the history again. With RTK's own format, the probe is a second process for--reverse,--boundary,--log-size,--output=<file>,--show-signature,--show-linear-breakandlog.showSignaturegiven with-cor in the environment. Under--oneline, a flag that adds lines of its own costs the probe too, and one RTK cannot see in the arguments a second run of the walk before it.Tests
tests/git_log_cap_notice_test.rsand unit tests ingit_cmd.rs: the notice at the cap and one past it, the number of git walks each shape costs, the commit notice beside a stored hint in recall and tee mode, git's own output where the hint would cost more than the lines it hides, boundary walks, the line bound, recall and tee round trips, signed commits, the linear-break bar, a graph over a criss-cross merge. Against develop over 59 cases, stdout is identical except for the recall hint, or git's own output where the hint would cost more, and stderr differs only by the notice on a walk that exits 0.🤖 Generated with Claude Code