#[non_exhaustive]pub struct DiffOptions {
pub context_lines: usize,
pub inter_hunk_context: usize,
pub algorithm: DiffAlgorithm,
pub indent_heuristic: bool,
pub renames: RenameDetection,
pub filter: Option<DiffFilter>,
pub whitespace: WhitespaceMode,
pub word_level_inline: bool,
pub function_context: bool,
/* private fields */
}Expand description
Line-diff options shared by structured output, log patches, and benchmarks.
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.context_lines: usizeUnchanged context lines around each change (Git -U, default 3).
inter_hunk_context: usize--inter-hunk-context (default 0).
algorithm: DiffAlgorithmLine diff algorithm.
indent_heuristic: boolApply Git’s indent heuristic when generating hunks.
renames: RenameDetectionRename detection applied by Diff::files_for_entries and tree content loaders when
entries are not already paired (default similarity 50 via RenameDetection::Similarity, Git -M).
filter: Option<DiffFilter>--diff-filter status selection (applied after rename detection).
whitespace: WhitespaceModeWhitespace comparison rules for line diffs.
word_level_inline: boolWhen false, skip intra-line word emphasis (line-level hunks only).
function_context: boolExpand hunks to enclosing function boundaries (git diff -W).
Implementations§
Source§impl DiffOptions
impl DiffOptions
Sourcepub fn with_context_lines(self, context_lines: usize) -> Self
pub fn with_context_lines(self, context_lines: usize) -> Self
Builder-style update of context lines (-U).
Sourcepub fn with_inter_hunk_context(self, inter_hunk_context: usize) -> Self
pub fn with_inter_hunk_context(self, inter_hunk_context: usize) -> Self
Builder-style update of inter-hunk context.
Sourcepub fn with_algorithm(self, algorithm: DiffAlgorithm) -> Self
pub fn with_algorithm(self, algorithm: DiffAlgorithm) -> Self
Builder-style update of the line diff algorithm.
Sourcepub fn with_indent_heuristic(self, indent_heuristic: bool) -> Self
pub fn with_indent_heuristic(self, indent_heuristic: bool) -> Self
Builder-style update of the indent heuristic flag.
Sourcepub fn with_renames(self, renames: RenameDetection) -> Self
pub fn with_renames(self, renames: RenameDetection) -> Self
Builder-style update of rename detection.
Sourcepub fn with_filter(self, filter: Option<DiffFilter>) -> Self
pub fn with_filter(self, filter: Option<DiffFilter>) -> Self
Builder-style update of diff status filter.
Sourcepub fn rename_similarity_threshold(&self) -> Option<u32>
pub fn rename_similarity_threshold(&self) -> Option<u32>
Similarity percent for rename detection, or None when RenameDetection::Off.
Sourcepub fn rename_threshold_u32(&self) -> u32
pub fn rename_threshold_u32(&self) -> u32
u32 threshold for rename pairing (apply_rename_detection_to_diff_entries) and related APIs.
Sourcepub fn with_word_level_inline(self, word_level_inline: bool) -> Self
pub fn with_word_level_inline(self, word_level_inline: bool) -> Self
Builder-style update of word-level inline emphasis.
Sourcepub fn with_whitespace(self, whitespace: WhitespaceMode) -> Self
pub fn with_whitespace(self, whitespace: WhitespaceMode) -> Self
Builder-style update of whitespace comparison rules.
Sourcepub fn with_no_index_stat_only(self, stat_only: bool) -> Self
pub fn with_no_index_stat_only(self, stat_only: bool) -> Self
When true, super::diff_paths counts lines instead of building hunks.
Sourcepub fn cap_word_level_inline_for_changed_files(
self,
changed_files: usize,
) -> Self
pub fn cap_word_level_inline_for_changed_files( self, changed_files: usize, ) -> Self
Turn off word-level inline when changed_files exceeds
WORD_LEVEL_INLINE_MAX_CHANGED_FILES.
Sourcepub fn from_config(config: &ConfigSet) -> Self
pub fn from_config(config: &ConfigSet) -> Self
Read diff.algorithm, diff.context, diff.interHunkContext, diff.indentHeuristic,
and diff.renames from repository config.
Sourcepub fn resolve_indent_heuristic(
config: &ConfigSet,
cli_indent_heuristic: bool,
cli_no_indent_heuristic: bool,
) -> bool
pub fn resolve_indent_heuristic( config: &ConfigSet, cli_indent_heuristic: bool, cli_no_indent_heuristic: bool, ) -> bool
Resolve indent heuristic with optional CLI overrides (log/diff plumbing).
Sourcepub fn resolve_indent_heuristic_with_override(
config: &ConfigSet,
cli_override: IndentHeuristicOverride,
) -> bool
pub fn resolve_indent_heuristic_with_override( config: &ConfigSet, cli_override: IndentHeuristicOverride, ) -> bool
Like Self::resolve_indent_heuristic, with a structured CLI override enum.
Trait Implementations§
Source§impl Clone for DiffOptions
impl Clone for DiffOptions
Source§impl Debug for DiffOptions
impl Debug for DiffOptions
Source§impl Default for DiffOptions
impl Default for DiffOptions
Source§impl From<&DiffOptions> for UnifiedDiffOptions<'_>
Carries the line settings of a repository diff (context, inter-hunk context, algorithm,
indent heuristic, whitespace rules and -W) over to a text diff. Labels, function-name
rules and anchors stay at their defaults.
impl From<&DiffOptions> for UnifiedDiffOptions<'_>
Carries the line settings of a repository diff (context, inter-hunk context, algorithm,
indent heuristic, whitespace rules and -W) over to a text diff. Labels, function-name
rules and anchors stay at their defaults.