File tree 3 files changed +22
-6
lines changed 3 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ impl Capabilities {
55
55
}
56
56
57
57
#[ 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 > {
59
59
Ok ( false )
60
60
}
61
61
Original file line number Diff line number Diff line change @@ -87,6 +87,7 @@ pub fn checkout<Find>(
87
87
where
88
88
Find : for < ' a > FnMut ( & oid , & ' a mut Vec < u8 > ) -> Option < git_object:: BlobRef < ' a > > ,
89
89
{
90
+ use std:: io:: ErrorKind :: AlreadyExists ;
90
91
let root = path. as_ref ( ) ;
91
92
let mut buf = Vec :: new ( ) ;
92
93
let mut collisions = Vec :: new ( ) ;
@@ -100,9 +101,17 @@ where
100
101
match res {
101
102
Ok ( ( ) ) => { }
102
103
// TODO: use ::IsDirectory as well when stabilized instead of raw_os_error()
104
+ #[ cfg( windows) ]
103
105
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 =>
105
107
{
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 ) => {
106
115
// We are here because a file existed or was blocked by a directory which shouldn't be possible unless
107
116
// we are on a file insensitive file system.
108
117
collisions. push ( Collision {
@@ -136,6 +145,7 @@ pub(crate) mod entry {
136
145
137
146
use crate :: index;
138
147
148
+ #[ cfg_attr( not( unix) , allow( unused_variables) ) ]
139
149
pub fn checkout < Find > (
140
150
entry : & mut Entry ,
141
151
entry_path : & BStr ,
Original file line number Diff line number Diff line change @@ -84,24 +84,30 @@ mod checkout {
84
84
let ( source_tree, destination, _index, outcome) =
85
85
checkout_index_in_tmp_dir ( opts, "make_ignorecase_collisions" ) . unwrap ( ) ;
86
86
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
+
87
93
assert_eq ! (
88
94
outcome. collisions,
89
95
vec![
90
96
Collision {
91
97
path: "FILE_x" . into( ) ,
92
- error_kind: ErrorKind :: AlreadyExists ,
98
+ error_kind,
93
99
} ,
94
100
Collision {
95
101
path: "d" . into( ) ,
96
- error_kind: ErrorKind :: AlreadyExists ,
102
+ error_kind: error_kind_dir ,
97
103
} ,
98
104
Collision {
99
105
path: "file_X" . into( ) ,
100
- error_kind: ErrorKind :: AlreadyExists ,
106
+ error_kind,
101
107
} ,
102
108
Collision {
103
109
path: "file_x" . into( ) ,
104
- error_kind: ErrorKind :: AlreadyExists ,
110
+ error_kind,
105
111
} ,
106
112
] ,
107
113
"these files couldn't be checked out"
You can’t perform that action at this time.
0 commit comments