11use gix_diff:: tree;
2- use gix_diff:: tree:: recorder:: Location ;
32
4- use crate :: { bstr:: BStr , diff :: Rewrites , Id , Tree } ;
3+ use crate :: { bstr:: BStr , Id , Tree } ;
54
65/// Returned by the `for_each` function to control flow.
76#[ derive( Default , Clone , Copy , PartialOrd , PartialEq , Ord , Eq , Hash ) ]
@@ -86,7 +85,7 @@ pub enum Change<'a, 'old, 'new> {
8685 source_entry_mode : gix_object:: tree:: EntryMode ,
8786 /// The object id of the entry before the rename.
8887 ///
89- /// Note that this is the same as `id` if we require the [similarity to be 100%](Rewrites::percentage), but may
88+ /// Note that this is the same as `id` if we require the [similarity to be 100%](gix_diff:: Rewrites::percentage), but may
9089 /// be different otherwise.
9190 source_id : Id < ' old > ,
9291 /// Information about the diff we performed to detect similarity and match the `source_id` with the current state at `id`.
@@ -129,12 +128,11 @@ impl<'repo> Tree<'repo> {
129128 /// using [`Platform::track_rewrites()`].
130129 #[ allow( clippy:: result_large_err) ]
131130 #[ doc( alias = "diff_tree_to_tree" , alias = "git2" ) ]
132- pub fn changes < ' a > ( & ' a self ) -> Result < Platform < ' a , ' repo > , crate :: diff:: new_rewrites :: Error > {
131+ pub fn changes < ' a > ( & ' a self ) -> Result < Platform < ' a , ' repo > , crate :: diff:: options :: init :: Error > {
133132 Ok ( Platform {
134133 state : Default :: default ( ) ,
135134 lhs : self ,
136- location : Some ( Location :: Path ) ,
137- rewrites : self . repo . config . diff_renames ( ) ?. unwrap_or_default ( ) . into ( ) ,
135+ options : crate :: diff:: Options :: from_configuration ( & self . repo . config ) ?,
138136 } )
139137 }
140138}
@@ -144,39 +142,13 @@ impl<'repo> Tree<'repo> {
144142pub struct Platform < ' a , ' repo > {
145143 state : gix_diff:: tree:: State ,
146144 lhs : & ' a Tree < ' repo > ,
147- location : Option < Location > ,
148- rewrites : Option < Rewrites > ,
145+ options : crate :: diff:: Options ,
149146}
150147
151- /// Configuration
152148impl Platform < ' _ , ' _ > {
153- /// Do not keep track of filepaths at all, which will leave all [`location`][Change::location] fields empty.
154- pub fn no_locations ( & mut self ) -> & mut Self {
155- self . location = Some ( Location :: FileName ) ;
156- self
157- }
158-
159- /// Keep track of file-names, which makes the [`location`][Change::location] field usable with the filename of the changed item.
160- pub fn track_filename ( & mut self ) -> & mut Self {
161- self . location = Some ( Location :: FileName ) ;
162- self
163- }
164-
165- /// Keep track of the entire path of a change, relative to the repository. (default).
166- ///
167- /// This makes the [`location`][Change::location] field usable.
168- pub fn track_path ( & mut self ) -> & mut Self {
169- self . location = Some ( Location :: Path ) ;
170- self
171- }
172-
173- /// Provide `None` to disable rewrite tracking entirely, or pass `Some(<configuration>)` to control to
174- /// what extent rename and copy tracking is performed.
175- ///
176- /// Note that by default, the git configuration determines rewrite tracking and git defaults are used
177- /// if nothing is configured, which turns rename tracking with 50% similarity on, while not tracking copies at all.
178- pub fn track_rewrites ( & mut self , renames : Option < Rewrites > ) -> & mut Self {
179- self . rewrites = renames;
149+ /// Adjust diff options with `change_opts`.
150+ pub fn options ( & mut self , change_opts : impl FnOnce ( & mut crate :: diff:: Options ) ) -> & mut Self {
151+ change_opts ( & mut self . options ) ;
180152 self
181153 }
182154}
0 commit comments