@@ -51,7 +51,14 @@ impl Options {
5151 pub ( crate ) fn from_configuration ( config : & crate :: config:: Cache ) -> Result < Self , options:: init:: Error > {
5252 Ok ( Options {
5353 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+ } ,
5562 } )
5663 }
5764}
@@ -164,14 +171,14 @@ pub(crate) mod utils {
164171 }
165172
166173 /// 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 .
168175 ///
169176 /// Note that missing values will be defaulted similar to what git does.
170177 #[ allow( clippy:: result_large_err) ]
171178 pub fn new_rewrites (
172179 config : & gix_config:: File < ' static > ,
173180 lenient : bool ,
174- ) -> Result < Option < Rewrites > , new_rewrites:: Error > {
181+ ) -> Result < ( Option < Rewrites > , bool ) , new_rewrites:: Error > {
175182 new_rewrites_inner ( config, lenient, & Diff :: RENAMES , & Diff :: RENAME_LIMIT )
176183 }
177184
@@ -180,33 +187,36 @@ pub(crate) mod utils {
180187 lenient : bool ,
181188 renames : & ' static crate :: config:: tree:: diff:: Renames ,
182189 rename_limit : & ' static crate :: config:: tree:: keys:: UnsignedInteger ,
183- ) -> Result < Option < Rewrites > , new_rewrites:: Error > {
190+ ) -> Result < ( Option < Rewrites > , bool ) , new_rewrites:: Error > {
184191 let copies = match config
185192 . boolean ( renames)
186193 . map ( |value| renames. try_into_renames ( value) )
187194 . transpose ( )
188195 . with_leniency ( lenient) ?
189196 {
190197 Some ( renames) => match renames {
191- Tracking :: Disabled => return Ok ( None ) ,
198+ Tracking :: Disabled => return Ok ( ( None , true ) ) ,
192199 Tracking :: Renames => None ,
193200 Tracking :: RenamesAndCopies => Some ( Copies :: default ( ) ) ,
194201 } ,
195- None => return Ok ( None ) ,
202+ None => return Ok ( ( None , false ) ) ,
196203 } ;
197204
198205 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+ ) )
210220 }
211221
212222 /// Return a low-level utility to efficiently prepare a blob-level diff operation between two resources,
0 commit comments