pub struct FilePatch {Show 23 fields
pub diff_old_path: Option<String>,
pub diff_new_path: Option<String>,
pub old_path: Option<String>,
pub new_path: Option<String>,
pub saw_old_header: bool,
pub saw_new_header: bool,
pub old_mode: Option<String>,
pub new_mode: Option<String>,
pub old_mode_line: Option<usize>,
pub new_mode_line: Option<usize>,
pub is_new: bool,
pub is_deleted: bool,
pub is_rename: bool,
pub is_copy: bool,
pub similarity_index: Option<u32>,
pub dissimilarity_index: Option<u32>,
pub old_oid: Option<String>,
pub new_oid: Option<String>,
pub binary_patch: Option<BinaryPatchPayload>,
pub is_binary: bool,
pub hunks: Vec<Hunk>,
pub ws_rule: u32,
pub is_toplevel_relative: bool,
}Expand description
Represents one file in a unified diff.
Fields§
§diff_old_path: Option<String>Path from diff --git old side (a/...) when present.
diff_new_path: Option<String>Path from diff --git new side (b/...) when present.
old_path: Option<String>Path on the old side (None for new files).
new_path: Option<String>Path on the new side (None for deleted files).
saw_old_header: boolWhether an explicit --- header line was present.
saw_new_header: boolWhether an explicit +++ header line was present.
old_mode: Option<String>Old mode from extended header.
new_mode: Option<String>New mode from extended header.
old_mode_line: Option<usize>Source line (1-based) of old mode / deleted file mode for diagnostics.
new_mode_line: Option<usize>Source line (1-based) of new mode / new file mode for diagnostics.
is_new: boolWhether this file is being newly created.
is_deleted: boolWhether this file is being deleted.
is_rename: boolWhether this is a rename.
is_copy: boolWhether this is a copy.
similarity_index: Option<u32>Similarity index (e.g., 90 for 90%).
dissimilarity_index: Option<u32>Dissimilarity index for rewrites.
old_oid: Option<String>Old blob OID from the index header (abbreviated).
new_oid: Option<String>New blob OID from the index header (abbreviated).
binary_patch: Option<BinaryPatchPayload>Parsed binary patch payload (GIT binary patch) if present.
is_binary: boolWhether this is a binary change (GIT binary patch payload or a
Binary files ... differ marker); stat/numstat show Bin / -.
hunks: Vec<Hunk>Hunks to apply.
ws_rule: u32Merged core.whitespace + whitespace attribute (Git ws_rule); 0 before assignment.
is_toplevel_relative: boolGit patch->is_toplevel_relative: set for diff --git patches only. When false, paths are
prefixed with the setup directory (work-tree-relative CWD) like prefix_patch in Git.
Implementations§
Source§impl FilePatch
impl FilePatch
Sourcepub fn effective_path(&self) -> Option<&str>
pub fn effective_path(&self) -> Option<&str>
Effective path for the file. For deletions, use old_path (new is /dev/null). For additions, use new_path (old is /dev/null). Otherwise prefer new_path.
Sourcepub fn source_path(&self) -> Option<&str>
pub fn source_path(&self) -> Option<&str>
Source path to read preimage content from.
For rename/copy patches this is the old path, otherwise this is the effective path.
Sourcepub fn target_path(&self) -> Option<&str>
pub fn target_path(&self) -> Option<&str>
Destination path to write postimage content to.
For additions/renames/copies this is the new path, otherwise this is the effective path.
Sourcepub fn involves_gitlink(&self) -> bool
pub fn involves_gitlink(&self) -> bool
True when this patch touches a gitlink/submodule (mode 160000).
Sourcepub fn worktree_rel_operational(
&self,
adjusted: &str,
setup_prefix: &str,
) -> String
pub fn worktree_rel_operational( &self, adjusted: &str, setup_prefix: &str, ) -> String
Work-tree-relative path for filesystem IO and .gitattributes (Git prefix_patch).