@@ -675,6 +675,7 @@ unstable_cli_options!(
675675    doctest_xcompile:  bool  = ( "Compile and run doctests for non-host target using runner config" ) , 
676676    dual_proc_macros:  bool  = ( "Build proc-macros for both the host and the target" ) , 
677677    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" ) , 
678679    jobserver_per_rustc:  bool  = ( HIDDEN ) , 
679680    minimal_versions:  bool  = ( "Resolve minimal dependency versions instead of maximum" ) , 
680681    mtime_on_use:  bool  = ( "Configure Cargo to update the mtime of used files" ) , 
@@ -778,6 +779,55 @@ where
778779    parse_check_cfg ( crates. into_iter ( ) ) . map_err ( D :: Error :: custom) 
779780} 
780781
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+     /// When cloning git dependencies, perform a shallow clone and maintain shallowness on subsequent fetches. 
789+      pub  shallow_deps :  bool , 
790+     /// Checkout git dependencies using `gitoxide` (submodules are still handled by git2 ATM, and filters 
791+      /// like linefeed conversions are unsupported). 
792+      pub  checkout :  bool , 
793+ } 
794+ 
795+ impl  GitoxideFeatures  { 
796+     fn  all ( )  -> Self  { 
797+         GitoxideFeatures  { 
798+             fetch :  true , 
799+             shallow_index :  true , 
800+             checkout :  true , 
801+             shallow_deps :  true , 
802+         } 
803+     } 
804+ } 
805+ 
806+ fn  parse_gitoxide ( 
807+     it :  impl  Iterator < Item  = impl  AsRef < str > > , 
808+ )  -> CargoResult < Option < GitoxideFeatures > >  { 
809+     let  mut  out = GitoxideFeatures :: default ( ) ; 
810+     let  GitoxideFeatures  { 
811+         fetch, 
812+         shallow_index, 
813+         checkout, 
814+         shallow_deps, 
815+     }  = & mut  out; 
816+ 
817+     for  e in  it { 
818+         match  e. as_ref ( )  { 
819+             "fetch"  => * fetch = true , 
820+             "shallow_index"  => * shallow_index = true , 
821+             "shallow_deps"  => * shallow_deps = true , 
822+             "checkout"  => * checkout = true , 
823+             _ => { 
824+                 bail ! ( "unstable 'gitoxide' only takes `fetch`, 'shallow_index', 'shallow_deps' and 'checkout' as valid inputs" ) 
825+             } 
826+         } 
827+     } 
828+     Ok ( Some ( out) ) 
829+ } 
830+ 
781831fn  parse_check_cfg ( 
782832    it :  impl  Iterator < Item  = impl  AsRef < str > > , 
783833)  -> CargoResult < Option < ( bool ,  bool ,  bool ,  bool ) > >  { 
@@ -928,6 +978,12 @@ impl CliUnstable {
928978            "doctest-in-workspace"  => self . doctest_in_workspace  = parse_empty ( k,  v) ?, 
929979            "panic-abort-tests"  => self . panic_abort_tests  = parse_empty ( k,  v) ?, 
930980            "jobserver-per-rustc"  => self . jobserver_per_rustc  = parse_empty ( k,  v) ?, 
981+             "gitoxide"  => { 
982+                 self . gitoxide  = v. map_or_else ( 
983+                     || Ok ( Some ( GitoxideFeatures :: all ( ) ) ) , 
984+                     |v| parse_gitoxide ( v. split ( ',' ) ) , 
985+                 ) ?
986+             } 
931987            "host-config"  => self . host_config  = parse_empty ( k,  v) ?, 
932988            "target-applies-to-host"  => self . target_applies_to_host  = parse_empty ( k,  v) ?, 
933989            "publish-timeout"  => self . publish_timeout  = parse_empty ( k,  v) ?, 
0 commit comments