(** Line-oriented diffs between two blobs. Computes a Myers diff — the algorithm [git diff] uses by default — and groups the result into hunks with the surrounding context. Cost scales with the number of differences rather than with file size, so a small change in a large file is cheap. Two files that differ in more than a thousand lines fall back to a coarse wholesale-replacement diff. The module is named for the granularity it works at: whole lines, matched as opaque units, with no word- or character-level refinement. It produces data only. Rendering it is {!module:Ui.Diff}'s job. *) (** {1 Line-level results} *) type line_kind = | Context | Addition | Deletion (** Whether a line is unchanged, added, or removed. *) type line = { kind : line_kind; old_number : int option; new_number : int option; text : string; } (** A single diff line with its position in the old and new files. *) (** {1 Hunks} *) type hunk = { old_start : int; old_count : int; new_start : int; new_count : int; lines : line list; } (** A contiguous group of changes with surrounding context. *) (** {1 Files} *) type file = { path : string; old_hash : string option; new_hash : string option; old_mode : int option; new_mode : int option; binary : bool; hunks : hunk list; } (** A single file's worth of changes, including metadata. *) (** {1 Computing diffs} *) val of_contents : string -> string -> line list (** [of_contents old_content new_content] produces a flat list of diff lines between two file contents, computed with Myers' O(ND) algorithm. The common prefix and suffix are matched directly; when the remainder differs in more than 1024 lines, it is listed as all deletions followed by all additions rather than spending unbounded time on the search. *) val hunks : ?context:int -> line list -> hunk list (** Group diff lines into hunks with [context] lines of surrounding unchanged content (default 3). *)