File tree 1 file changed +14
-1
lines changed
1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -2044,7 +2044,13 @@ impl Repository {
2044
2044
2045
2045
/// Test if the ignore rules apply to a given path.
2046
2046
pub fn is_path_ignored < P : AsRef < Path > > ( & self , path : P ) -> Result < bool , Error > {
2047
- let path = try!( path. as_ref ( ) . into_c_string ( ) ) ;
2047
+ let path = if cfg ! ( windows) {
2048
+ // `git_ignore_path_is_ignored` dose not work with windows path separator
2049
+ // so we convert \ to /
2050
+ try!( :: std:: ffi:: CString :: new ( path. as_ref ( ) . to_string_lossy ( ) . replace ( '\\' , "/" ) ) )
2051
+ } else {
2052
+ try!( path. as_ref ( ) . into_c_string ( ) )
2053
+ } ;
2048
2054
let mut ignored: c_int = 0 ;
2049
2055
unsafe {
2050
2056
try_call ! ( raw:: git_ignore_path_is_ignored( & mut ignored, self . raw, path) ) ;
@@ -2536,8 +2542,15 @@ mod tests {
2536
2542
2537
2543
let _ = repo. add_ignore_rule ( "/foo" ) ;
2538
2544
assert ! ( repo. is_path_ignored( Path :: new( "/foo" ) ) . unwrap( ) ) ;
2545
+ if cfg ! ( windows) {
2546
+ assert ! ( repo. is_path_ignored( Path :: new( "\\ foo\\ thing" ) ) . unwrap( ) ) ;
2547
+ }
2548
+
2539
2549
2540
2550
let _ = repo. clear_ignore_rules ( ) ;
2541
2551
assert ! ( !repo. is_path_ignored( Path :: new( "/foo" ) ) . unwrap( ) ) ;
2552
+ if cfg ! ( windows) {
2553
+ assert ! ( !repo. is_path_ignored( Path :: new( "\\ foo\\ thing" ) ) . unwrap( ) ) ;
2554
+ }
2542
2555
}
2543
2556
}
You can’t perform that action at this time.
0 commit comments