11//! Utilities for handling git repositories, mainly around
22//! authentication/cloning.
33
4- use crate :: core:: { GitReference , Verbosity } ;
4+ use crate :: core:: { GitReference , SourceId , Verbosity } ;
55use crate :: sources:: git:: fetch:: RemoteKind ;
66use crate :: sources:: git:: oxide;
77use crate :: sources:: git:: oxide:: cargo_config_to_gitoxide_overrides;
8+ use crate :: sources:: git:: source:: GitSource ;
9+ use crate :: sources:: source:: Source as _;
810use crate :: util:: HumanBytes ;
911use crate :: util:: errors:: { CargoResult , GitCliError } ;
1012use crate :: util:: { GlobalContext , IntoUrl , MetricsCounter , Progress , network} ;
@@ -447,7 +449,7 @@ impl<'a> GitCheckout<'a> {
447449 let target = repo. head ( ) ?. target ( ) ;
448450 Ok ( ( target, repo) )
449451 } ) ;
450- let mut repo = match head_and_repo {
452+ let repo = match head_and_repo {
451453 Ok ( ( head, repo) ) => {
452454 if child. head_id ( ) == head {
453455 return update_submodules ( & repo, gctx, & child_remote_url) ;
@@ -461,24 +463,23 @@ impl<'a> GitCheckout<'a> {
461463 }
462464 } ;
463465 // Fetch data from origin and reset to the head commit
464- let reference = GitReference :: Rev ( head. to_string ( ) ) ;
465466 gctx. shell ( )
466467 . status ( "Updating" , format ! ( "git submodule `{child_remote_url}`" ) ) ?;
467- fetch (
468- & mut repo,
469- & child_remote_url,
470- & reference,
468+ let mut source = GitSource :: new (
469+ SourceId :: from_url ( & format ! ( "git+{child_remote_url}#{head}" ) ) ?,
471470 gctx,
472- RemoteKind :: GitDependency ,
473471 )
474472 . with_context ( || {
475473 let name = child. name ( ) . unwrap_or ( "" ) ;
476474 format ! ( "failed to fetch submodule `{name}` from {child_remote_url}" , )
477475 } ) ?;
476+ source. set_quiet ( true ) ;
477+
478+ let ( db, actual_rev) = source. update_db ( ) ?;
479+ db. copy_to ( actual_rev, & repo. path ( ) , gctx) ?;
478480
479481 let obj = repo. find_object ( head, None ) ?;
480- reset ( & repo, & obj, gctx) ?;
481- update_submodules ( & repo, gctx, & child_remote_url)
482+ reset ( & repo, & obj, gctx)
482483 }
483484 }
484485}
0 commit comments