Repository navigation
Ignore "No newline at end of file" markers in patches - #93
Merged
Merged
Conversation
janedbal
marked this pull request as ready for review
October 20, 2026 07:48
Git writes "\ No newline at end of file" after a line that has no newline. sebastian/diff parses this marker as an unchanged line, so PatchParser counted it as a line of the new file. Every added line after the marker got a number one too high. The content check then failed with a false "Is the patch up-to-date?" error, and check --patch and patch-coverage stopped. This happens when the old version of a file has no final newline and the change adds lines after its last line or edits its last line. Adding the missing final newline is enough. The check covers every file in the patch, so a .neon, .yml or .json file also triggers it. In a unified diff, only this marker starts with a backslash. PatchParser now removes such lines before it parses the patch. Co-Authored-By: Claude Code
janedbal
force-pushed
the
jn-fix-patch-no-newline-marker
branch
from
October 20, 2026 08:41
2f61fa2 to
7aeb017
Compare
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.
Git writes
\ No newline at end of fileafter a line that has no newline. sebastian/diff parses this marker as an unchanged line, soPatchParsercounts it as a line of the new file. Every added line after the marker gets a number one too high:The content check then fails, and
check --patchandpatch-coveragestop:When it happens:
phpcbffix..neon,.ymlor.jsonfile also triggers it.In a unified diff, every file line starts with a space,
+or-. Only this marker starts with a backslash. NowPatchParserremoves such lines before it parses the patch.PatchParserTestwith a fixture patch from a realgit diff. The test fails onmaster.Co-Authored-By: Claude Code