File tree Expand file tree Collapse file tree 4 files changed +14
-5
lines changed Expand file tree Collapse file tree 4 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -1240,7 +1240,7 @@ extern {
1240
1240
pub fn git_commit_time ( commit : * const git_commit ) -> git_time_t ;
1241
1241
pub fn git_commit_time_offset ( commit : * const git_commit ) -> c_int ;
1242
1242
pub fn git_commit_tree ( tree_out : * mut * mut git_tree ,
1243
- commit : * const git_commit ) -> c_uint ;
1243
+ commit : * const git_commit ) -> c_int ;
1244
1244
pub fn git_commit_tree_id ( commit : * const git_commit ) -> * const git_oid ;
1245
1245
pub fn git_commit_amend ( id : * mut git_oid ,
1246
1246
commit_to_amend : * const git_commit ,
Original file line number Diff line number Diff line change @@ -49,11 +49,20 @@ impl<'a> Commit<'a> {
49
49
50
50
/// Get the id of the tree pointed to by this commit.
51
51
///
52
- /// No attempts are made to fetch an object from the
52
+ /// No attempts are made to fetch an object from the ODB.
53
53
pub fn tree_id ( & self ) -> Oid {
54
54
unsafe { Oid :: from_raw ( raw:: git_commit_tree_id ( & * self . raw ) ) }
55
55
}
56
56
57
+ /// Get the tree pointed to by a commit.
58
+ pub fn tree ( & self ) -> Result < Tree , Error > {
59
+ let mut ret = 0 as * mut raw:: git_tree ;
60
+ unsafe {
61
+ try_call ! ( raw:: git_commit_tree( & mut ret, & * self . raw) ) ;
62
+ Ok ( Tree :: from_raw ( ret) )
63
+ }
64
+ }
65
+
57
66
/// Get access to the underlying raw pointer.
58
67
pub fn raw ( & self ) -> * mut raw:: git_commit { self . raw }
59
68
@@ -298,6 +307,7 @@ mod tests {
298
307
commit. message_encoding ( ) ;
299
308
commit. summary ( ) . unwrap ( ) ;
300
309
commit. tree_id ( ) ;
310
+ commit. tree ( ) . unwrap ( ) ;
301
311
assert_eq ! ( commit. parents( ) . count( ) , 0 ) ;
302
312
303
313
assert_eq ! ( commit. author( ) . name( ) , Some ( "name" ) ) ;
Original file line number Diff line number Diff line change @@ -783,7 +783,7 @@ impl Repository {
783
783
let mut raw = 0 as * mut raw:: git_tree ;
784
784
unsafe {
785
785
try_call ! ( raw:: git_tree_lookup( & mut raw, self . raw( ) , oid. raw( ) ) ) ;
786
- Ok ( Tree :: from_raw ( self , raw) )
786
+ Ok ( Tree :: from_raw ( raw) )
787
787
}
788
788
}
789
789
Original file line number Diff line number Diff line change @@ -30,8 +30,7 @@ impl<'repo> Tree<'repo> {
30
30
///
31
31
/// This method is unsafe as there is no guarantee that `raw` is a valid
32
32
/// pointer.
33
- pub unsafe fn from_raw ( _repo : & Repository ,
34
- raw : * mut raw:: git_tree ) -> Tree {
33
+ pub unsafe fn from_raw ( raw : * mut raw:: git_tree ) -> Tree < ' repo > {
35
34
Tree {
36
35
raw : raw,
37
36
marker1 : marker:: ContravariantLifetime ,
You can’t perform that action at this time.
0 commit comments