@@ -28,7 +28,17 @@ fn entry_by_path_with_conflicting_file() {
28
28
file. entry_by_path( "file" . into( ) ) . expect( "found" ) . stage( ) ,
29
29
2 ,
30
30
"we always find our stage while in a merge"
31
- )
31
+ ) ;
32
+ assert_eq ! (
33
+ file. prefixed_entries( "fil" . into( ) ) . expect( "present" ) ,
34
+ file. entries( ) ,
35
+ "it's possible to get the entire range"
36
+ ) ;
37
+ assert_eq ! (
38
+ file. prefixed_entries( "" . into( ) ) . expect( "present" ) ,
39
+ file. entries( ) ,
40
+ "empty prefix matches all"
41
+ ) ;
32
42
}
33
43
34
44
#[ test]
@@ -65,4 +75,31 @@ fn sort_entries() {
65
75
new_entry_path,
66
76
"we can find the correct entry now"
67
77
) ;
78
+
79
+ check_prefix ( & file, "a" , & [ "a" , "an initially incorrectly ordered entry" ] ) ;
80
+ check_prefix (
81
+ & file,
82
+ "d" ,
83
+ & [ "d/a" , "d/b" , "d/c" , "d/last/123" , "d/last/34" , "d/last/6" ] ,
84
+ ) ;
85
+ check_prefix (
86
+ & file,
87
+ "d/" ,
88
+ & [ "d/a" , "d/b" , "d/c" , "d/last/123" , "d/last/34" , "d/last/6" ] ,
89
+ ) ;
90
+ check_prefix ( & file, "d/last" , & [ "d/last/123" , "d/last/34" , "d/last/6" ] ) ;
91
+ check_prefix ( & file, "d/las" , & [ "d/last/123" , "d/last/34" , "d/last/6" ] ) ;
92
+ check_prefix ( & file, "x" , & [ "x" ] ) ;
93
+ }
94
+
95
+ fn check_prefix ( index : & gix_index:: State , prefix : & str , expected : & [ & str ] ) {
96
+ assert_eq ! (
97
+ index
98
+ . prefixed_entries( prefix. into( ) )
99
+ . expect( "present" )
100
+ . iter( )
101
+ . map( |e| e. path( index) )
102
+ . collect:: <Vec <_>>( ) ,
103
+ expected
104
+ ) ;
68
105
}
0 commit comments