File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -131,7 +131,7 @@ impl<'cfg> HttpRegistry<'cfg> {
131131 config : & ' cfg Config ,
132132 name : & str ,
133133 ) -> CargoResult < HttpRegistry < ' cfg > > {
134- if !config. cli_unstable ( ) . sparse_registry {
134+ if !source_id . is_crates_io ( ) && ! config. cli_unstable ( ) . sparse_registry {
135135 anyhow:: bail!( "usage of sparse registries requires `-Z sparse-registry`" ) ;
136136 }
137137 let url = source_id. url ( ) . as_str ( ) ;
Original file line number Diff line number Diff line change @@ -891,6 +891,13 @@ commands like [`cargo publish`] that require authentication.
891891
892892Can be overridden with the ` --token ` command-line option.
893893
894+ ##### ` registries.crates-io.protocol `
895+ * Type: string
896+ * Default: ` git ` (or ` sparse ` ` -Z sparse-registry ` is passed)
897+ * Environment: ` CARGO_REGISTRIES_CRATES_IO_PROTOCOL `
898+
899+ Specifies the protocol used to access crates.io. Allowed values are ` git ` or ` sparse ` .
900+
894901#### ` [registry] `
895902
896903The ` [registry] ` table controls the default registry used when one is not
Original file line number Diff line number Diff line change @@ -832,7 +832,7 @@ fn main() {
832832* Tracking Issue: [ 9069] ( https://github.com/rust-lang/cargo/issues/9069 )
833833* RFC: [ #2789 ] ( https://github.com/rust-lang/rfcs/pull/2789 )
834834
835- The ` sparse-registry ` feature allows cargo to interact with remote registries served
835+ The ` sparse-registry ` feature allows Cargo to interact with remote registries served
836836over plain HTTP rather than git. These registries can be identified by urls starting with
837837` sparse+http:// ` or ` sparse+https:// ` .
838838
@@ -841,6 +841,17 @@ crates, which can save significant time and bandwidth.
841841
842842The format of the sparse index is identical to a checkout of a git-based index.
843843
844+ Note that this feature is not required for accessing crates.io over the sparse protocol.
845+ To set the protocol used for crates.io, set in a [ config file] :
846+ ``` toml
847+ [registries .crates-io ]
848+ protocol = ' sparse'
849+ ```
850+ Or use the environment variable ` CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse ` .
851+
852+ Enabling this feature changes the default protocol for accessing crates.io to from ` git `
853+ to ` sparse ` .
854+
844855### credential-process
845856* Tracking Issue: [ #8933 ] ( https://github.com/rust-lang/cargo/issues/8933 )
846857* RFC: [ #2730 ] ( https://github.com/rust-lang/rfcs/pull/2730 )
Original file line number Diff line number Diff line change @@ -2703,15 +2703,6 @@ fn http_requires_z_flag() {
27032703 . run ( ) ;
27042704}
27052705
2706- #[ cargo_test]
2707- fn protocol_sparse_requires_z_flag ( ) {
2708- cargo_process ( "install bar" )
2709- . with_status ( 101 )
2710- . env ( "CARGO_REGISTRIES_CRATES_IO_PROTOCOL" , "sparse" )
2711- . with_stderr ( "[ERROR] usage of sparse registries requires `-Z sparse-registry`" )
2712- . run ( )
2713- }
2714-
27152706#[ cargo_test]
27162707fn protocol ( ) {
27172708 cargo_process ( "install bar" )
You can’t perform that action at this time.
0 commit comments