Repository navigation
Conversation
|
recheck |
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.
16e9ca8 to
7c0865a
Compare
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 <[email protected]>
fix(git): keep +/-/@@ diff markers at column 0 in compact_diff (adopt upstream rtk-ai#3646)
|
Closing as a duplicate of #3269, which makes the same fix to Both PRs de-indent the hunk header, the Two things decided it for #3269. It has a full green test matrix, where this PR only ever ran Thanks for catching this — it's a genuine correctness bug, not cosmetics, and it's why this whole area is being worked through now. |
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 <[email protected]>
Summary
compact_diff()indents hunk lines by two spaces, moving+/-/@@off column 0 — sortk git diff | grep -E '^[+-]'silently matches nothing (false negative for any diff-parsing pipeline). Reproduced on the latest release, 0.45.0.(+N -M)so it can't read as an added line.Test plan
cargo fmt --all --check && cargo clippy --all-targets && cargo test(2,705 tests pass, clippy clean)rtk git diffoutput inspected before/after on a real repo (transcripts below)test_compact_diff_keeps_diff_markers_at_column_zerocovers markers at column 0, context-line leading space, and the summary-line disguiseProblem
compact_diff()indents every hunk header and hunk line by two spaces. That moves the+/-/@@markers off column 0, so any consumer that reads RTK'sgit diff/git showoutput like a unified diff silently gets nothing.Because the Claude Code hook rewrites
git→rtk gittransparently, the agent does not know the output was reformatted. The failing pipeline exits1with empty stdout — which looks exactly like "no matching changes". It is a convincing false negative, not an error.Reproduction (rtk 0.45.0, macOS)
One file, one edit — replace a word and add two bullet lines:
The same diff through
rtk git diff(actual output):Every marker now sits at column 2, so:
0matches, exit1— indistinguishable from a genuinely clean result. Note also the bare+3 -1per-file summary on the last line: once markers are back at column 0, a line shaped like that would itself read as an added line, so it needs re-spelling too.We hit this twice in one day while measuring an Odoo 17→18 schema delta: two independent safety checks (
git diff A B | grep -E '^[+-].*fields\.'for model renames and forSelectionkey changes) both reported "0 findings". Both had findings. A later session committed on the strength of an "edit verified, grep shows nothing unexpected" check that had matched nothing for the same reason.This contradicts the project's own Transparency principle in
CONTRIBUTING.md:Fix
@@) and hunk lines (+,-, context) at column 0, exactly as git prints them. File names and the truncation hints keep their current shape.+N -Mas(+N -M)so it can never be mistaken for an added line (same notationdiff_cmd.rsalready uses).test_compact_diff_keeps_diff_markers_at_column_zeroas a regression test.Side effect: two fewer bytes per hunk line, so the compacted output gets slightly smaller.
Same repo, this branch's build (actual output):
(4, not 6: the raw count includes the
--- a//+++ b/file headers, which compact mode drops by design. All four real changed lines are found, and the(+3 -1)summary no longer masquerades as one.)cargo fmt --check,cargo clippy -D warningsand the fullcargo test(2,705 tests) pass.Affected callers
compact_diffis shared bygit diff,git show,git stash show,rtk pipe,gh/glabdiff views — all of them gain column-0 markers.