pub struct FileDiff {
pub old_path: Option<String>,
pub new_path: String,
pub is_new: bool,
pub is_rename: bool,
pub added: BTreeSet<u32>,
pub removed: BTreeSet<u32>,
/* private fields */
}Expand description
Per-file diff information.
Fields§
§old_path: Option<String>Old-side (base) path. Differs from new_path on a rename; None for an
added file.
new_path: StringNew-side (head) path.
is_new: boolWhether the file is newly added in head.
is_rename: boolWhether the file was renamed (and possibly modified).
added: BTreeSet<u32>New-side line numbers added or modified by the diff.
removed: BTreeSet<u32>Old-side line numbers removed by the diff.
Implementations§
Source§impl FileDiff
impl FileDiff
Sourcepub fn new(
new_path: impl Into<String>,
old_path: Option<String>,
is_new: bool,
is_rename: bool,
added: BTreeSet<u32>,
removed: BTreeSet<u32>,
) -> Self
pub fn new( new_path: impl Into<String>, old_path: Option<String>, is_new: bool, is_rename: bool, added: BTreeSet<u32>, removed: BTreeSet<u32>, ) -> Self
Builds a FileDiff with only added/removed line sets and no hunk
alignment. Used to construct diffs programmatically and in tests; the
git2-driven path uses DiffModel::from_diff which also records hunks.
Sourcepub fn map_base_to_head(&self, old_line: u32) -> Option<u32>
pub fn map_base_to_head(&self, old_line: u32) -> Option<u32>
Maps an unchanged base-side line to its head-side line number.
Returns None when the base line was removed or modified (i.e. it has no
unchanged counterpart in head). Context lines inside hunks use the exact
pairs git2 reported; lines outside every hunk use the cumulative hunk
offset.