@@ -45,6 +45,30 @@ static int rugged_refdb_backend_custom__exists(
4545 return GIT_OK ;
4646}
4747
48+ static int rugged_refdb_backend_custom__lookup (
49+ git_reference * * out ,
50+ git_refdb_backend * _backend ,
51+ const char * ref_name )
52+ {
53+ rugged_refdb_backend_custom * backend = (rugged_refdb_backend_custom * )_backend ;
54+ git_oid oid ;
55+ VALUE rb_result ;
56+
57+ // TODO: Proper exception handling
58+ rb_result = rb_funcall (backend -> self , rb_intern ("lookup" ), 1 , rb_str_new2 (ref_name ));
59+ if (TYPE (rb_result ) == T_STRING ) {
60+ // TODO: Handle symbolic refs as well
61+ // TODO: Proper exception handling
62+ rugged_exception_check (git_oid_fromstr (& oid , StringValueCStr (rb_result )));
63+ * out = git_reference__alloc (ref_name , & oid , NULL );
64+ return GIT_OK ;
65+ } else {
66+ // TODO: Better error handling
67+ * out = NULL ;
68+ return GIT_ENOTFOUND ;
69+ }
70+ }
71+
4872static int rugged_refdb_backend_custom__compress (git_refdb_backend * _backend )
4973{
5074 rugged_refdb_backend_custom * backend = (rugged_refdb_backend_custom * )_backend ;
@@ -68,6 +92,7 @@ static VALUE rb_git_refdb_backend_custom_new(VALUE self, VALUE rb_repo)
6892
6993 backend -> parent .exists = & rugged_refdb_backend_custom__exists ;
7094 backend -> parent .compress = & rugged_refdb_backend_custom__compress ;
95+ backend -> parent .lookup = & rugged_refdb_backend_custom__lookup ;
7196 backend -> parent .free = xfree ;
7297
7398 backend -> self = Data_Wrap_Struct (self , NULL , rb_git_refdb_backend__free , backend );
0 commit comments