#[non_exhaustive]pub struct FileDiff {
pub change: ChangeKind,
pub path: PathBuf,
pub old_path: Option<PathBuf>,
pub hunks: Vec<Hunk>,
pub raw: String,
}Expand description
One file’s full parsed diff (hunks and lines) — the shared
vcs_diff::FileDiff, returned by Repo::diff directly
(no remapping); the same type GitApi::diff/JjApi::diff already return.
One file’s entry in a parsed git-format unified diff (git diff or
jj diff --git).
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.change: ChangeKindHow the file changed.
path: PathBufThe file’s path — the new path for a rename — forward-slash normalised.
A PathBuf (not a String) so a non-UTF-8 filename is carried
losslessly: git C-quotes a non-ASCII path into octal escapes that decode
back to the exact bytes, kept here via path_from_bytes rather than
substituted with U+FFFD. (For jj’s raw-UTF-8 --git diff a non-UTF-8
path is still subject to the surrounding text layer’s decode; the
byte-faithful cross-backend round-trip is the status/conflict path, which
carries PathBuf end to end.)
old_path: Option<PathBuf>For a rename, the original path (forward-slash normalised); None otherwise.
hunks: Vec<Hunk>The @@ hunks; empty for a binary file or a pure rename with no edits.
raw: StringThe verbatim diff section for this file (the diff --git … block through
to the next file), for callers that display the raw text.