fix(patchset): ignore trailing junks when hunk is complete#23
Merged
weihanglo merged 8 commits intogit-format-patchfrom Jan 26, 2026
Merged
fix(patchset): ignore trailing junks when hunk is complete#23weihanglo merged 8 commits intogit-format-patchfrom
weihanglo merged 8 commits intogit-format-patchfrom
Conversation
Patch that deletes a diff file containing `-- ` patterns within its content, followed by a real email signature at the end. Tests that we should correctly distinguish between: - `-- ` appearing as patch content (from inner diff's empty context lines) - `-- ` appearing as the actual email signature separator Both git apply and GNU patch handle this correctly.
Before this, we failed to handle patch that deletes a diff file containing `-- ` patterns within its content. As we'll strip out the actual patch content by the wrong `rfind` logic. Both git apply and GNU patch handle this correctly by just ignoring junks between each file patch. With this we can also remove the email signature stripping logic.
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.
Before this, we failed to handle patch that deletes a diff file
containing
--patterns within its content. As we'll strip outthe actual patch content by the wrong
rfindlogic.Both git apply and GNU patch handle this correctly by just ignoring
junks between each file patch.
With this we can also remove the email signature stripping logic.
Junk Between Hunks vs Between Files
diffy matches GNU patch behavior.
git apply is stricter (errors on junk between hunks).
This bug was found during a replay of the most recent 1000 commits in rust-lang/rust https://github.com/weihanglo/diffy/actions/runs/21342417740/job/61423914086.
This also add a check that fail when no patch found in a patchset.