Expand description
The *** Begin Patch envelope apply_patch takes: its parser and its matcher
(spec 3.1 §7.26, §10 D8).
*** Begin Patch
*** Add File: docs/new.md
+first line
*** Delete File: old.txt
*** Update File: src/lib.rs
*** Move to: src/core.rs
@@ fn main()
context line
-removed line
+added line
*** End PatchA hunk is located by its context and removed lines, never by line numbers: an exact
match first, then one that ignores trailing whitespace and line endings, and never an
ambiguous or fuzzy one. A hunk with an @@ anchor matches at the first place at or
after the anchor line — the line equal to the anchor, or starting with it — and the
first anchor of a hunk must name one line; a hunk without one must match exactly once
after the previous hunk. Each line keeps its own line
ending, and added lines take the file’s prevailing one.
Structs§
- Hunk
- One located change of an
Update File. - Patch
- A parsed patch: its file operations in order.
- Patch
Error - Why a patch does not parse or does not apply.
Enums§
Functions§
- apply_
hunks - Applies
hunkstotext, returning the new text (spec 3.1 §7.26). - parse_
patch - Parses the
*** Begin Patchenvelope (spec 3.1 §7.26).