mirror of
https://github.com/rtk-ai/rtk.git
synced 2026-09-19 07:33:17 +08:00
844d6fa3d1
A hunk ran until the next header, so any trailing text was read as its body. `gh pr diff --patch` routes here, and GitHub's `.patch` is an mbox: each patch carries a bare `---` before the diffstat and a `-- ` signature after the diff, both at column 0. With hunk bodies now anchoring, a two-commit mbox with two real deletions reported `grep -c "^-"` = 5. `@@ -a,b +c,d @@` declares its own line counts, so the hunk now ends when they are consumed and anything after it is outside every hunk. That covers trailing prose and truncated input too, rather than the shapes we happen to know about, and a heuristic on `---` / `-- ` could not have worked: a deleted line whose content is `- ` renders as `-- `. `--patch` also joins `has_non_diff_format_flag`, so an mbox passes through whole. Someone asking for a patch wants one that applies. Leading context keeps the last lines before the change rather than the first. With `-U10` or `--function-context` the first three sit ten lines above it, and emitting those tells the reader that ctx3 precedes the deletion when ctx10 does. A three-slot ring buffer costs the same lines. The diff-wide budget is charged when the buffer drains, so a line the ring evicted costs nothing. Combined diffs carry one marker column per parent, so a line changed against only one of them holds its marker in column 2. Those were counted as context: neither in the `+N -M` tally nor reachable by an anchored grep. The tally reads both columns now. The grep gap is real and cannot be closed without rewriting the line, so FEATURES.md states it alongside the per-hunk cap. Against `git diff --numstat` on three complete commit ranges the tally is now exact, where master under-counted one of them by +2 -1. `diff_header_path` keeps paths containing spaces: git does not quote them, so `diff --cc my file.txt` needs the whole remainder, not the last token. FEATURES.md said 15 lines for a 24-line block and showed the stat's first line with a leading space it does not have. It now also carries a measured example with real compression, since the two-file one saves 11% in a document advertising 60-90%.