@@ -94,8 +94,9 @@ pub struct Config {
94
94
/// Lock, if held, of the global package cache along with the number of
95
95
/// acquisitions so far.
96
96
package_cache_lock : RefCell < Option < ( Option < FileLock > , usize ) > > ,
97
- /// HTTP configuration for Cargo
97
+ /// Cached configuration parsed by Cargo
98
98
http_config : LazyCell < CargoHttpConfig > ,
99
+ net_config : LazyCell < CargoNetConfig > ,
99
100
}
100
101
101
102
impl Config {
@@ -155,6 +156,7 @@ impl Config {
155
156
updated_sources : LazyCell :: new ( ) ,
156
157
package_cache_lock : RefCell :: new ( None ) ,
157
158
http_config : LazyCell :: new ( ) ,
159
+ net_config : LazyCell :: new ( ) ,
158
160
}
159
161
}
160
162
@@ -638,8 +640,9 @@ impl Config {
638
640
self . locked = locked;
639
641
self . offline = offline
640
642
|| self
641
- . get :: < Option < bool > > ( "net.offline" )
642
- . unwrap_or ( None )
643
+ . net_config ( )
644
+ . ok ( )
645
+ . and_then ( |n| n. offline )
643
646
. unwrap_or ( false ) ;
644
647
self . target_dir = cli_target_dir;
645
648
self . cli_flags . parse ( unstable_flags) ?;
@@ -929,6 +932,11 @@ impl Config {
929
932
. try_borrow_with ( || Ok ( self . get :: < CargoHttpConfig > ( "http" ) ?) )
930
933
}
931
934
935
+ pub fn net_config ( & self ) -> CargoResult < & CargoNetConfig > {
936
+ self . net_config
937
+ . try_borrow_with ( || Ok ( self . get :: < CargoNetConfig > ( "net" ) ?) )
938
+ }
939
+
932
940
pub fn crates_io_source_id < F > ( & self , f : F ) -> CargoResult < SourceId >
933
941
where
934
942
F : FnMut ( ) -> CargoResult < SourceId > ,
@@ -1457,3 +1465,11 @@ pub enum SslVersionConfig {
1457
1465
Single ( String ) ,
1458
1466
Range ( SslVersionConfigRange ) ,
1459
1467
}
1468
+
1469
+ #[ derive( Debug , Deserialize ) ]
1470
+ pub struct CargoNetConfig {
1471
+ pub retry : Option < u32 > ,
1472
+ pub offline : Option < bool > ,
1473
+ #[ serde( rename = "git-fetch-with-cli" ) ]
1474
+ pub git_fetch_with_cli : Option < bool > ,
1475
+ }
0 commit comments