Skip to content

Commit

Permalink
fixing reflist + adding test for Git2\Reference::list($repo)
Browse files Browse the repository at this point in the history
  • Loading branch information
MagicalTux committed Nov 21, 2017
1 parent 32d63a2 commit 87e3f4f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 5 additions & 6 deletions git2_reference.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,13 @@ ZEND_END_ARG_INFO()

static int git2_reference_list_callback(git_reference *ref, void *payload) {
git2_reference_object_t *intern;
zval *obj;
ALLOC_ZVAL(obj);
zval obj;

object_init_ex(obj, php_git2_reference_ce);
intern = (git2_reference_object_t*)Z_OBJ_P(obj);
object_init_ex(&obj, php_git2_reference_ce);
intern = (git2_reference_object_t*)Z_OBJ_P(&obj);
intern->ref = ref;

add_next_index_zval((zval*)payload, obj);
add_next_index_zval((zval*)payload, &obj);
return 0;
}

Expand All @@ -108,7 +107,7 @@ static PHP_METHOD(Reference, list) {

array_init(return_value);

int res = git_reference_foreach(repo, git2_reference_list_callback, &return_value);
int res = git_reference_foreach(repo, git2_reference_list_callback, return_value);
if (res != 0) {
git2_throw_last_error();
return;
Expand Down
4 changes: 4 additions & 0 deletions git2_tests/001_clone.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@
#var_dump($repo->checkout_head());
var_dump($repo->head());

foreach(Git2\Reference::list($repo) as $ref) {
echo "Ref: ".$ref->name()." --> ".bin2hex($ref->target())."\n";
}

0 comments on commit 87e3f4f

Please sign in to comment.