File tree 2 files changed +21
-6
lines changed
2 files changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -751,7 +751,7 @@ git_enum! {
751
751
}
752
752
753
753
pub type git_treewalk_cb =
754
- Option < extern "C" fn ( * const c_char , * const git_tree_entry , * mut c_void ) -> c_int > ;
754
+ extern "C" fn ( * const c_char , * const git_tree_entry , * mut c_void ) -> c_int ;
755
755
pub type git_treebuilder_filter_cb =
756
756
Option < extern "C" fn ( * const git_tree_entry , * mut c_void ) -> c_int > ;
757
757
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ pub struct TreeIter<'tree> {
36
36
37
37
/// A binary indicator of whether a tree walk should be performed in pre-order
38
38
/// or post-order.
39
+ #[ derive( Clone , Copy ) ]
39
40
pub enum TreeWalkMode {
40
41
/// Runs the traversal in pre-order.
41
42
PreOrder = 0 ,
@@ -126,12 +127,12 @@ impl<'repo> Tree<'repo> {
126
127
let mut data = TreeWalkCbData {
127
128
callback : & mut callback,
128
129
} ;
129
- raw:: git_tree_walk (
130
+ try_call ! ( raw:: git_tree_walk(
130
131
self . raw( ) ,
131
- mode. into ( ) ,
132
- Some ( treewalk_cb :: < T > ) ,
133
- & mut data as * mut _ as * mut c_void ,
134
- ) ;
132
+ mode as raw :: git_treewalk_mode ,
133
+ treewalk_cb:: <T >,
134
+ & mut data as * mut _ as * mut c_void
135
+ ) ) ;
135
136
Ok ( ( ) )
136
137
}
137
138
}
@@ -599,4 +600,18 @@ mod tests {
599
600
. unwrap ( ) ;
600
601
assert_eq ! ( ct, 8 ) ;
601
602
}
603
+
604
+ #[ test]
605
+ fn tree_walk_error ( ) {
606
+ let ( td, repo) = crate :: test:: repo_init ( ) ;
607
+
608
+ setup_repo ( & td, & repo) ;
609
+
610
+ let head = repo. head ( ) . unwrap ( ) ;
611
+ let target = head. target ( ) . unwrap ( ) ;
612
+ let commit = repo. find_commit ( target) . unwrap ( ) ;
613
+ let tree = repo. find_tree ( commit. tree_id ( ) ) . unwrap ( ) ;
614
+ let e = tree. walk ( TreeWalkMode :: PreOrder , |_, _| -1 ) . unwrap_err ( ) ;
615
+ assert_eq ! ( e. class( ) , crate :: ErrorClass :: Callback ) ;
616
+ }
602
617
}
You can’t perform that action at this time.
0 commit comments