Skip to content

Commit e86c5d7

Browse files
committed
added Git2\Commit::getTree
1 parent 91d1fd9 commit e86c5d7

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

commit.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,13 +323,45 @@ PHP_METHOD(git2_commit, create)
323323
}
324324
/* }}} */
325325

326+
327+
/*
328+
{{{ proto: Git2\Commit::getTree()
329+
*/
330+
PHP_METHOD(git2_commit, getTree)
331+
{
332+
php_git2_commit *m_commit;
333+
git_oid *oid, *id;
334+
git_otype type = GIT_OBJ_TREE;
335+
git_object *object;
336+
zval *result;
337+
int error = 0;
338+
339+
m_commit = PHP_GIT2_GET_OBJECT(php_git2_commit, getThis());
340+
341+
if (m_commit != NULL) {
342+
if (m_commit->commit == NULL) {
343+
RETURN_FALSE;
344+
}
345+
346+
oid = git_commit_tree_oid(m_commit->commit);
347+
error = git_object_lookup(&object, git_object_owner((git_object *)m_commit->commit), oid, type);
348+
result = php_git2_object_new(git_object_owner((git_object *)m_commit->commit), object TSRMLS_CC);
349+
RETVAL_ZVAL(result,0,1);
350+
} else {
351+
RETURN_FALSE;
352+
}
353+
}
354+
/* }}} */
355+
356+
326357
static zend_function_entry php_git2_commit_methods[] = {
327358
PHP_ME(git2_commit, getMessage, NULL, ZEND_ACC_PUBLIC)
328359
PHP_ME(git2_commit, getMessageEncoding, NULL, ZEND_ACC_PUBLIC)
329360
PHP_ME(git2_commit, parentCount, NULL, ZEND_ACC_PUBLIC)
330361
PHP_ME(git2_commit, getAuthor, NULL, ZEND_ACC_PUBLIC)
331362
PHP_ME(git2_commit, getCommitter, NULL, ZEND_ACC_PUBLIC)
332363
PHP_ME(git2_commit, getOid, NULL, ZEND_ACC_PUBLIC)
364+
PHP_ME(git2_commit, getTree, NULL, ZEND_ACC_PUBLIC)
333365
PHP_ME(git2_commit, create, arginfo_git2_commit_create, ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
334366
{NULL,NULL,NULL}
335367
};

0 commit comments

Comments
 (0)