@@ -98,14 +98,12 @@ impl GitRemote {
98
98
// populated the database with the latest version of `reference`, so
99
99
// return that database and the rev we resolve to.
100
100
if let Some ( mut db) = db {
101
- let shallow =
102
- RemoteKind :: GitDependency . to_shallow_setting ( db. repo . is_shallow ( ) , cargo_config) ;
103
101
fetch (
104
102
& mut db. repo ,
105
103
self . url . as_str ( ) ,
106
104
reference,
107
105
cargo_config,
108
- shallow ,
106
+ RemoteKind :: GitDependency ,
109
107
locked_rev,
110
108
)
111
109
. with_context ( || format ! ( "failed to fetch into: {}" , into. display( ) ) ) ?;
@@ -127,13 +125,12 @@ impl GitRemote {
127
125
}
128
126
paths:: create_dir_all ( into) ?;
129
127
let mut repo = init ( into, true ) ?;
130
- let shallow = RemoteKind :: GitDependency . to_shallow_setting ( repo. is_shallow ( ) , cargo_config) ;
131
128
fetch (
132
129
& mut repo,
133
130
self . url . as_str ( ) ,
134
131
reference,
135
132
cargo_config,
136
- shallow ,
133
+ RemoteKind :: GitDependency ,
137
134
locked_rev,
138
135
)
139
136
. with_context ( || format ! ( "failed to clone into: {}" , into. display( ) ) ) ?;
@@ -456,9 +453,15 @@ impl<'a> GitCheckout<'a> {
456
453
cargo_config
457
454
. shell ( )
458
455
. status ( "Updating" , format ! ( "git submodule `{}`" , url) ) ?;
459
- let shallow =
460
- RemoteKind :: GitDependency . to_shallow_setting ( repo. is_shallow ( ) , cargo_config) ;
461
- fetch ( & mut repo, & url, & reference, cargo_config, shallow, None ) . with_context ( || {
456
+ fetch (
457
+ & mut repo,
458
+ & url,
459
+ & reference,
460
+ cargo_config,
461
+ RemoteKind :: GitDependency ,
462
+ None ,
463
+ )
464
+ . with_context ( || {
462
465
format ! (
463
466
"failed to fetch submodule `{}` from {}" ,
464
467
child. name( ) . unwrap_or( "" ) ,
@@ -837,7 +840,7 @@ pub fn fetch(
837
840
orig_url : & str ,
838
841
reference : & GitReference ,
839
842
config : & Config ,
840
- shallow : gix :: remote :: fetch :: Shallow ,
843
+ remote_kind : RemoteKind ,
841
844
locked_rev : Option < git2:: Oid > ,
842
845
) -> CargoResult < ( ) > {
843
846
if config. frozen ( ) {
@@ -850,6 +853,9 @@ pub fn fetch(
850
853
anyhow:: bail!( "can't update a git repository in the offline mode" )
851
854
}
852
855
856
+ let shallow = remote_kind. to_shallow_setting ( repo. is_shallow ( ) , config) ;
857
+ let is_shallow = !matches ! ( shallow, gix:: remote:: fetch:: Shallow :: NoChange ) ;
858
+
853
859
// If we're fetching from GitHub, attempt GitHub's special fast path for
854
860
// testing if we've already got an up-to-date copy of the repository.
855
861
let is_shallow = !matches ! ( shallow, gix:: remote:: fetch:: Shallow :: NoChange ) ;
@@ -878,9 +884,7 @@ pub fn fetch(
878
884
// The `+` symbol on the refspec means to allow a forced (fast-forward)
879
885
// update which is needed if there is ever a force push that requires a
880
886
// fast-forward.
881
- if let Some ( rev) =
882
- locked_rev. filter ( |_| !matches ! ( shallow, gix:: remote:: fetch:: Shallow :: NoChange ) )
883
- {
887
+ if let Some ( rev) = locked_rev. filter ( |_| is_shallow) {
884
888
// If we want a specific revision and know about, obtain that specifically.
885
889
refspecs. push ( format ! ( "+{0}:refs/remotes/origin/HEAD" , rev) ) ;
886
890
} else {
0 commit comments