@@ -45,6 +45,30 @@ static int rugged_refdb_backend_custom__exists(
45
45
return GIT_OK ;
46
46
}
47
47
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
+
48
72
static int rugged_refdb_backend_custom__compress (git_refdb_backend * _backend )
49
73
{
50
74
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)
68
92
69
93
backend -> parent .exists = & rugged_refdb_backend_custom__exists ;
70
94
backend -> parent .compress = & rugged_refdb_backend_custom__compress ;
95
+ backend -> parent .lookup = & rugged_refdb_backend_custom__lookup ;
71
96
backend -> parent .free = xfree ;
72
97
73
98
backend -> self = Data_Wrap_Struct (self , NULL , rb_git_refdb_backend__free , backend );
0 commit comments