1
1
use gix_diff:: tree;
2
- use gix_diff:: tree:: recorder:: Location ;
3
2
4
- use crate :: { bstr:: BStr , diff :: Rewrites , Id , Tree } ;
3
+ use crate :: { bstr:: BStr , Id , Tree } ;
5
4
6
5
/// Returned by the `for_each` function to control flow.
7
6
#[ derive( Default , Clone , Copy , PartialOrd , PartialEq , Ord , Eq , Hash ) ]
@@ -86,7 +85,7 @@ pub enum Change<'a, 'old, 'new> {
86
85
source_entry_mode : gix_object:: tree:: EntryMode ,
87
86
/// The object id of the entry before the rename.
88
87
///
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
90
89
/// be different otherwise.
91
90
source_id : Id < ' old > ,
92
91
/// 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> {
129
128
/// using [`Platform::track_rewrites()`].
130
129
#[ allow( clippy:: result_large_err) ]
131
130
#[ 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 > {
133
132
Ok ( Platform {
134
133
state : Default :: default ( ) ,
135
134
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 ) ?,
138
136
} )
139
137
}
140
138
}
@@ -144,39 +142,13 @@ impl<'repo> Tree<'repo> {
144
142
pub struct Platform < ' a , ' repo > {
145
143
state : gix_diff:: tree:: State ,
146
144
lhs : & ' a Tree < ' repo > ,
147
- location : Option < Location > ,
148
- rewrites : Option < Rewrites > ,
145
+ options : crate :: diff:: Options ,
149
146
}
150
147
151
- /// Configuration
152
148
impl 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 ) ;
180
152
self
181
153
}
182
154
}
0 commit comments