23
23
*/
24
24
25
25
#include "rugged.h"
26
+ #include <ruby/thread.h>
26
27
27
28
extern VALUE rb_mRugged ;
28
29
extern VALUE rb_cRuggedObject ;
@@ -380,13 +381,31 @@ static VALUE rb_git_diff_tree_to_index(VALUE self, VALUE rb_repo, VALUE rb_self,
380
381
return rugged_diff_new (rb_cRuggedDiff , rb_repo , diff );
381
382
}
382
383
384
+ struct nogvl_diff_args {
385
+ git_repository * repo ;
386
+ git_tree * tree ;
387
+ git_tree * other_tree ;
388
+ git_diff_options * opts ;
389
+ int error ;
390
+ };
391
+
392
+ static void * rb_git_diff_tree_to_tree_nogvl (void * _args )
393
+ {
394
+ struct nogvl_diff_args * args ;
395
+ git_diff * diff = NULL ;
396
+
397
+ args = (struct nogvl_diff_args * )_args ;
398
+ args -> error = git_diff_tree_to_tree (& diff , args -> repo , args -> tree , args -> other_tree , args -> opts );
399
+ return diff ;
400
+ }
401
+
383
402
static VALUE rb_git_diff_tree_to_tree (VALUE self , VALUE rb_repo , VALUE rb_tree , VALUE rb_other_tree , VALUE rb_options ) {
384
403
git_tree * tree = NULL ;
385
404
git_tree * other_tree = NULL ;
386
405
git_diff_options opts = GIT_DIFF_OPTIONS_INIT ;
387
406
git_repository * repo = NULL ;
388
407
git_diff * diff = NULL ;
389
- int error ;
408
+ struct nogvl_diff_args args ;
390
409
391
410
Data_Get_Struct (rb_repo , git_repository , repo );
392
411
Data_Get_Struct (rb_tree , git_tree , tree );
@@ -396,10 +415,15 @@ static VALUE rb_git_diff_tree_to_tree(VALUE self, VALUE rb_repo, VALUE rb_tree,
396
415
397
416
rugged_parse_diff_options (& opts , rb_options );
398
417
399
- error = git_diff_tree_to_tree (& diff , repo , tree , other_tree , & opts );
418
+ args .repo = repo ;
419
+ args .tree = tree ;
420
+ args .other_tree = other_tree ;
421
+ args .opts = & opts ;
422
+
423
+ diff = rb_thread_call_without_gvl (rb_git_diff_tree_to_tree_nogvl , & args , RUBY_UBF_PROCESS , NULL );
400
424
401
425
xfree (opts .pathspec .strings );
402
- rugged_exception_check (error );
426
+ rugged_exception_check (args . error );
403
427
404
428
return rugged_diff_new (rb_cRuggedDiff , rb_repo , diff );
405
429
}
0 commit comments