Skip to content

Commit b26bb55

Browse files
committed
move error handling case to Ruby
1 parent 5c2efa3 commit b26bb55

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

ext/rugged/rugged_tree.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -489,14 +489,9 @@ static VALUE rb_git_tree_diff_(VALUE self, VALUE rb_repo, VALUE rb_self, VALUE r
489489
Data_Get_Struct(rb_self, git_tree, tree);
490490
}
491491

492-
if (rb_obj_is_kind_of(rb_other, rb_cRuggedIndex)) {
493492
git_index *index;
494493
Data_Get_Struct(rb_other, git_index, index);
495494
error = git_diff_tree_to_index(&diff, repo, tree, index, &opts);
496-
} else {
497-
xfree(opts.pathspec.strings);
498-
rb_raise(rb_eTypeError, "A Rugged::Commit, Rugged::Tree or Rugged::Index instance is required");
499-
}
500495

501496
xfree(opts.pathspec.strings);
502497
rugged_exception_check(error);

lib/rugged/tree.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ def self.diff(repo, _self, other = nil, options = {})
2121
diff_tree_to_tree repo, _self, other.tree, options
2222
when Rugged::Tree
2323
diff_tree_to_tree repo, _self, other, options
24-
else
24+
when Rugged::Index
2525
_diff(repo, _self, other, options)
26+
else
27+
raise TypeError, "A Rugged::Commit, Rugged::Tree or Rugged::Index instance is required"
2628
end
2729
end
2830
end

0 commit comments

Comments
 (0)