Skip to content

Commit 9f8c803

Browse files
committed
for now, add example
1 parent 9e521b4 commit 9f8c803

File tree

5 files changed

+27
-2
lines changed

5 files changed

+27
-2
lines changed

example/clone.php

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
$repo = git_clone("https://github.com/chobie/php-protocolbuffers", "/tmp/protocolbuffers");

example/ref_lookup.php

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
$repo = git_repository_open("../");
3+
4+
$ref = git_reference_dwim($repo, "functions");
5+
$obj = git_reference_peel($ref, GIT_OBJ_ANY);
6+
echo git_object_id($obj);

example/revwalk.php

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
$repo = git_repository_open("../");
3+
$walker = git_revwalk_new($repo);
4+
git_revwalk_push_range($walker, "HEAD~20..HEAD");
5+
6+
while ($id = git_revwalk_next($walker)) {
7+
echo $id . PHP_EOL;
8+
}

example/walking.php

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
$repo = git_repository_open("../");
3+
$obj = git_revparse_single($repo, "HEAD^{tree}");
4+
5+
$payload = array();
6+
git_tree_walk($obj, GIT_TREEWALK_PRE, function($root, $entry, &$payload) {
7+
echo git_tree_entry_name($entry) . PHP_EOL;
8+
}, $payload);

reference.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -858,11 +858,12 @@ PHP_FUNCTION(git_reference_peel)
858858
{
859859
php_git2_t *result = NULL, *_ref = NULL;
860860
git_object *out = NULL;
861-
zval *ref = NULL, *type = NULL;
861+
zval *ref = NULL;
862862
int error = 0;
863+
long type = 0;
863864

864865
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
865-
"r<git_otype>", &ref, &type) == FAILURE) {
866+
"rl", &ref, &type) == FAILURE) {
866867
return;
867868
}
868869

0 commit comments

Comments
 (0)