@@ -3,8 +3,8 @@ pub mod from_tree {
3
3
use std:: collections:: VecDeque ;
4
4
5
5
use bstr:: { BStr , BString , ByteSlice , ByteVec } ;
6
- use gix_object:: { tree, tree:: EntryKind , FindExt } ;
7
- use gix_traverse:: tree:: { breadthfirst , visit:: Action , Visit } ;
6
+ use gix_object:: { tree, tree:: EntryKind } ;
7
+ use gix_traverse:: tree:: { depthfirst , visit:: Action , Visit } ;
8
8
9
9
use crate :: {
10
10
entry:: { Flags , Mode , Stat } ,
@@ -21,7 +21,7 @@ pub mod from_tree {
21
21
source : gix_validate:: path:: component:: Error ,
22
22
} ,
23
23
#[ error( transparent) ]
24
- Traversal ( #[ from] gix_traverse:: tree:: breadthfirst :: Error ) ,
24
+ Traversal ( #[ from] gix_traverse:: tree:: depthfirst :: Error ) ,
25
25
}
26
26
27
27
/// Initialization
@@ -58,12 +58,8 @@ pub mod from_tree {
58
58
Find : gix_object:: Find ,
59
59
{
60
60
let _span = gix_features:: trace:: coarse!( "gix_index::State::from_tree()" ) ;
61
- let mut buf = Vec :: new ( ) ;
62
- let root = objects
63
- . find_tree_iter ( tree, & mut buf)
64
- . map_err ( breadthfirst:: Error :: from) ?;
65
61
let mut delegate = CollectEntries :: new ( validate) ;
66
- match breadthfirst ( root , breadthfirst :: State :: default ( ) , & objects, & mut delegate) {
62
+ match depthfirst ( tree . to_owned ( ) , depthfirst :: State :: default ( ) , & objects, & mut delegate) {
67
63
Ok ( ( ) ) => { }
68
64
Err ( gix_traverse:: tree:: breadthfirst:: Error :: Cancelled ) => {
69
65
let ( path, err) = delegate
@@ -76,15 +72,17 @@ pub mod from_tree {
76
72
}
77
73
78
74
let CollectEntries {
79
- mut entries,
75
+ entries,
80
76
path_backing,
81
77
path : _,
82
78
path_deque : _,
83
79
validate : _,
84
- invalid_path : _ ,
80
+ invalid_path,
85
81
} = delegate;
86
82
87
- entries. sort_by ( |a, b| Entry :: cmp_filepaths ( a. path_in ( & path_backing) , b. path_in ( & path_backing) ) ) ;
83
+ if let Some ( ( path, err) ) = invalid_path {
84
+ return Err ( Error :: InvalidComponent { path, source : err } ) ;
85
+ }
88
86
89
87
Ok ( State {
90
88
object_hash : tree. kind ( ) ,
0 commit comments