@@ -75,7 +75,8 @@ pub struct Options {
75
75
pub ( crate ) lossy_config : Option < bool > ,
76
76
pub ( crate ) lenient_config : bool ,
77
77
pub ( crate ) bail_if_untrusted : bool ,
78
- pub ( crate ) config_overrides : Vec < BString > ,
78
+ pub ( crate ) api_config_overrides : Vec < BString > ,
79
+ pub ( crate ) cli_config_overrides : Vec < BString > ,
79
80
/// Internal to pass an already obtained CWD on to where it may also be used. This avoids the CWD being queried more than once per repo.
80
81
pub ( crate ) current_dir : Option < PathBuf > ,
81
82
}
@@ -91,7 +92,8 @@ impl Default for Options {
91
92
lossy_config : None ,
92
93
lenient_config : true ,
93
94
bail_if_untrusted : false ,
94
- config_overrides : Vec :: new ( ) ,
95
+ api_config_overrides : Vec :: new ( ) ,
96
+ cli_config_overrides : Vec :: new ( ) ,
95
97
current_dir : None ,
96
98
}
97
99
}
@@ -138,7 +140,15 @@ impl Options {
138
140
/// as the configuration is initialized to allow affecting the repository instantiation phase, both on disk or when opening.
139
141
/// The configuration is marked with [source API][git_config::Source::Api].
140
142
pub fn config_overrides ( mut self , values : impl IntoIterator < Item = impl Into < BString > > ) -> Self {
141
- self . config_overrides = values. into_iter ( ) . map ( Into :: into) . collect ( ) ;
143
+ self . api_config_overrides = values. into_iter ( ) . map ( Into :: into) . collect ( ) ;
144
+ self
145
+ }
146
+
147
+ /// Set configuration values of the form `core.abbrev=5` or `remote.origin.url = foo` or `core.bool-implicit-true` for application
148
+ /// as CLI overrides to the repository configuration, marked with [source CLI][git_config::Source::Cli].
149
+ /// These are equivalent to CLI overrides passed with `-c` in `git`, for example.
150
+ pub fn cli_overrides ( mut self , values : impl IntoIterator < Item = impl Into < BString > > ) -> Self {
151
+ self . cli_config_overrides = values. into_iter ( ) . map ( Into :: into) . collect ( ) ;
142
152
self
143
153
}
144
154
@@ -241,7 +251,8 @@ impl git_sec::trust::DefaultForLevel for Options {
241
251
lossy_config : None ,
242
252
bail_if_untrusted : false ,
243
253
lenient_config : true ,
244
- config_overrides : Vec :: new ( ) ,
254
+ api_config_overrides : Vec :: new ( ) ,
255
+ cli_config_overrides : Vec :: new ( ) ,
245
256
current_dir : None ,
246
257
} ,
247
258
git_sec:: Trust :: Reduced => Options {
@@ -253,7 +264,8 @@ impl git_sec::trust::DefaultForLevel for Options {
253
264
bail_if_untrusted : false ,
254
265
lenient_config : true ,
255
266
lossy_config : None ,
256
- config_overrides : Vec :: new ( ) ,
267
+ api_config_overrides : Vec :: new ( ) ,
268
+ cli_config_overrides : Vec :: new ( ) ,
257
269
current_dir : None ,
258
270
} ,
259
271
}
@@ -361,7 +373,8 @@ impl ThreadSafeRepository {
361
373
lenient_config,
362
374
bail_if_untrusted,
363
375
permissions : Permissions { ref env, config } ,
364
- ref config_overrides,
376
+ ref api_config_overrides,
377
+ ref cli_config_overrides,
365
378
ref current_dir,
366
379
} = options;
367
380
let current_dir = current_dir. as_deref ( ) . expect ( "BUG: current_dir must be set by caller" ) ;
@@ -402,7 +415,8 @@ impl ThreadSafeRepository {
402
415
env. clone ( ) ,
403
416
config,
404
417
lenient_config,
405
- config_overrides,
418
+ api_config_overrides,
419
+ cli_config_overrides,
406
420
) ?;
407
421
408
422
if bail_if_untrusted && git_dir_trust != git_sec:: Trust :: Full {
@@ -571,7 +585,7 @@ mod tests {
571
585
#[ test]
572
586
fn size_of_options ( ) {
573
587
let actual = std:: mem:: size_of :: < Options > ( ) ;
574
- let limit = 140 ;
588
+ let limit = 160 ;
575
589
assert ! (
576
590
actual <= limit,
577
591
"{} <= {}: size shouldn't change without us knowing (on windows, it's bigger)" ,
0 commit comments