pub struct FilePatch {Show 16 fields
pub old_path: Option<Vec<u8>>,
pub new_path: Option<Vec<u8>>,
pub old_mode: Option<u32>,
pub new_mode: Option<u32>,
pub hunks: Vec<Hunk>,
pub is_new: bool,
pub is_delete: bool,
pub is_rename: bool,
pub is_copy: bool,
pub similarity: Option<u8>,
pub dissimilarity: Option<u8>,
pub old_oid_hex: Option<Vec<u8>>,
pub new_oid_hex: Option<Vec<u8>>,
pub is_binary: bool,
pub binary: Option<BinaryPatch>,
pub is_toplevel_relative: bool,
}Expand description
A patch targeting a single file. Produced by parse_unified_patch.
Fields§
§old_path: Option<Vec<u8>>Path on the a/ (old) side, or None for a newly created file.
new_path: Option<Vec<u8>>Path on the b/ (new) side, or None for a deleted file.
old_mode: Option<u32>Mode of the old file, when a mode header was present.
new_mode: Option<u32>Mode of the new file, when a mode header was present.
hunks: Vec<Hunk>§is_new: boolThe patch creates a new file (--- /dev/null / new file mode).
is_delete: boolThe patch deletes the file (+++ /dev/null / deleted file mode).
is_rename: boolThe patch renames the file (rename from/rename to).
is_copy: boolThe patch copies the file (copy from/copy to).
similarity: Option<u8>Similarity score from similarity index N%, used for rename/copy summaries.
dissimilarity: Option<u8>Dissimilarity score from dissimilarity index N%, used for rewrite summaries.
old_oid_hex: Option<Vec<u8>>Hex object id prefixes from the index <old>..<new>[ mode] line, if any.
Carried verbatim (abbreviated or full); the binary apply and the -3
fallback need these to resolve the pre-/post-image blobs.
new_oid_hex: Option<Vec<u8>>§is_binary: boolTrue when the patch is binary: either a GIT binary patch block (with
binary payload) or a metadata-only Binary files ... differ line
(no payload — the postimage must be reconstructed from the object store).
binary: Option<BinaryPatch>The GIT binary patch payload, when this is a binary file patch. The
fragment bytes are still zlib-deflated (the caller inflates them with
the recorded original length), matching git’s two-hunk forward/reverse
layout.
is_toplevel_relative: boolTrue for git (diff --git) patches, whose names are relative to the
repository top-level; false for traditional diffs, whose names are
relative to the current directory (git’s is_toplevel_relative). The
apply cwd-prefix is only prepended to non-toplevel-relative patches.