@@ -114,7 +114,6 @@ fn sort_entries() {
114
114
"we can find the correct entry now"
115
115
) ;
116
116
117
- check_prefix ( & file, "a" , & [ "a" , "an initially incorrectly ordered entry" ] ) ;
118
117
check_prefix (
119
118
& file,
120
119
"d" ,
@@ -126,18 +125,44 @@ fn sort_entries() {
126
125
& [ "d/a" , "d/b" , "d/c" , "d/last/123" , "d/last/34" , "d/last/6" ] ,
127
126
) ;
128
127
check_prefix ( & file, "d/last" , & [ "d/last/123" , "d/last/34" , "d/last/6" ] ) ;
128
+ check_prefix ( & file, "d/last/" , & [ "d/last/123" , "d/last/34" , "d/last/6" ] ) ;
129
129
check_prefix ( & file, "d/las" , & [ "d/last/123" , "d/last/34" , "d/last/6" ] ) ;
130
+ check_prefix ( & file, "d/last/123" , & [ "d/last/123" ] ) ;
131
+ check_prefix ( & file, "d/last/34" , & [ "d/last/34" ] ) ;
132
+ check_prefix ( & file, "d/last/6" , & [ "d/last/6" ] ) ;
133
+ check_prefix ( & file, "x" , & [ "x" ] ) ;
134
+ check_prefix ( & file, "a" , & [ "a" , "an initially incorrectly ordered entry" ] ) ;
135
+ }
136
+
137
+ #[ test]
138
+ fn prefixed_entries ( ) {
139
+ let mut file = Fixture :: Generated ( "v4_more_files_IEOT" ) . open ( ) ;
140
+ let entry = file. entry ( 0 ) . clone ( ) ;
141
+ let new_entry_path = "an initially incorrectly ordered entry" . into ( ) ;
142
+ file. dangerously_push_entry ( entry. stat , entry. id , entry. flags , entry. mode , new_entry_path) ;
143
+ file. sort_entries ( ) ;
144
+
145
+ check_prefix ( & file, "a" , & [ "a" , "an initially incorrectly ordered entry" ] ) ;
146
+ check_prefix ( & file, "an" , & [ "an initially incorrectly ordered entry" ] ) ;
147
+ check_prefix (
148
+ & file,
149
+ "an initially incorrectly ordered entry" ,
150
+ & [ "an initially incorrectly ordered entry" ] ,
151
+ ) ;
130
152
check_prefix ( & file, "x" , & [ "x" ] ) ;
153
+ check_prefix ( & file, "b" , & [ "b" ] ) ;
154
+ check_prefix ( & file, "c" , & [ "c" ] ) ;
131
155
}
132
156
133
157
fn check_prefix ( index : & gix_index:: State , prefix : & str , expected : & [ & str ] ) {
134
158
assert_eq ! (
135
159
index
136
160
. prefixed_entries( prefix. into( ) )
137
- . expect ( "present" )
161
+ . unwrap_or_else ( || panic! ( "{prefix:?} must match at least one entry" ) )
138
162
. iter( )
139
163
. map( |e| e. path( index) )
140
164
. collect:: <Vec <_>>( ) ,
141
- expected
165
+ expected,
166
+ "{prefix:?}"
142
167
) ;
143
168
}
0 commit comments