File tree Expand file tree Collapse file tree 3 files changed +22
-6
lines changed Expand file tree Collapse file tree 3 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ impl Capabilities {
5555 }
5656
5757 #[ cfg( not( unix) ) ]
58- fn probe_file_mode ( root : & Path ) -> std:: io:: Result < bool > {
58+ fn probe_file_mode ( _root : & Path ) -> std:: io:: Result < bool > {
5959 Ok ( false )
6060 }
6161
Original file line number Diff line number Diff line change @@ -87,6 +87,7 @@ pub fn checkout<Find>(
8787where
8888 Find : for < ' a > FnMut ( & oid , & ' a mut Vec < u8 > ) -> Option < git_object:: BlobRef < ' a > > ,
8989{
90+ use std:: io:: ErrorKind :: AlreadyExists ;
9091 let root = path. as_ref ( ) ;
9192 let mut buf = Vec :: new ( ) ;
9293 let mut collisions = Vec :: new ( ) ;
@@ -100,9 +101,17 @@ where
100101 match res {
101102 Ok ( ( ) ) => { }
102103 // TODO: use ::IsDirectory as well when stabilized instead of raw_os_error()
104+ #[ cfg( windows) ]
103105 Err ( index:: checkout:: Error :: Io ( err) )
104- if err. kind ( ) == std :: io :: ErrorKind :: AlreadyExists || err. raw_os_error ( ) == Some ( 21 ) =>
106+ if err. kind ( ) == AlreadyExists || err. kind ( ) == std :: io :: ErrorKind :: PermissionDenied =>
105107 {
108+ collisions. push ( Collision {
109+ path : entry_path. into ( ) ,
110+ error_kind : err. kind ( ) ,
111+ } ) ;
112+ }
113+ #[ cfg( not( windows) ) ]
114+ Err ( index:: checkout:: Error :: Io ( err) ) if err. kind ( ) == AlreadyExists || err. raw_os_error ( ) == Some ( 21 ) => {
106115 // We are here because a file existed or was blocked by a directory which shouldn't be possible unless
107116 // we are on a file insensitive file system.
108117 collisions. push ( Collision {
@@ -136,6 +145,7 @@ pub(crate) mod entry {
136145
137146 use crate :: index;
138147
148+ #[ cfg_attr( not( unix) , allow( unused_variables) ) ]
139149 pub fn checkout < Find > (
140150 entry : & mut Entry ,
141151 entry_path : & BStr ,
Original file line number Diff line number Diff line change @@ -84,24 +84,30 @@ mod checkout {
8484 let ( source_tree, destination, _index, outcome) =
8585 checkout_index_in_tmp_dir ( opts, "make_ignorecase_collisions" ) . unwrap ( ) ;
8686
87+ let error_kind = ErrorKind :: AlreadyExists ;
88+ #[ cfg( windows) ]
89+ let error_kind_dir = ErrorKind :: PermissionDenied ;
90+ #[ cfg( not( windows) ) ]
91+ let error_kind_dir = error_kind;
92+
8793 assert_eq ! (
8894 outcome. collisions,
8995 vec![
9096 Collision {
9197 path: "FILE_x" . into( ) ,
92- error_kind: ErrorKind :: AlreadyExists ,
98+ error_kind,
9399 } ,
94100 Collision {
95101 path: "d" . into( ) ,
96- error_kind: ErrorKind :: AlreadyExists ,
102+ error_kind: error_kind_dir ,
97103 } ,
98104 Collision {
99105 path: "file_X" . into( ) ,
100- error_kind: ErrorKind :: AlreadyExists ,
106+ error_kind,
101107 } ,
102108 Collision {
103109 path: "file_x" . into( ) ,
104- error_kind: ErrorKind :: AlreadyExists ,
110+ error_kind,
105111 } ,
106112 ] ,
107113 "these files couldn't be checked out"
You can’t perform that action at this time.
0 commit comments