6
6
*/
7
7
8
8
#include "rugged.h"
9
+ #include <ruby/thread.h>
9
10
10
11
extern VALUE rb_mRugged ;
11
12
VALUE rb_cRuggedDiff ;
@@ -197,6 +198,20 @@ static int diff_print_cb(
197
198
return GIT_OK ;
198
199
}
199
200
201
+ struct nogvl_diff_patch_args {
202
+ git_diff * diff ;
203
+ git_diff_format_t format ;
204
+ VALUE rb_str ;
205
+ };
206
+
207
+ static void rb_git_diff_patch_nogvl (void * _args )
208
+ {
209
+ struct nogvl_diff_patch_args * args ;
210
+
211
+ args = (struct nogvl_diff_patch_args * )_args ;
212
+ git_diff_print (args -> diff , args -> format , diff_print_cb , (void * ) args -> rb_str );
213
+ }
214
+
200
215
/*
201
216
* call-seq:
202
217
* diff.patch -> patch
@@ -209,20 +224,25 @@ static VALUE rb_git_diff_patch(int argc, VALUE *argv, VALUE self)
209
224
git_diff * diff ;
210
225
VALUE rb_str = rb_str_new (NULL , 0 );
211
226
VALUE rb_opts ;
227
+ struct nogvl_diff_patch_args args ;
228
+ git_diff_format_t format = GIT_DIFF_FORMAT_PATCH ;
212
229
213
230
rb_scan_args (argc , argv , "00:" , & rb_opts );
214
231
215
232
Data_Get_Struct (self , git_diff , diff );
216
233
217
234
if (!NIL_P (rb_opts )) {
218
235
if (rb_hash_aref (rb_opts , CSTR2SYM ("compact" )) == Qtrue )
219
- git_diff_print ( diff , GIT_DIFF_FORMAT_NAME_STATUS , diff_print_cb , ( void * ) rb_str ) ;
236
+ format = GIT_DIFF_FORMAT_NAME_STATUS ;
220
237
else
221
- git_diff_print (diff , GIT_DIFF_FORMAT_PATCH , diff_print_cb , (void * )rb_str );
222
- } else {
223
- git_diff_print (diff , GIT_DIFF_FORMAT_PATCH , diff_print_cb , (void * )rb_str );
238
+ format = GIT_DIFF_FORMAT_PATCH ;
224
239
}
225
240
241
+ args .diff = diff ;
242
+ args .format = format ;
243
+ args .rb_str = rb_str ;
244
+ rb_thread_call_without_gvl (rb_git_diff_patch_nogvl , & args , RUBY_UBF_PROCESS , NULL );
245
+
226
246
return rb_str ;
227
247
}
228
248
0 commit comments