Expand description
git diff output: a parser and a review-style renderer.
parse_unified reads git diff (and plain diff -u) output: diff --git headers, index lines, new, deleted, renamed and copied files,
mode changes, binary files, ---/+++, hunks and \ No newline at end of file. PatchView renders a Patch with a file tree summary,
syntax-highlighted hunks, inline Annotations and links from a
LinkProvider.
Paths are decoded from git’s C-style quoting ("b/\033[2J"), so a
FilePatch holds them exactly as named, control characters included.
PatchView shows paths, modes and hunk sections with controls made
visible (␛[2J) and percent-encodes controls in link targets; line
content is shown as given, so sanitize untrusted patch text before
parsing if its content must be inert too.
Structs§
- Annotation
- A note attached to a line of the new side, shown under it.
- File
Patch - One file’s changes.
- Parse
Error - Why a patch did not parse.
- Patch
- A parsed patch.
- Patch
Hunk - A hunk:
@@ -old_start,old_len +new_start,new_len @@ section. - Patch
Line - One line of a hunk, with its line numbers on each side.
- Patch
View - A review-style rendering of a
Patch: a file tree with per-file counts, then each file’s header and highlighted hunks, with annotations under their lines and a changed-line summary at the end. - Template
Links - Links from URL templates.
{path}and{line}are filled in, and so is every{name}given throughvar:
Enums§
- File
Status - What happened to a file.
- Line
Kind - A line of a hunk.
Traits§
- Link
Provider - Where file and line links point.
Functions§
- parse_
unified - Parse
git diff(ordiff -u) output. Text outside any file, such as a commit message, is skipped.