Skip to content

v1.4.0

Choose a tag to compare

@github-actions github-actions released this 20 Mar 04:21
· 52 commits to main since this release

Performance

  • Patch Creation: Optimized Patch::from_texts to construct hunks directly from diff operations, avoiding the overhead of generating and re-parsing a unified diff string.
  • Formatting: Optimized Hunk::fmt to calculate line counts in a single pass.

Fixed

  • Patch Application: Fixed a bug where a trailing newline was incorrectly added to files lacking one, even if the patch only modified lines at the beginning or middle of the file. The original newline status is now preserved unless the patch explicitly modifies the end of the file.
  • Patch Application: Fixed a bug where files resulting in exactly one newline (e.g., replacing all content with a single empty line) were incorrectly truncated to 0 bytes.
  • Parser: Fixed handling of the \ No newline at end of file marker. It now correctly verifies that the marker immediately follows a context or addition line.
  • Parser: Fixed parsing of empty hunks (e.g., @@ -0,0 +0,0 @@) which were previously ignored.
  • Parser: Fixed a bug where a context line in a diff that looks like a closing fence (e.g., ```) would incorrectly terminate the markdown code block. The parser now enforces that a closing fence must not be more indented than the opening fence.
  • Parser: Improved Conflict Marker detection to prevent false positives from Markdown H1 headers (lines of ====). Detection now strictly requires a start marker (<<<<) followed by a middle (====) or end (>>>>) marker.
  • CLI: Fixed formatting in the debug report (-vvvv) where final summary logs were appended outside the markdown code block, breaking the report structure.

Added

  • CLI: Added -R / --reverse flag to reverse patches before applying them (useful for undoing changes).
  • API: Added mpatch::invert_patches helper function to programmatically invert a list of patches.
  • API: Added HunkApplier::set_original_newline_status to manually control the expected newline behavior when using the line-based API.
  • API: Derived PartialEq for ApplyOptions.

Changed

  • Patch Application: Files are now automatically deleted if the patch application results in empty content.
  • Internal: Refactored debug report finalization to be more robust and prevent redundant file locking.

🆚 Compare changes