Skip to content

Commit 59af00e

Browse files
committed
Pull other is_a check in to Ruby
1 parent 4141b2f commit 59af00e

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

ext/rugged/rugged_index.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -810,14 +810,9 @@ 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_cRuggedTree)) {
814813
git_tree *other_tree;
815814
Data_Get_Struct(rb_other, git_tree, other_tree);
816815
error = git_diff_tree_to_index(&diff, repo, other_tree, index, &opts);
817-
} else {
818-
xfree(opts.pathspec.strings);
819-
rb_raise(rb_eTypeError, "A Rugged::Commit or Rugged::Tree instance is required");
820-
}
821816

822817
xfree(opts.pathspec.strings);
823818
rugged_exception_check(error);

lib/rugged/index.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ def diff(*args)
1111
if other.is_a? ::Rugged::Commit
1212
_diff other.tree, options
1313
else
14-
_diff other, options
14+
if other.is_a? ::Rugged::Tree
15+
_diff other, options
16+
else
17+
raise TypeError, "A Rugged::Commit or Rugged::Tree instance is required"
18+
end
1519
end
1620
end
1721
end

0 commit comments

Comments
 (0)