@@ -169,20 +169,22 @@ static VALUE rb_git_config_delete(VALUE self, VALUE rb_key)
169
169
return Qtrue ;
170
170
}
171
171
172
- static int cb_config__each_key (const git_config_entry * entry , void * opaque )
172
+ static int cb_config__each_key (const git_config_entry * entry , void * payload )
173
173
{
174
- rb_funcall ((VALUE )opaque , rb_intern ("call" ), 1 , rb_str_new_utf8 (entry -> name ));
175
- return GIT_OK ;
174
+ int * exception = (int * ) payload ;
175
+
176
+ rb_protect (rb_yield , rb_ary_new3 (1 , rb_str_new_utf8 (entry -> name )), exception );
177
+
178
+ return (* exception != 0 ) ? GIT_EUSER : GIT_OK ;
176
179
}
177
180
178
- static int cb_config__each_pair (const git_config_entry * entry , void * opaque )
181
+ static int cb_config__each_pair (const git_config_entry * entry , void * payload )
179
182
{
180
- rb_funcall ((VALUE )opaque , rb_intern ("call" ), 2 ,
181
- rb_str_new_utf8 (entry -> name ),
182
- rb_str_new_utf8 (entry -> value )
183
- );
183
+ int * exception = (int * ) payload ;
184
184
185
- return GIT_OK ;
185
+ rb_protect (rb_yield , rb_ary_new3 (2 , rb_str_new_utf8 (entry -> name ), rb_str_new_utf8 (entry -> value )), exception );
186
+
187
+ return (* exception != 0 ) ? GIT_EUSER : GIT_OK ;
186
188
}
187
189
188
190
static int cb_config__to_hash (const git_config_entry * entry , void * opaque )
@@ -210,12 +212,15 @@ static int cb_config__to_hash(const git_config_entry *entry, void *opaque)
210
212
static VALUE rb_git_config_each_key (VALUE self )
211
213
{
212
214
git_config * config ;
213
- int error ;
215
+ int error , exception ;
214
216
215
217
RETURN_ENUMERATOR (self , 0 , 0 );
216
218
Data_Get_Struct (self , git_config , config );
217
219
218
- error = git_config_foreach (config , & cb_config__each_key , (void * )rb_block_proc ());
220
+ error = git_config_foreach (config , & cb_config__each_key , & exception );
221
+ if (error == GIT_EUSER )
222
+ rb_jump_tag (exception );
223
+
219
224
rugged_exception_check (error );
220
225
return Qnil ;
221
226
}
@@ -237,12 +242,15 @@ static VALUE rb_git_config_each_key(VALUE self)
237
242
static VALUE rb_git_config_each_pair (VALUE self )
238
243
{
239
244
git_config * config ;
240
- int error ;
241
-
245
+ int error , exception ;
246
+
242
247
RETURN_ENUMERATOR (self , 0 , 0 );
243
248
Data_Get_Struct (self , git_config , config );
244
249
245
- error = git_config_foreach (config , & cb_config__each_pair , (void * )rb_block_proc ());
250
+ error = git_config_foreach (config , & cb_config__each_pair , & exception );
251
+ if (error == GIT_EUSER )
252
+ rb_jump_tag (exception );
253
+
246
254
rugged_exception_check (error );
247
255
return Qnil ;
248
256
}
0 commit comments