@@ -51,7 +51,14 @@ impl Options {
51
51
pub ( crate ) fn from_configuration ( config : & crate :: config:: Cache ) -> Result < Self , options:: init:: Error > {
52
52
Ok ( Options {
53
53
location : Some ( Location :: Path ) ,
54
- rewrites : config. diff_renames ( ) ?. unwrap_or_default ( ) . into ( ) ,
54
+ rewrites : {
55
+ let ( rewrites, is_configured) = config. diff_renames ( ) ?;
56
+ if is_configured {
57
+ rewrites
58
+ } else {
59
+ Some ( Default :: default ( ) )
60
+ }
61
+ } ,
55
62
} )
56
63
}
57
64
}
@@ -164,14 +171,14 @@ pub(crate) mod utils {
164
171
}
165
172
166
173
/// Create an instance by reading all relevant information from the `config`uration, while being `lenient` or not.
167
- /// Returns `Ok(None) ` if nothing is configured.
174
+ /// Returns `Ok(( None, false)) ` if nothing is configured, or `Ok((None, true))` if it's configured and disabled .
168
175
///
169
176
/// Note that missing values will be defaulted similar to what git does.
170
177
#[ allow( clippy:: result_large_err) ]
171
178
pub fn new_rewrites (
172
179
config : & gix_config:: File < ' static > ,
173
180
lenient : bool ,
174
- ) -> Result < Option < Rewrites > , new_rewrites:: Error > {
181
+ ) -> Result < ( Option < Rewrites > , bool ) , new_rewrites:: Error > {
175
182
new_rewrites_inner ( config, lenient, & Diff :: RENAMES , & Diff :: RENAME_LIMIT )
176
183
}
177
184
@@ -180,33 +187,36 @@ pub(crate) mod utils {
180
187
lenient : bool ,
181
188
renames : & ' static crate :: config:: tree:: diff:: Renames ,
182
189
rename_limit : & ' static crate :: config:: tree:: keys:: UnsignedInteger ,
183
- ) -> Result < Option < Rewrites > , new_rewrites:: Error > {
190
+ ) -> Result < ( Option < Rewrites > , bool ) , new_rewrites:: Error > {
184
191
let copies = match config
185
192
. boolean ( renames)
186
193
. map ( |value| renames. try_into_renames ( value) )
187
194
. transpose ( )
188
195
. with_leniency ( lenient) ?
189
196
{
190
197
Some ( renames) => match renames {
191
- Tracking :: Disabled => return Ok ( None ) ,
198
+ Tracking :: Disabled => return Ok ( ( None , true ) ) ,
192
199
Tracking :: Renames => None ,
193
200
Tracking :: RenamesAndCopies => Some ( Copies :: default ( ) ) ,
194
201
} ,
195
- None => return Ok ( None ) ,
202
+ None => return Ok ( ( None , false ) ) ,
196
203
} ;
197
204
198
205
let default = Rewrites :: default ( ) ;
199
- Ok ( Rewrites {
200
- copies,
201
- limit : config
202
- . integer ( rename_limit)
203
- . map ( |value| rename_limit. try_into_usize ( value) )
204
- . transpose ( )
205
- . with_leniency ( lenient) ?
206
- . unwrap_or ( default. limit ) ,
207
- ..default
208
- }
209
- . into ( ) )
206
+ Ok ( (
207
+ Rewrites {
208
+ copies,
209
+ limit : config
210
+ . integer ( rename_limit)
211
+ . map ( |value| rename_limit. try_into_usize ( value) )
212
+ . transpose ( )
213
+ . with_leniency ( lenient) ?
214
+ . unwrap_or ( default. limit ) ,
215
+ ..default
216
+ }
217
+ . into ( ) ,
218
+ true ,
219
+ ) )
210
220
}
211
221
212
222
/// Return a low-level utility to efficiently prepare a blob-level diff operation between two resources,
0 commit comments