pub struct FileChange {
pub path: String,
pub kind: String,
pub old_path: Option<String>,
pub similarity_score: Option<f64>,
pub mode: Option<FileMode>,
pub old_mode: Option<FileMode>,
pub binary: bool,
pub symlink: Option<SymlinkChange>,
pub lines: Option<Vec<LineDiff>>,
pub line_counts: Option<LineCounts>,
pub eol: FileEolState,
}Fields§
§path: String§kind: String§old_path: Option<String>§similarity_score: Option<f64>Rename-detector score (0.0–1.0) for kind == "renamed" entries.
The patch renderer emits this as similarity index N% in the
extended diff header; without it git apply rejects rename
patches because there’s no signal that b/new shouldn’t already
exist on the target side.
mode: Option<FileMode>Git file mode of the content side, used by the patch renderer to
emit new file mode <mode> (adds) / deleted file mode <mode>
(deletes). None falls back to 100644 (a regular file). For an
executable the renderer emits 100755; for a symlink 120000
(and the hunk body is the link target, matching git’s blob
representation of a symlink). For a modified change it is the
new (post-change) mode, paired with old_mode.
old_mode: Option<FileMode>Old (pre-change) git file mode for a modified change. When it
differs from mode the renderer emits old mode/new mode
extended headers so a chmod (e.g. exec-bit flip) round-trips
through git apply even when the file’s content is unchanged.
binary: bool§symlink: Option<SymlinkChange>Raw symlink target bytes for each side of a change that touches a
symlink. Git stores a symlink’s blob as the raw bytes of its target,
which on Unix need not be valid UTF-8 — so they can never flow through
content_str()/diff_blobs (which require UTF-8) or be binary-marked
(a 120000 placeholder-binary stanza is rejected by git apply).
When Some, the patch renderer reconstructs a byte-exact target hunk
from these bytes — the single byte-preserving symlink path across every
surface (add/delete/edit/rename) and both backends. None means the
change does not involve a symlink and renders as ordinary text.
lines: Option<Vec<LineDiff>>§line_counts: Option<LineCounts>Pre-computed line tally for paths where we counted before
dropping the hunk vector (the --stat path). When present
DiffStats reads it instead of walking lines, so the
summary remains accurate without us retaining the hunks.
eol: FileEolStateTrailing-newline state and total line counts per side. The
patch renderer uses these to emit the unified-diff
\ No newline at end of file marker; diff_blobs strips
line terminators before the renderer ever sees them, so the
state must be plumbed alongside the hunk vector. Defaults
(true / 0) mean “no marker needed”, which is what
status-only fast paths fall back to.
Trait Implementations§
Source§impl Clone for FileChange
impl Clone for FileChange
Source§impl Debug for FileChange
impl Debug for FileChange
Source§impl Default for FileChange
impl Default for FileChange
Source§impl JsonSchema for FileChange
impl JsonSchema for FileChange
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more