@@ -29,7 +29,7 @@ extern VALUE rb_cRuggedRepo;
29
29
extern VALUE rb_eRuggedError ;
30
30
VALUE rb_cRuggedRemote ;
31
31
32
- #define RUGGED_REMOTE_CALLBACKS_INIT {1, progress_cb , NULL, credentials_cb, certificate_check_cb, transfer_progress_cb, update_tips_cb , NULL, NULL, push_update_reference_cb, NULL}
32
+ #define RUGGED_REMOTE_CALLBACKS_INIT {1, NULL , NULL, NULL, NULL, NULL, NULL , NULL, NULL, push_update_reference_cb, NULL}
33
33
34
34
static int progress_cb (const char * str , int len , void * data )
35
35
{
@@ -184,6 +184,27 @@ static int credentials_cb(
184
184
rb_raise(rb_eArgError, "Expected a Proc or an object that responds to #call (:" name " )."); \
185
185
} while (0);
186
186
187
+ static void setup_callbacks (git_remote_callbacks * callbacks , VALUE rb_options )
188
+ {
189
+ if (NIL_P (rb_options ))
190
+ return ;
191
+
192
+ if (!NIL_P (rb_hash_aref (rb_options , CSTR2SYM ("progress" ))))
193
+ callbacks -> sideband_progress = progress_cb ;
194
+
195
+ if (!NIL_P (rb_hash_aref (rb_options , CSTR2SYM ("credentials" ))))
196
+ callbacks -> credentials = credentials_cb ;
197
+
198
+ if (!NIL_P (rb_hash_aref (rb_options , CSTR2SYM ("certificate_check" ))))
199
+ callbacks -> certificate_check = certificate_check_cb ;
200
+
201
+ if (!NIL_P (rb_hash_aref (rb_options , CSTR2SYM ("transfer_progress" ))))
202
+ callbacks -> transfer_progress = transfer_progress_cb ;
203
+
204
+ if (!NIL_P (rb_hash_aref (rb_options , CSTR2SYM ("update_tips" ))))
205
+ callbacks -> update_tips = update_tips_cb ;
206
+ }
207
+
187
208
void rugged_remote_init_callbacks_and_payload_from_options (
188
209
VALUE rb_options ,
189
210
git_remote_callbacks * callbacks ,
@@ -193,6 +214,7 @@ void rugged_remote_init_callbacks_and_payload_from_options(
193
214
194
215
prefilled .payload = payload ;
195
216
memcpy (callbacks , & prefilled , sizeof (git_remote_callbacks ));
217
+ setup_callbacks (callbacks , rb_options );
196
218
197
219
if (!NIL_P (rb_options )) {
198
220
CALLABLE_OR_RAISE (payload -> certificate_check , rb_options , "certificate_check" );
0 commit comments