Skip to content

fix(patch): trailing garbage after no-newline-at-eof marker#21

Merged
weihanglo merged 2 commits intogit-format-patchfrom
regression
Jan 25, 2026
Merged

fix(patch): trailing garbage after no-newline-at-eof marker#21
weihanglo merged 2 commits intogit-format-patchfrom
regression

Conversation

@weihanglo
Copy link
Copy Markdown
Owner

This was a regression introduced by commit 79c086b (#7),
which added garbage handling for complete hunks
but missed the no_newline_context branch.

When a hunk ends with \ No newline at end of file on a context line
and is followed by trailing content (e.g., diff --git headers from
UniDiff splitting), the parser now correctly recognizes the hunk as
complete instead of erroring with "expected end of hunk".

This fixes parsing of git diff output in UniDiff mode where patches
are split by ---/+++ boundaries, causing subsequent git headers to
be appended to the previous patch.

Pattern first appeared in rust-lang/cargo@b119b891d.

This was a regression introduced by commit 79c086b (#7),
which added garbage handling for complete hunks
but missed the `no_newline_context` branch.

When a hunk ends with `\ No newline at end of file` on a context line
and is followed by trailing content (e.g., `diff --git` headers from
UniDiff splitting), the parser fails with "expected end of hunk".

Pattern first appeared in rust-lang/cargo@b119b891d.
This was a regression introduced by commit 79c086b (#7),
which added garbage handling for complete hunks
but missed the `no_newline_context` branch.

When a hunk ends with `\ No newline at end of file` on a context line
and is followed by trailing content (e.g., `diff --git` headers from
UniDiff splitting), the parser now correctly recognizes the hunk as
complete instead of erroring with "expected end of hunk".

This fixes parsing of `git diff` output in UniDiff mode where patches
are split by `---/+++` boundaries, causing subsequent git headers to
be appended to the previous patch.

Pattern first appeared in rust-lang/cargo@b119b891d.
@weihanglo weihanglo merged commit 948b8f4 into git-format-patch Jan 25, 2026
11 checks passed
@weihanglo weihanglo deleted the regression branch January 25, 2026 20:58
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