Skip to main content

Module patch

Module patch 

Source

Structs§

FilePatch
Hunk
PatchError

Enums§

HunkLine
PatchKind

Functions§

apply_hunks
Apply a list of hunks to the original file content, producing the patched text.
apply_hunks_best_effort
Try to apply each hunk individually. Hunks that apply cleanly are applied; hunks that fail are inserted as conflict markers at the expected location. Returns the result text — never fails.
is_patch_file
Returns true if the content looks like a patch file (unified or context diff).
parse_patch
Parse a unified or context diff into a list of per-file patches.
sanitize_patch_path
Sanitize a path from a patch file: strip leading separators, reject .. traversal, and normalize backslashes to forward slashes for cross-platform consistency.