File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -2827,6 +2827,12 @@ extern "C" {
28272827 repo : * mut git_repository ,
28282828 id : * const git_oid ,
28292829 ) -> 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 ;
28302836 pub fn git_commit_message ( commit : * const git_commit ) -> * const c_char ;
28312837 pub fn git_commit_message_encoding ( commit : * const git_commit ) -> * const c_char ;
28322838 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 {
14181418 }
14191419 }
14201420
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+
14211435 /// Creates an `AnnotatedCommit` from the given commit id.
14221436 pub fn find_annotated_commit ( & self , id : Oid ) -> Result < AnnotatedCommit < ' _ > , Error > {
14231437 unsafe {
You can’t perform that action at this time.
0 commit comments