package patch
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Module PatchSource
Patch - parsing and applying unified diffs in pure OCaml
type hunk = {mine_start : int;mine_len : int;mine : string list;their_start : int;their_len : int;their : string list;
}A hunk contains some difference between two files: each with a start line and length, and then the content as lists of string.
pp_hunk ppf hunk pretty-prints the hunk on ppf, the printing is in the same format as diff does.
pp_operation ~git ppf op pretty-prints the operation op on ppf, If git is true, the git diff style will be output (a "diff --git oldfilename newfilename" line, etc).
operation_eq a b is true if a and b are equal.
The type of a diff: an operation, a list of hunks, and information whether a trailing newline exists on the left and right.
pp ~git ppf t pretty-prints t on ppf. If git is true, "git diff" style will be printed.
pp ~git ppf diffs pretty-prints diffs on ppf. If git is true, "git diff" style will be printed.
patch file_contents diff applies diff on file_contents, resulting in the new file contents (or None if deleted).