@@ -675,6 +675,7 @@ unstable_cli_options!(
675
675
doctest_xcompile: bool = ( "Compile and run doctests for non-host target using runner config" ) ,
676
676
dual_proc_macros: bool = ( "Build proc-macros for both the host and the target" ) ,
677
677
features: Option <Vec <String >> = ( HIDDEN ) ,
678
+ gitoxide: Option <GitoxideFeatures > = ( "Use gitoxide for the given git interactions, or all of them if no argument is given" ) ,
678
679
jobserver_per_rustc: bool = ( HIDDEN ) ,
679
680
minimal_versions: bool = ( "Resolve minimal dependency versions instead of maximum" ) ,
680
681
mtime_on_use: bool = ( "Configure Cargo to update the mtime of used files" ) ,
@@ -778,6 +779,50 @@ where
778
779
parse_check_cfg ( crates. into_iter ( ) ) . map_err ( D :: Error :: custom)
779
780
}
780
781
782
+ #[ derive( Debug , Copy , Clone , Default , Serialize , Deserialize ) ]
783
+ pub struct GitoxideFeatures {
784
+ /// All featches are done with gitoxide, which includes git dependencies as well as the crates index.
785
+ pub fetch : bool ,
786
+ /// When cloning the index, perform a shallow clone. Maintain shallowness upon subsequent fetches.
787
+ pub shallow_index : bool ,
788
+ /// Checkout git dependencies using `gitoxide` (submodules are still handled by git2 ATM, and filters
789
+ /// like linefeed conversions are unsupported).
790
+ pub checkout : bool ,
791
+ }
792
+
793
+ impl GitoxideFeatures {
794
+ fn all ( ) -> Self {
795
+ GitoxideFeatures {
796
+ fetch : true ,
797
+ shallow_index : true ,
798
+ checkout : true ,
799
+ }
800
+ }
801
+ }
802
+
803
+ fn parse_gitoxide (
804
+ it : impl Iterator < Item = impl AsRef < str > > ,
805
+ ) -> CargoResult < Option < GitoxideFeatures > > {
806
+ let mut out = GitoxideFeatures :: default ( ) ;
807
+ let GitoxideFeatures {
808
+ fetch,
809
+ shallow_index,
810
+ checkout,
811
+ } = & mut out;
812
+
813
+ for e in it {
814
+ match e. as_ref ( ) {
815
+ "fetch" => * fetch = true ,
816
+ "shallow_index" => * shallow_index = true ,
817
+ "checkout" => * checkout = true ,
818
+ _ => {
819
+ bail ! ( "unstable 'gitoxide' only takes `fetch`, 'shallow_index' and 'checkout' as valid inputs" )
820
+ }
821
+ }
822
+ }
823
+ Ok ( Some ( out) )
824
+ }
825
+
781
826
fn parse_check_cfg (
782
827
it : impl Iterator < Item = impl AsRef < str > > ,
783
828
) -> CargoResult < Option < ( bool , bool , bool , bool ) > > {
@@ -928,6 +973,12 @@ impl CliUnstable {
928
973
"doctest-in-workspace" => self . doctest_in_workspace = parse_empty ( k, v) ?,
929
974
"panic-abort-tests" => self . panic_abort_tests = parse_empty ( k, v) ?,
930
975
"jobserver-per-rustc" => self . jobserver_per_rustc = parse_empty ( k, v) ?,
976
+ "gitoxide" => {
977
+ self . gitoxide = v. map_or_else (
978
+ || Ok ( Some ( GitoxideFeatures :: all ( ) ) ) ,
979
+ |v| parse_gitoxide ( v. split ( ',' ) ) ,
980
+ ) ?
981
+ }
931
982
"host-config" => self . host_config = parse_empty ( k, v) ?,
932
983
"target-applies-to-host" => self . target_applies_to_host = parse_empty ( k, v) ?,
933
984
"publish-timeout" => self . publish_timeout = parse_empty ( k, v) ?,
0 commit comments