Skip to main content

parse_unified_patch

Function parse_unified_patch 

Source
pub fn parse_unified_patch(input: &[u8]) -> Result<Vec<FilePatch>>
Expand description

Parse a unified/git diff into one FilePatch per file it touches.

The parser is intentionally lenient about leading commentary (commit messages, index <oid>..<oid> lines, etc.): anything that is not part of a recognised header or hunk body is skipped. It errors only on structurally invalid hunks (bad @@ headers, body lines that overflow the declared hunk counts, or hunk bodies that appear with no preceding file header).