@@ -489,18 +489,7 @@ static VALUE rb_git_tree_diff_(VALUE self, VALUE rb_repo, VALUE rb_self, VALUE r
489
489
Data_Get_Struct (rb_self , git_tree , tree );
490
490
}
491
491
492
- if (rb_obj_is_kind_of (rb_other , rb_cRuggedCommit )) {
493
- git_tree * other_tree ;
494
- git_commit * commit ;
495
-
496
- Data_Get_Struct (rb_other , git_commit , commit );
497
- error = git_commit_tree (& other_tree , commit );
498
-
499
- if (!error ) {
500
- error = git_diff_tree_to_tree (& diff , repo , tree , other_tree , & opts );
501
- git_tree_free (other_tree );
502
- }
503
- } else if (rb_obj_is_kind_of (rb_other , rb_cRuggedTree )) {
492
+ if (rb_obj_is_kind_of (rb_other , rb_cRuggedTree )) {
504
493
git_tree * other_tree ;
505
494
506
495
Data_Get_Struct (rb_other , git_tree , other_tree );
@@ -520,8 +509,9 @@ static VALUE rb_git_tree_diff_(VALUE self, VALUE rb_repo, VALUE rb_self, VALUE r
520
509
return rugged_diff_new (rb_cRuggedDiff , rb_repo , diff );
521
510
}
522
511
523
- static VALUE rb_git_diff_tree_to_tree (VALUE self , VALUE rb_repo , VALUE rb_tree , VALUE rb_options ) {
512
+ static VALUE rb_git_diff_tree_to_tree (VALUE self , VALUE rb_repo , VALUE rb_tree , VALUE rb_other_tree , VALUE rb_options ) {
524
513
git_tree * tree = NULL ;
514
+ git_tree * other_tree = NULL ;
525
515
git_diff_options opts = GIT_DIFF_OPTIONS_INIT ;
526
516
git_repository * repo = NULL ;
527
517
git_diff * diff = NULL ;
@@ -530,9 +520,12 @@ static VALUE rb_git_diff_tree_to_tree(VALUE self, VALUE rb_repo, VALUE rb_tree,
530
520
Data_Get_Struct (rb_repo , git_repository , repo );
531
521
Data_Get_Struct (rb_tree , git_tree , tree );
532
522
523
+ if (RTEST (rb_other_tree ))
524
+ Data_Get_Struct (rb_other_tree , git_tree , other_tree );
525
+
533
526
rugged_parse_diff_options (& opts , rb_options );
534
527
535
- error = git_diff_tree_to_tree (& diff , repo , tree , NULL , & opts );
528
+ error = git_diff_tree_to_tree (& diff , repo , tree , other_tree , & opts );
536
529
537
530
xfree (opts .pathspec .strings );
538
531
rugged_exception_check (error );
@@ -1039,7 +1032,7 @@ void Init_rugged_tree(void)
1039
1032
rb_define_singleton_method (rb_cRuggedTree , "empty" , rb_git_tree_empty , 1 );
1040
1033
1041
1034
rb_define_private_method (rb_singleton_class (rb_cRuggedTree ), "_diff" , rb_git_tree_diff_ , 4 );
1042
- rb_define_private_method (rb_singleton_class (rb_cRuggedTree ), "diff_tree_to_tree" , rb_git_diff_tree_to_tree , 3 );
1035
+ rb_define_private_method (rb_singleton_class (rb_cRuggedTree ), "diff_tree_to_tree" , rb_git_diff_tree_to_tree , 4 );
1043
1036
1044
1037
rb_cRuggedTreeBuilder = rb_define_class_under (rb_cRuggedTree , "Builder" , rb_cObject );
1045
1038
rb_define_singleton_method (rb_cRuggedTreeBuilder , "new" , rb_git_treebuilder_new , -1 );
0 commit comments