Repository navigation
Conversation
`rtk git log --stat` dropped most commits with no notice: 30 commits in, 9 out, and 18 of 50 absent in the original report. With --stat (or --numstat/--shortstat) git appends the diffstat *after* the pretty-format output — that is, after RTK's trailing ---END--- marker. Splitting on that marker therefore left each diffstat heading the *next* block, where the parser read its first line as the commit header and demoted the real header to a body line, capped at 3. Merge commits carry no diffstat at all, so the damage was irregular rather than uniform — which is why it read as a merge-commit bug. Lead each commit with the marker instead of terminating it. Every block then starts at a real header and each diffstat stays with the commit it describes, so no commit can be knocked out of step. Diffstat lines share the existing body budget and overflow through the existing "[+N lines omitted]" notice, so what is dropped is disclosed. --stat stays filtered rather than passed through, keeping it compatible with the -p/--patch passthrough proposed in rtk-ai#2951. Fixes rtk-ai#2882
|
|
Adopt upstream rtk-ai#3028: git - keep every commit in git log --stat output
| None => continue, | ||
| }; | ||
| // Remaining lines are the body — keep up to 3 non-empty, non-trailer lines | ||
| let all_body_lines: Vec<&str> = lines |
There was a problem hiding this comment.
Minor: diffstat lines from git log --stat get mixed into the same untagged all_body_lines list as real commit-message body text, and they’re truncated with the default width of 80 chars.
For a large commit and/or a deeply nested path, for example src/cmds/git/git.rs | 123 ++++++++++++++++++++++++++++++++++++++++++++--------, which is 83 chars, the line gets cut with a trailing .... The insertion/deletion counts are then silently lost, and there’s no indication that the truncated line was diffstat data rather than commit-message prose.
This seems like a simple fix that could fit in that PR
|
Closing: already fixed on develop. |
Fixes #2882
Problem
rtk git log --statdrops most commits, with no notice and no escape hatch. Measured on this repo:The reporter saw 18 of 50 missing. An agent reading this gets a confidently incomplete history.
Root cause
Not merge-commit handling, which is where the issue reasonably pointed — merge commits are a symptom.
With
--stat, git appends the diffstat after the pretty-format output, i.e. after RTK's trailing---END---marker:So
output.split("---END---")yields blocks shaped[diffstat of commit N-1] + [header of commit N] + [body of commit N].filter_log_outputtakes the block's first line as the header — which is now a diffstat line — and the real commit header becomes a body line, capped at 3 and collapsed into[+N lines omitted]. Each commit that has a diffstat consumes the next commit's slot.Merge commits produce no diffstat (
git log --statomits it for merges by default), so the corruption is irregular rather than uniform. That is why it presented as "the parser loses its place around merge commits": they are the blocks where the pattern breaks step, not the cause.Fix
Lead each commit with the marker instead of terminating it:
Every block now begins at a real commit header, and anything git appends after the format — the diffstat — stays inside the block of the commit it describes. No commit can be knocked out of step, and merge commits need no special-casing since the anchor no longer depends on a diffstat being present.
Blank blocks are filtered before
take(limit), because the empty region ahead of the first marker would otherwise consume one commit's slot.Diffstat lines share the existing body budget and overflow through the existing
[+N lines omitted]notice, so the issue's "Expected" is met on both counts: every commit is preserved, and anything dropped is disclosed.Scope note:
--statstays filtered rather than switching to passthrough. #2951 proposes passthrough for-p/--patchand its tests assert--statkeeps being filtered; fixing the parser satisfies both, so the two PRs are complementary rather than contradictory. They touch the same function and whichever lands second will need a trivial rebase.Verification
--stat -10--stat -30--stat -50Hash-level set comparison at
-30: commits present in native but absent from rtk went from 21 to 0.test_filter_log_output_stat_keeps_every_commit(a merge commit + two diffstat-bearing commits, asserting the middle one survives, mirroring thea0530e8/463e523/deaa799case in the issue) andtest_filter_log_output_stat_overflow_is_disclosed.git log,git log -5,git log --oneline -20,git log -3 --format=%H.cargo fmt --all --checkclean,cargo clippy --all-targetszero warnings,cargo test --all2495 passed / 0 failed.Token savings, stated plainly:
git log --stat -30goes from 59.3% to 53.1% — the extra words are the 21 recovered commits. Worth being explicit that this filter never met the 60% target on--stat; the old number was closer to it only because it was discarding 70% of the data. I'd rather surface that than quietly claim a win. If you want--statback above 60%, the natural lever is compacting each diffstat to itsN files changedsummary line, which I'm happy to add here or in a follow-up.Test plan
cargo fmt --all && cargo clippy --all-targets && cargo test --allrtk git log --stat -10/-30/-50compared against nativegit log --statby hash set