Skip to content

unified: stop hunk body at lines not starting with space, +, -, or \#62

Merged
jelmer merged 1 commit intomasterfrom
hunkend
Apr 29, 2026
Merged

unified: stop hunk body at lines not starting with space, +, -, or \#62
jelmer merged 1 commit intomasterfrom
hunkend

Conversation

@jelmer
Copy link
Copy Markdown
Member

@jelmer jelmer commented Apr 29, 2026

is_hunk_end() only treated @@, ---, and +++ as hunk terminators. parse_hunk_line then classified anything else as a context line. As a result, the diff --git and index lines git places between files were silently absorbed into the previous hunk as two extra context lines — inflating both old and new counts by two and producing spurious hunk-line-count-mismatch diagnostics on otherwise valid patches.

Make is_hunk_end strict: a unified body line must start with ' ', '+', '-', '\', or '\n'. Anything else ends the hunk. The looser @@/---/+++ check moves to is_hunk_boundary, still used by the invalid-header recovery loop which needs to skip past arbitrary garbage.

is_hunk_end() only treated `@@`, `---`, and `+++` as hunk terminators.
parse_hunk_line then classified anything else as a context line. As a
result, the `diff --git` and `index` lines git places between files were
silently absorbed into the previous hunk as two extra context lines —
inflating both old and new counts by two and producing spurious
hunk-line-count-mismatch diagnostics on otherwise valid patches.

Make is_hunk_end strict: a unified body line must start with ' ', '+',
'-', '\\', or '\n'. Anything else ends the hunk. The looser
@@/---/+++ check moves to is_hunk_boundary, still used by the
invalid-header recovery loop which needs to skip past arbitrary garbage.
@jelmer jelmer enabled auto-merge April 29, 2026 08:22
@jelmer jelmer merged commit f13147c into master Apr 29, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant