Skip to main content

Module git

Module git 

Source
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.
FilePatch
One file’s changes.
ParseError
Why a patch did not parse.
Patch
A parsed patch.
PatchHunk
A hunk: @@ -old_start,old_len +new_start,new_len @@ section.
PatchLine
One line of a hunk, with its line numbers on each side.
PatchView
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.
TemplateLinks
Links from URL templates. {path} and {line} are filled in, and so is every {name} given through var:

Enums§

FileStatus
What happened to a file.
LineKind
A line of a hunk.

Traits§

LinkProvider
Where file and line links point.

Functions§

parse_unified
Parse git diff (or diff -u) output. Text outside any file, such as a commit message, is skipped.