File tree 2 files changed +26
-0
lines changed
2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -2205,6 +2205,13 @@ extern "C" {
2205
2205
id : * const git_oid ,
2206
2206
kind : git_object_t ,
2207
2207
) -> c_int ;
2208
+ pub fn git_object_lookup_prefix (
2209
+ dest : * mut * mut git_object ,
2210
+ repo : * mut git_repository ,
2211
+ id : * const git_oid ,
2212
+ len : size_t ,
2213
+ kind : git_object_t ,
2214
+ ) -> c_int ;
2208
2215
pub fn git_object_type ( obj : * const git_object ) -> git_object_t ;
2209
2216
pub fn git_object_peel (
2210
2217
peeled : * mut * mut git_object ,
Original file line number Diff line number Diff line change @@ -1459,6 +1459,25 @@ impl Repository {
1459
1459
}
1460
1460
}
1461
1461
1462
+ /// Lookup a reference to one of the objects by id prefix in a repository.
1463
+ pub fn find_object_by_prefix (
1464
+ & self ,
1465
+ prefix_hash : & str ,
1466
+ kind : Option < ObjectType > ,
1467
+ ) -> Result < Object < ' _ > , Error > {
1468
+ let mut raw = ptr:: null_mut ( ) ;
1469
+ unsafe {
1470
+ try_call ! ( raw:: git_object_lookup_prefix(
1471
+ & mut raw,
1472
+ self . raw( ) ,
1473
+ Oid :: from_str( prefix_hash) ?. raw( ) ,
1474
+ prefix_hash. len( ) ,
1475
+ kind
1476
+ ) ) ;
1477
+ Ok ( Binding :: from_raw ( raw) )
1478
+ }
1479
+ }
1480
+
1462
1481
/// Create a new direct reference.
1463
1482
///
1464
1483
/// This function will return an error if a reference already exists with
You can’t perform that action at this time.
0 commit comments