File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -600,10 +600,10 @@ impl Index {
600
600
/// Find the first position of any entries matching a prefix.
601
601
///
602
602
/// To find the first position of a path inside a given folder, suffix the prefix with a '/'.
603
- pub fn find_prefix ( & self , path : & Path ) -> Result < Option < usize > , Error > {
603
+ pub fn find_prefix < T : IntoCString > ( & self , prefix : T ) -> Result < Option < usize > , Error > {
604
604
unsafe {
605
605
let mut at_pos: size_t = 0 ;
606
- let entry_path = path . into_c_string ( ) ?;
606
+ let entry_path = prefix . into_c_string ( ) ?;
607
607
let result = call ! ( raw:: git_index_find_prefix(
608
608
& mut at_pos,
609
609
self . raw,
@@ -883,12 +883,15 @@ mod tests {
883
883
let mut e = entry ( ) ;
884
884
e. path = b"foo/bar" . to_vec ( ) ;
885
885
index. add ( & e) . unwrap ( ) ;
886
+ let mut e = entry ( ) ;
887
+ e. path = b"foo2/bar" . to_vec ( ) ;
888
+ index. add ( & e) . unwrap ( ) ;
886
889
assert_eq ! ( index. get( 0 ) . unwrap( ) . path, b"foo/bar" ) ;
887
890
assert_eq ! (
888
891
index. get_path( Path :: new( "foo/bar" ) , 0 ) . unwrap( ) . path,
889
892
b"foo/bar"
890
893
) ;
891
- assert_eq ! ( index. find_prefix( Path :: new( "foo /" ) ) . unwrap( ) , Some ( 0 ) ) ;
894
+ assert_eq ! ( index. find_prefix( Path :: new( "foo2 /" ) ) . unwrap( ) , Some ( 1 ) ) ;
892
895
assert_eq ! ( index. find_prefix( Path :: new( "empty/" ) ) . unwrap( ) , None ) ;
893
896
}
894
897
You can’t perform that action at this time.
0 commit comments