File tree 2 files changed +19
-5
lines changed
2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change 1
1
use git_hash:: oid;
2
+ use std:: io:: ErrorKind :: AlreadyExists ;
2
3
3
4
use crate :: { index, index:: checkout:: Collision } ;
4
5
@@ -87,6 +88,7 @@ pub fn checkout<Find>(
87
88
where
88
89
Find : for < ' a > FnMut ( & oid , & ' a mut Vec < u8 > ) -> Option < git_object:: BlobRef < ' a > > ,
89
90
{
91
+ use std:: io:: ErrorKind :: AlreadyExists ;
90
92
let root = path. as_ref ( ) ;
91
93
let mut buf = Vec :: new ( ) ;
92
94
let mut collisions = Vec :: new ( ) ;
@@ -100,9 +102,17 @@ where
100
102
match res {
101
103
Ok ( ( ) ) => { }
102
104
// TODO: use ::IsDirectory as well when stabilized instead of raw_os_error()
105
+ #[ cfg( windows) ]
103
106
Err ( index:: checkout:: Error :: Io ( err) )
104
- if err. kind ( ) == std :: io :: ErrorKind :: AlreadyExists || err. raw_os_error ( ) == Some ( 21 ) =>
107
+ if err. kind ( ) == AlreadyExists || err. kind ( ) == std :: io :: ErrorKind :: PermissionDenied =>
105
108
{
109
+ collisions. push ( Collision {
110
+ path : entry_path. into ( ) ,
111
+ error_kind : err. kind ( ) ,
112
+ } ) ;
113
+ }
114
+ #[ cfg( not( windows) ) ]
115
+ Err ( index:: checkout:: Error :: Io ( err) ) if err. kind ( ) == AlreadyExists || err. raw_os_error ( ) == Some ( 21 ) => {
106
116
// We are here because a file existed or was blocked by a directory which shouldn't be possible unless
107
117
// we are on a file insensitive file system.
108
118
collisions. push ( Collision {
Original file line number Diff line number Diff line change @@ -83,25 +83,29 @@ mod checkout {
83
83
let opts = opts_with_symlink ( true ) ;
84
84
let ( source_tree, destination, _index, outcome) =
85
85
checkout_index_in_tmp_dir ( opts, "make_ignorecase_collisions" ) . unwrap ( ) ;
86
+ #[ cfg( windows) ]
87
+ let error_kind = ErrorKind :: PermissionDenied ;
88
+ #[ cfg( not( windows) ) ]
89
+ let error_kind = ErrorKind :: AlreadyExists ;
86
90
87
91
assert_eq ! (
88
92
outcome. collisions,
89
93
vec![
90
94
Collision {
91
95
path: "FILE_x" . into( ) ,
92
- error_kind: ErrorKind :: AlreadyExists ,
96
+ error_kind,
93
97
} ,
94
98
Collision {
95
99
path: "d" . into( ) ,
96
- error_kind: ErrorKind :: AlreadyExists ,
100
+ error_kind,
97
101
} ,
98
102
Collision {
99
103
path: "file_X" . into( ) ,
100
- error_kind: ErrorKind :: AlreadyExists ,
104
+ error_kind,
101
105
} ,
102
106
Collision {
103
107
path: "file_x" . into( ) ,
104
- error_kind: ErrorKind :: AlreadyExists ,
108
+ error_kind,
105
109
} ,
106
110
] ,
107
111
"these files couldn't be checked out"
You can’t perform that action at this time.
0 commit comments