@@ -944,6 +944,9 @@ pub fn fetch(
944944
945945 let shallow = remote_kind. to_shallow_setting ( repo. is_shallow ( ) , gctx) ;
946946
947+ // Flag to keep track if the rev is a full commit hash
948+ let mut fast_path_rev: bool = false ;
949+
947950 let oid_to_fetch = match github_fast_path ( repo, remote_url, reference, gctx) {
948951 Ok ( FastPathRev :: UpToDate ) => return Ok ( ( ) ) ,
949952 Ok ( FastPathRev :: NeedsFetch ( rev) ) => Some ( rev) ,
@@ -984,6 +987,7 @@ pub fn fetch(
984987 if rev. starts_with ( "refs/" ) {
985988 refspecs. push ( format ! ( "+{0}:{0}" , rev) ) ;
986989 } else if let Some ( oid_to_fetch) = oid_to_fetch {
990+ fast_path_rev = true ;
987991 refspecs. push ( format ! ( "+{0}:refs/commit/{0}" , oid_to_fetch) ) ;
988992 } else if !matches ! ( shallow, gix:: remote:: fetch:: Shallow :: NoChange )
989993 && rev. parse :: < Oid > ( ) . is_ok ( )
@@ -1006,13 +1010,20 @@ pub fn fetch(
10061010 }
10071011 }
10081012
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 {
10101014 fetch_with_cli ( repo, remote_url, & refspecs, tags, gctx)
10111015 } else if gctx. cli_unstable ( ) . gitoxide . map_or ( false , |git| git. fetch ) {
10121016 fetch_with_gitoxide ( repo, remote_url, refspecs, tags, shallow, gctx)
10131017 } else {
10141018 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+ }
10151025 }
1026+ result
10161027}
10171028
10181029/// `gitoxide` uses shallow locks to assure consistency when fetching to and to avoid races, and to write
0 commit comments