File tree 2 files changed +20
-0
lines changed
2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -2827,6 +2827,12 @@ extern "C" {
2827
2827
repo : * mut git_repository ,
2828
2828
id : * const git_oid ,
2829
2829
) -> c_int ;
2830
+ pub fn git_commit_lookup_prefix (
2831
+ commit : * mut * mut git_commit ,
2832
+ repo : * mut git_repository ,
2833
+ id : * const git_oid ,
2834
+ len : size_t ,
2835
+ ) -> c_int ;
2830
2836
pub fn git_commit_message ( commit : * const git_commit ) -> * const c_char ;
2831
2837
pub fn git_commit_message_encoding ( commit : * const git_commit ) -> * const c_char ;
2832
2838
pub fn git_commit_message_raw ( commit : * const git_commit ) -> * const c_char ;
Original file line number Diff line number Diff line change @@ -1418,6 +1418,20 @@ impl Repository {
1418
1418
}
1419
1419
}
1420
1420
1421
+ /// Lookup a reference to one of the commits in a repository by short hash.
1422
+ pub fn find_commit_by_prefix ( & self , prefix_hash : & str ) -> Result < Commit < ' _ > , Error > {
1423
+ let mut raw = ptr:: null_mut ( ) ;
1424
+ unsafe {
1425
+ try_call ! ( raw:: git_commit_lookup_prefix(
1426
+ & mut raw,
1427
+ self . raw( ) ,
1428
+ Oid :: from_str( prefix_hash) ?. raw( ) ,
1429
+ prefix_hash. len( )
1430
+ ) ) ;
1431
+ Ok ( Binding :: from_raw ( raw) )
1432
+ }
1433
+ }
1434
+
1421
1435
/// Creates an `AnnotatedCommit` from the given commit id.
1422
1436
pub fn find_annotated_commit ( & self , id : Oid ) -> Result < AnnotatedCommit < ' _ > , Error > {
1423
1437
unsafe {
You can’t perform that action at this time.
0 commit comments