Expand description
Unified-diff text to FileDiffs, with no I/O: the one parser behind
the system-git backend (git diff output) and the hosting API diffs (a
host’s per-file patch, which has hunks but no diff --git header).
Lines are split with str::lines, so a \r\n terminator is dropped
like a \n: a CRLF patch parses as the same lines as an LF one. A
\ No newline at end of file marker is not a line of the file and is
skipped.
Functions§
- parse_
hunks - Parses the hunks of one file’s
patch(what a hosting API returns per file:@@ -a,b +c,d @@sections, nodiff --git/---/+++header) into aFileDiffforpathwith the givenstatus. Anything before the first@@line is skipped, so a patch that does carry---/+++lines parses the same. An empty patch (a binary file, a mode change, a rename without edits) has no hunks. - parse_
unified - Parses a whole
git diffoutput: oneFileDiffperdiff --githeader, its status read from the extended header lines (new file mode,deleted file mode,rename from|to).