patchkit

Crates.iopatchkit
lib.rspatchkit
version0.2.2
created_at2023-11-28 16:45:10.291527+00
updated_at2025-10-28 10:39:29.193534+00
descriptionA library for parsing and manipulating patch files
homepagehttps://github.com/breezy-team/patchkit
repositoryhttps://github.com/breezy-team/patchkit
max_upload_size
id1052175
size941,147
Jelmer Vernooij (jelmer)

documentation

README

Parsing and manipulation of patch files

This crate provides support for parsing and editing of unified diff files, as well as related files (e.g. quilt).

Features

  • Traditional parsing: Parse patch files into structured data
  • Lossless parsing (new): Parse patch files while preserving all formatting and whitespace using the edit module

Example

use patchkit::edit;

let patch_text = r#"--- a/file.txt
+++ b/file.txt
@@ -1,3 +1,3 @@
 line 1
-line 2
+line 2 modified
 line 3
"#;

let parsed = edit::parse(patch_text);
let patch = parsed.tree();

for patch_file in patch.patch_files() {
    for hunk in patch_file.hunks() {
        for line in hunk.lines() {
            if let Some(text) = line.text() {
                println!("{}", text);
            }
        }
    }
}
Commit count: 107

cargo fmt