Skip to content

Commit 4b4e65a

Browse files
authored
Merge pull request #938 from libgit2/cmn/walker-commit
Fix pushing/hiding objects into the walker
2 parents c78ba61 + eb3b1ba commit 4b4e65a

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

ext/rugged/rugged_revwalk.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ extern VALUE rb_mRugged;
1111
extern VALUE rb_cRuggedObject;
1212
VALUE rb_cRuggedWalker;
1313

14+
extern const rb_data_type_t rugged_object_type;
15+
1416
static void rb_git_walk__free(git_revwalk *walk)
1517
{
1618
git_revwalk_free(walk);
@@ -43,7 +45,7 @@ static void push_commit_1(git_revwalk *walk, VALUE rb_commit, int hide)
4345
{
4446
if (rb_obj_is_kind_of(rb_commit, rb_cRuggedObject)) {
4547
git_object *object;
46-
Data_Get_Struct(rb_commit, git_object, object);
48+
TypedData_Get_Struct(rb_commit, git_object, &rugged_object_type, object);
4749

4850
push_commit_oid(walk, git_object_id(object), hide);
4951
return;

test/walker_test.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,17 @@ def test_walk_count_with_block
167167

168168
assert_equal 1, amount
169169
end
170+
171+
def test_push_hide_commit
172+
@walker.push(@repo.lookup("9fd738e8f7967c078dceed8190330fc8648ee56a"))
173+
@walker.hide(@repo.lookup("5b5b025afb0b4c913b4c338a42934a3863bf3644"))
174+
175+
amount = @walker.count do |commit|
176+
commit.oid == "9fd738e8f7967c078dceed8190330fc8648ee56a"
177+
end
178+
179+
assert_equal 1, amount
180+
end
170181
end
171182

172183
# testrepo (the non-bare repo) is the one with non-linear history,

0 commit comments

Comments
 (0)