fix(git): stop hiding merge commits and disclose the default log cap - #3662
Open
dwin-gharibi wants to merge 1 commit into
Open
fix(git): stop hiding merge commits and disclose the default log cap#3662dwin-gharibi wants to merge 1 commit into
dwin-gharibi wants to merge 1 commit into
Conversation
With no explicit count run_log appended two flags of its own. -10 is a presentation cap but was emitted with no marker, so ten commits read as the whole history. --no-merges is not a cap at all: it removes commits from the middle of history, so 'was the branch merged?' -- asked by running git log -- got a confident no. Drop the --no-merges injection entirely, ask git for one commit past the cap so the overflow is detectable, and have filter_log_output append '[rtk] truncated at N commits; use -n N for more' when it dropped anything. An explicit -n is the agent's own choice and is left alone. The notice carries no number on purpose: the probe only proves more commits exist, not how many, and '+1 more' against a 16-commit history would swap one misleading output for another. search.rs already works this way -- it caps, then emits '+N more in <file>' with a tee hint. This applies the same rule to git log.
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.
Closes #3661.
Summary
--no-merges. A cap trims the tail of a list; hiding merge commits removescommits from the middle of history, and no truncation notice can express that. "Was the branch
merged?" has to stay answerable from
git log.run_lognow asks git for one commit past the cap purely to detectthe overflow, and
filter_log_outputappends[rtk] truncated at N commits; use -n N for morewhen it dropped anything.-n N/--max-countis the agent's own choice and is never annotated.Test plan
cargo fmt --all && cargo clippy --all-targets && cargo testrtk <command>output inspectedUnit tests (added, TDD — red before green)
src/cmds/git/git.rs:default_cap_is_disclosed— 12 commits, cap 10: still 10 entries, plus the marker.default_cap_is_disclosed_for_user_formats— same for the--oneline/--prettyline path.user_limit_is_not_annotated— an explicit limit is left alone.exact_fit_is_not_annotated— nothing dropped, nothing claimed.Two existing tests updated
test_filter_log_output_cap_linesandtest_filter_log_output_user_format_with_limitasserted abare line count, which now includes the marker. Both were tightened to assert the commit count
and the presence of the disclosure — a stronger assertion than before.
Behavioural check on a real repo
16 commits, one of them a merge:
rtk git log— merge commitrtk git log— truncation marker[rtk] truncated at 10 commits; use -n N for morertk git log— commits shownrtk git log -n 20rtk git log --onelineSuite
cargo test --all: 2629 passed, 0 failed (2625 ondevelop, +4 from this PR).cargo clippy --all-targets: clean.cargo fmt --all: clean.