@@ -37,14 +37,14 @@ VALUE rb_cRuggedRefdb;
37
37
* needs to be assigned using `Refdb#backend=`.
38
38
*/
39
39
static VALUE rb_git_refdb_new (VALUE klass , VALUE rb_repo ) {
40
- git_refdb * refdb ;
41
- git_repository * repo ;
40
+ git_refdb * refdb ;
41
+ git_repository * repo ;
42
42
43
- Data_Get_Struct (rb_repo , git_repository , repo );
43
+ Data_Get_Struct (rb_repo , git_repository , repo );
44
44
45
- rugged_exception_check (git_refdb_new (& refdb , repo ));
45
+ rugged_exception_check (git_refdb_new (& refdb , repo ));
46
46
47
- return Data_Wrap_Struct (klass , NULL , git_refdb_free , refdb );
47
+ return Data_Wrap_Struct (klass , NULL , git_refdb_free , refdb );
48
48
}
49
49
50
50
/*
@@ -55,14 +55,14 @@ static VALUE rb_git_refdb_new(VALUE klass, VALUE rb_repo) {
55
55
* backend.
56
56
*/
57
57
static VALUE rb_git_refdb_open (VALUE klass , VALUE rb_repo ) {
58
- git_refdb * refdb ;
59
- git_repository * repo ;
58
+ git_refdb * refdb ;
59
+ git_repository * repo ;
60
60
61
- Data_Get_Struct (rb_repo , git_repository , repo );
61
+ Data_Get_Struct (rb_repo , git_repository , repo );
62
62
63
- rugged_exception_check (git_refdb_open (& refdb , repo ));
63
+ rugged_exception_check (git_refdb_open (& refdb , repo ));
64
64
65
- return Data_Wrap_Struct (klass , NULL , git_refdb_free , refdb );
65
+ return Data_Wrap_Struct (klass , NULL , git_refdb_free , refdb );
66
66
}
67
67
68
68
/*
@@ -77,30 +77,46 @@ static VALUE rb_git_refdb_new(VALUE klass, VALUE rb_repo) {
77
77
*/
78
78
static VALUE rb_git_refdb_set_backend (VALUE self , VALUE rb_backend )
79
79
{
80
- git_refdb * refdb ;
81
- git_refdb_backend * backend ;
80
+ git_refdb * refdb ;
81
+ git_refdb_backend * backend ;
82
82
83
- Data_Get_Struct (self , git_refdb , refdb );
84
- Data_Get_Struct (rb_backend , git_refdb_backend , backend );
83
+ Data_Get_Struct (self , git_refdb , refdb );
84
+ Data_Get_Struct (rb_backend , git_refdb_backend , backend );
85
85
86
- if (!backend )
87
- rb_exc_raise (rb_exc_new_cstr (rb_eRuntimeError , "Can not reuse refdb backend instances" ));
86
+ if (!backend )
87
+ rb_exc_raise (rb_exc_new_cstr (rb_eRuntimeError , "Can not reuse refdb backend instances" ));
88
88
89
- rugged_exception_check (git_refdb_set_backend (refdb , backend ));
89
+ rugged_exception_check (git_refdb_set_backend (refdb , backend ));
90
90
91
- // libgit2 has taken ownership of the backend, so we should make sure
92
- // we don't try to free it.
93
- ((struct RData * )rb_backend )-> data = NULL ;
91
+ // libgit2 has taken ownership of the backend, so we should make sure
92
+ // we don't try to free it.
93
+ ((struct RData * )rb_backend )-> data = NULL ;
94
94
95
- return Qnil ;
95
+ return Qnil ;
96
+ }
97
+
98
+ /*
99
+ * call-seq:
100
+ * refdb.compress -> nil
101
+ */
102
+ static VALUE rb_git_refdb_compress (VALUE self )
103
+ {
104
+ git_refdb * refdb ;
105
+
106
+ Data_Get_Struct (self , git_refdb , refdb );
107
+
108
+ rugged_exception_check (git_refdb_compress (refdb ));
109
+
110
+ return Qnil ;
96
111
}
97
112
98
113
void Init_rugged_refdb (void )
99
114
{
100
115
rb_cRuggedRefdb = rb_define_class_under (rb_mRugged , "Refdb" , rb_cObject );
101
116
102
- rb_define_singleton_method (rb_cRuggedRefdb , "new" , rb_git_refdb_new , 1 );
117
+ rb_define_singleton_method (rb_cRuggedRefdb , "new" , rb_git_refdb_new , 1 );
103
118
rb_define_singleton_method (rb_cRuggedRefdb , "open" , rb_git_refdb_open , 1 );
104
119
105
120
rb_define_method (rb_cRuggedRefdb , "backend=" , rb_git_refdb_set_backend , 1 );
121
+ rb_define_method (rb_cRuggedRefdb , "compress" , rb_git_refdb_compress , 0 );
106
122
}
0 commit comments