Skip to main content

FilePatch

Struct FilePatch 

Source
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: bool

The patch creates a new file (--- /dev/null / new file mode).

§is_delete: bool

The patch deletes the file (+++ /dev/null / deleted file mode).

§is_rename: bool

The patch renames the file (rename from/rename to).

§is_copy: bool

The 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: bool

True 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: bool

True 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.

Trait Implementations§

Source§

impl Clone for FilePatch

Source§

fn clone(&self) -> FilePatch

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FilePatch

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for FilePatch

Source§

impl PartialEq for FilePatch

Source§

fn eq(&self, other: &FilePatch) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for FilePatch

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.