Repository navigation
fix(git): keep +/-/@@ diff markers at column 0 in compact_diff (adopt upstream #3646) - #118
Merged
Merged
Conversation
compact_diff indented every hunk header and hunk line by two spaces. That moved the unified-diff markers off the line start, so anything reading `rtk git diff` through a pipe as a diff — `grep -E '^[+-]'`, patch, diff-aware tooling — matched nothing and exited 1. Because the hook rewrites `git` to `rtk git` transparently, that reads as a clean "no matching changes" result: a silent false negative. Emit hunk headers and hunk lines exactly as git prints them, and spell the per-file summary as `(+N -M)` so it cannot be mistaken for an added line (the notation diff_cmd.rs already uses). Output shrinks by two bytes per hunk line. Adds a regression test.
The Avant/Apres example still showed the pre-fix indented format (and was already stale in other ways: a '~' modified marker and '(+5/-2)' tally that compact_diff never emitted). Redraw it from real output of the new format: markers at column 0, per-file tally indented as ' (+N -M)'. Fork-authored amendment to the rtk-ai#3646 adoption; CONTRIBUTING requires doc updates for changes to documented behavior. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Owner
Author
Review round (pre-merge)Three passes ran on the branch diff: upstream's Verdicts: upstream reviewer APPROVE, 0 critical / 2 important; Spec axis: no missing requirements, no scope creep; Standards axis: 2 hard findings, 2 judgement calls. Acted on
Deliberately left byte-identical (cherry-pick integrity)
Follow-ups (out of scope for this adoption)
Cross-checked reviewer claims
|
This was referenced Aug 24, 2026
KuSh
pushed a commit
that referenced
this pull request
Aug 30, 2026
The stdin diff path (git diff | rtk diff -) emitted changed lines two-space indented, pushing their +/- markers to column 2. Anchored greps over the output (grep -E '^[+-]') matched nothing — a silent false negative for any script or CI gate built on diff conventions. Same class as the compact_diff fix in #118 (upstream rtk-ai#3646), same design rule applied: change lines at column 0; the [file] header and overflow line are unchanged and never start with +/-. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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 #102.
What this adopts
Adoption of upstream rtk-ai/rtk#3646 by @ninearif (Arif Waram): keep
+/-/@@diff markers at column 0 incompact_diff.The ticket named upstream #3269 (@iliaal). During Phase 2 a cluster check found rtk-ai#3646, opened 2026-08-23, which is a strict superset of rtk-ai#3269:
format!(" {}", line)sites emit at column 0 (hunk header, added, removed, context).+N -M→(+N -M), matching the notationdiff_cmd.rsalready uses, so the tally can never be read as an added line even if a consumer strips indentation.test_compact_diff_keeps_diff_markers_at_column_zero): asserts@@at column 0, context-line leading space, an exhaustive filter that only real hunk lines start with+/-, and the tally re-spell.Adopting rtk-ai#3646 leaves no residual gap; rtk-ai#3269 is referenced as the passed-over alternative. Both fix the same defect; they conflict textually and cannot both be cherry-picked.
Commits
fix(git): keep +/-/@@ diff markers at column 0 in compact_diffdevelopNo fork-authored amendments were needed: all 129 existing git-module tests and the full suite pass unchanged — no fork test had encoded the old indent.
Bug
compact_diffindented every hunk header and hunk body line by two spaces, so any anchored consumer of rtk-filtered diff output (grep -E '^[+-]',grep '^-') silently matched nothing. Because the hook rewritesgit → rtk gittransparently, the empty result is indistinguishable from "no matching changes" — a convincing false negative, not an error. Affects allcompact_diffcallers:git diff,git show,git stash show,gh/glabdiff views,rtk pipe.Repro (real binaries, scratch repo with 3 changed lines)
Raw git:
Before (installed rtk.exe, pre-fix):
Filtered output had every marker at column 2:
After (this branch's build):
(3 vs raw 5: compact mode drops the
--- a//+++ b/file headers by design; all real hunk lines are found and the tally no longer masquerades.)Quality gate
cargo fmt --all && cargo clippy --all-targets && cargo test --all— clean on the branch (2717 unit tests + all integration suites, 0 failures, clippy zero warnings). The same gate also ran green on the mergeddevelopright after today's upstream sync (13 commits), before branching.Deliberately not fixed
diff --git/---/+++headers are dropped by design) — usertk proxy git difffor a faithful patch. The indent was never what made that case fail.^-anchors again rtk-ai/rtk#3269 stays open upstream; no comment was posted there (declining/steering upstream PRs is contributor outreach, a separate decision).