@@ -12,6 +12,8 @@ use crate::{
12
12
BStr , FullName , Namespace , Reference ,
13
13
} ;
14
14
15
+ use gix_path:: relative_path:: RelativePath ;
16
+
15
17
/// An iterator stepping through sorted input of loose references and packed references, preferring loose refs over otherwise
16
18
/// equivalent packed references.
17
19
///
@@ -204,9 +206,9 @@ impl Platform<'_> {
204
206
///
205
207
/// Prefixes are relative paths with slash-separated components.
206
208
// TODO: use `RelativePath` type instead (see #1921), or a trait that helps convert into it.
207
- pub fn prefixed < ' a > ( & self , prefix : impl Into < & ' a BStr > ) -> std:: io:: Result < LooseThenPacked < ' _ , ' _ > > {
209
+ pub fn prefixed < ' a > ( & self , prefix : & ' a RelativePath ) -> std:: io:: Result < LooseThenPacked < ' _ , ' _ > > {
208
210
self . store
209
- . iter_prefixed_packed ( prefix. into ( ) , self . packed . as_ref ( ) . map ( |b| & * * * b) )
211
+ . iter_prefixed_packed ( prefix, self . packed . as_ref ( ) . map ( |b| & * * * b) )
210
212
}
211
213
}
212
214
@@ -291,13 +293,8 @@ impl<'a> IterInfo<'a> {
291
293
. peekable ( )
292
294
}
293
295
294
- fn from_prefix (
295
- base : & ' a Path ,
296
- prefix : impl Into < Cow < ' a , BStr > > ,
297
- precompose_unicode : bool ,
298
- ) -> std:: io:: Result < Self > {
299
- let prefix = prefix. into ( ) ;
300
- let prefix_path = gix_path:: from_bstr ( prefix. as_ref ( ) ) ;
296
+ fn from_prefix ( base : & ' a Path , prefix : & ' a RelativePath , precompose_unicode : bool ) -> std:: io:: Result < Self > {
297
+ let prefix_path = gix_path:: from_bstr ( prefix) ;
301
298
if prefix_path. is_absolute ( ) {
302
299
return Err ( std:: io:: Error :: new (
303
300
std:: io:: ErrorKind :: InvalidInput ,
@@ -326,7 +323,7 @@ impl<'a> IterInfo<'a> {
326
323
. to_owned ( ) ;
327
324
Ok ( IterInfo :: ComputedIterationRoot {
328
325
base,
329
- prefix,
326
+ prefix : prefix . into ( ) ,
330
327
iter_root,
331
328
precompose_unicode,
332
329
} )
@@ -380,7 +377,7 @@ impl file::Store {
380
377
// TODO: use `RelativePath` type instead (see #1921), or a trait that helps convert into it.
381
378
pub fn iter_prefixed_packed < ' a , ' s , ' p > (
382
379
& ' s self ,
383
- prefix : impl Into < & ' a BStr > ,
380
+ prefix : & ' a RelativePath ,
384
381
packed : Option < & ' p packed:: Buffer > ,
385
382
) -> std:: io:: Result < LooseThenPacked < ' p , ' s > > {
386
383
let prefix = prefix. into ( ) ;
@@ -394,8 +391,12 @@ impl file::Store {
394
391
self . iter_from_info ( git_dir_info, common_dir_info, packed)
395
392
}
396
393
Some ( namespace) => {
397
- let prefix = namespace. to_owned ( ) . into_namespaced_prefix ( prefix) ;
398
- let git_dir_info = IterInfo :: from_prefix ( self . git_dir ( ) , prefix. clone ( ) , self . precompose_unicode ) ?;
394
+ let prefix = namespace
395
+ . to_owned ( )
396
+ . into_namespaced_prefix ( prefix)
397
+ . try_into ( )
398
+ . expect ( "TODO" ) ;
399
+ let git_dir_info = IterInfo :: from_prefix ( self . git_dir ( ) , prefix, self . precompose_unicode ) ?;
399
400
let common_dir_info = self
400
401
. common_dir ( )
401
402
. map ( |base| IterInfo :: from_prefix ( base, prefix, self . precompose_unicode ) )
0 commit comments