fix(git): fix --reverse showing newest commits instead of oldest#1302
Open
NEOFIT-dev wants to merge 1 commit intortk-ai:developfrom
Open
fix(git): fix --reverse showing newest commits instead of oldest#1302NEOFIT-dev wants to merge 1 commit intortk-ai:developfrom
NEOFIT-dev wants to merge 1 commit intortk-ai:developfrom
Conversation
RTK was injecting -50 into git before --reverse, causing `git log -50 --reverse` to pick the 50 most-recent commits then reverse them. Users saw 2025 data instead of historical commits from 2022. Fix: extract build_log_command() so the -N injection decision is testable. When --reverse is present without an explicit -N, RTK skips the default -N injection entirely. Git streams all commits oldest-first; RTK caps output at the normal limit (50 with --format, 10 plain) so the user gets the N oldest commits. A stderr warning fires when the output is truncated. Tests: - build_log_command: verify -N is not injected for --reverse (regression guard at the actual bug site, not just the post-processor) - build_log_command: --reverse + explicit -N respects user limit - build_log_command: without --reverse, default -N injection still works - warning path: truncation fires when raw_count > limit, silent otherwise - token savings: ≥60% verified against a real git log --reverse fixture Closes rtk-ai#1296
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.
Summary
-50into git before--reverse, sogit log -50 --reversepicked the 50 most-recent commits then reversed them — users saw 2025 data instead of historical commits from 2022-Ninjection when--reverseis present; git streams all commits oldest-first and RTK caps output at the normal limit (50 with--format, 10 plain) → user gets the N oldest commits-NCloses #1296
Test plan
cargo fmt --all && cargo clippy --all-targets && cargo testtest_build_log_command_reverse_does_not_inject_n— regression guard at the actual bug sitetest_build_log_command_reverse_with_explicit_n_respects_user_limit—-n 200,--max-count=200workarounds from the issuetest_reverse_truncation_warning_multiline_commits— warning counts commits not linestest_reverse_token_savings_plain_fixture— ≥60% savings on real fixturertk git log --reversein a repo with 100+ commits shows oldest commits first