gix_diff/
lib.rs

1//! Algorithms for diffing various git object types and for generating patches, highly optimized for performance.
2//! ## Feature Flags
3#![cfg_attr(
4    all(doc, feature = "document-features"),
5    doc = ::document_features::document_features!()
6)]
7#![cfg_attr(all(doc, feature = "document-features"), feature(doc_cfg, doc_auto_cfg))]
8#![deny(missing_docs, rust_2018_idioms)]
9#![forbid(unsafe_code)]
10
11/// Re-export for use in public API.
12#[cfg(feature = "blob")]
13pub use gix_command as command;
14/// Re-export for use in public API.
15#[cfg(feature = "blob")]
16pub use gix_object as object;
17
18/// A structure to capture how to perform rename and copy tracking, used by the [rewrites::Tracker].
19#[derive(Debug, Copy, Clone, PartialEq)]
20#[cfg(feature = "blob")]
21pub struct Rewrites {
22    /// If `Some(…)`, also find copies. `None` is the default which does not try to detect copies at all.
23    ///
24    /// Note that this is an even more expensive operation than detecting renames stemming from additions and deletions
25    /// as the resulting set to search through is usually larger.
26    pub copies: Option<rewrites::Copies>,
27    /// The percentage of similarity needed for files to be considered renamed, defaulting to `Some(0.5)`.
28    /// This field is similar to `git diff -M50%`.
29    ///
30    /// If `None`, files are only considered equal if their content matches 100%.
31    /// Note that values greater than 1.0 have no different effect than 1.0.
32    pub percentage: Option<f32>,
33    /// The amount of files to consider for fuzzy rename or copy tracking. Defaults to 1000, meaning that only 1000*1000
34    /// combinations can be tested for fuzzy matches, i.e. the ones that try to find matches by comparing similarity.
35    /// If 0, there is no limit.
36    ///
37    /// If the limit would not be enough to test the entire set of combinations, the algorithm will trade in precision and not
38    /// run the fuzzy version of identity tests at all. That way results are never partial.
39    pub limit: usize,
40
41    /// If `true`, empty blobs will be tracked. If `false`, they do not participate in rename tracking.
42    ///
43    /// Leaving this off usually leads to better results as empty files don't have a unique-enough identity.
44    pub track_empty: bool,
45}
46
47/// Contains a [Tracker](rewrites::Tracker) to detect rewrites.
48#[cfg(feature = "blob")]
49pub mod rewrites;
50
51///
52pub mod tree;
53pub use tree::function::diff as tree;
54
55///
56#[cfg(feature = "blob")]
57pub mod tree_with_rewrites;
58#[cfg(feature = "blob")]
59pub use tree_with_rewrites::function::diff as tree_with_rewrites;
60
61///
62#[cfg(feature = "index")]
63pub mod index;
64#[cfg(feature = "index")]
65pub use index::function::diff as index;
66
67///
68#[cfg(feature = "blob")]
69pub mod blob;