@@ -944,6 +944,9 @@ pub fn fetch(
944
944
945
945
let shallow = remote_kind. to_shallow_setting ( repo. is_shallow ( ) , gctx) ;
946
946
947
+ // Flag to keep track if the rev is a full commit hash
948
+ let mut fast_path_rev: bool = false ;
949
+
947
950
let oid_to_fetch = match github_fast_path ( repo, remote_url, reference, gctx) {
948
951
Ok ( FastPathRev :: UpToDate ) => return Ok ( ( ) ) ,
949
952
Ok ( FastPathRev :: NeedsFetch ( rev) ) => Some ( rev) ,
@@ -984,6 +987,7 @@ pub fn fetch(
984
987
if rev. starts_with ( "refs/" ) {
985
988
refspecs. push ( format ! ( "+{0}:{0}" , rev) ) ;
986
989
} else if let Some ( oid_to_fetch) = oid_to_fetch {
990
+ fast_path_rev = true ;
987
991
refspecs. push ( format ! ( "+{0}:refs/commit/{0}" , oid_to_fetch) ) ;
988
992
} else if !matches ! ( shallow, gix:: remote:: fetch:: Shallow :: NoChange )
989
993
&& rev. parse :: < Oid > ( ) . is_ok ( )
@@ -1006,13 +1010,20 @@ pub fn fetch(
1006
1010
}
1007
1011
}
1008
1012
1009
- if let Some ( true ) = gctx. net_config ( ) ?. git_fetch_with_cli {
1013
+ let result = if let Some ( true ) = gctx. net_config ( ) ?. git_fetch_with_cli {
1010
1014
fetch_with_cli ( repo, remote_url, & refspecs, tags, gctx)
1011
1015
} else if gctx. cli_unstable ( ) . gitoxide . map_or ( false , |git| git. fetch ) {
1012
1016
fetch_with_gitoxide ( repo, remote_url, refspecs, tags, shallow, gctx)
1013
1017
} else {
1014
1018
fetch_with_libgit2 ( repo, remote_url, refspecs, tags, shallow, gctx)
1019
+ } ;
1020
+
1021
+ if fast_path_rev {
1022
+ if let Some ( oid) = oid_to_fetch {
1023
+ return result. with_context ( || format ! ( "revision {} not found" , oid) ) ;
1024
+ }
1015
1025
}
1026
+ result
1016
1027
}
1017
1028
1018
1029
/// `gitoxide` uses shallow locks to assure consistency when fetching to and to avoid races, and to write
0 commit comments