Skip to content

Commit 4141b2f

Browse files
committed
Pull is_a check to Ruby
1 parent 1c92d0e commit 4141b2f

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

ext/rugged/rugged_index.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -810,15 +810,7 @@ static VALUE rb_git_index_diff(VALUE self, VALUE rb_other, VALUE rb_options)
810810
// the "old file" side of the diff.
811811
opts.flags ^= GIT_DIFF_REVERSE;
812812

813-
if (rb_obj_is_kind_of(rb_other, rb_cRuggedCommit)) {
814-
git_tree *other_tree;
815-
git_commit *commit;
816-
Data_Get_Struct(rb_other, git_commit, commit);
817-
error = git_commit_tree(&other_tree, commit);
818-
819-
if (!error)
820-
error = git_diff_tree_to_index(&diff, repo, other_tree, index, &opts);
821-
} else if (rb_obj_is_kind_of(rb_other, rb_cRuggedTree)) {
813+
if (rb_obj_is_kind_of(rb_other, rb_cRuggedTree)) {
822814
git_tree *other_tree;
823815
Data_Get_Struct(rb_other, git_tree, other_tree);
824816
error = git_diff_tree_to_index(&diff, repo, other_tree, index, &opts);

lib/rugged/index.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ def diff(*args)
88
if other.nil?
99
diff_index_to_workdir options
1010
else
11-
_diff other, options
11+
if other.is_a? ::Rugged::Commit
12+
_diff other.tree, options
13+
else
14+
_diff other, options
15+
end
1216
end
1317
end
1418

0 commit comments

Comments
 (0)