@@ -56,6 +56,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_git2_tree_get_subtree, 0,0,1)
5656 ZEND_ARG_INFO (0 , path )
5757ZEND_END_ARG_INFO ()
5858
59+ ZEND_BEGIN_ARG_INFO_EX (arginfo_git2_tree_get_entry_by_name , 0 ,0 ,1 )
60+ ZEND_ARG_INFO (0 , path )
61+ ZEND_END_ARG_INFO ()
62+
5963
6064static int php_git2_tree_diff_cb (const git_tree_diff_data * ptr , void * data )
6165{
@@ -296,6 +300,35 @@ PHP_METHOD(git2_tree, getSubtree)
296300/* }}} */
297301
298302
303+ /*
304+ {{{ proto: Git2\Tree Git2\Tree::getEntryByName($name)
305+ */
306+ PHP_METHOD (git2_tree , getEntryByName )
307+ {
308+ char * path = NULL ;
309+ int path_len = 0 ;
310+ php_git2_tree * object ;
311+ const git_tree_entry * entry = NULL ;
312+
313+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
314+ "s" , & path , & path_len ) == FAILURE ) {
315+ return ;
316+ }
317+
318+ object = PHP_GIT2_GET_OBJECT (php_git2_tree , getThis ());
319+
320+ entry = git_tree_entry_byname (object -> tree , (const char * )path );
321+ if (entry ) {
322+ zval * result ;
323+
324+ create_tree_entry_from_entry (& result , (git_tree_entry * )entry ,git_object_owner ((git_object * )object -> tree ));
325+ RETVAL_ZVAL (result , 0 , 1 );
326+ } else {
327+ RETURN_FALSE ;
328+ }
329+ }
330+ /* }}} */
331+
299332
300333static zend_function_entry php_git2_tree_methods [] = {
301334 PHP_ME (git2_tree , diff , arginfo_git2_tree_diff , ZEND_ACC_PUBLIC | ZEND_ACC_STATIC )
@@ -306,6 +339,7 @@ static zend_function_entry php_git2_tree_methods[] = {
306339 PHP_ME (git2_tree , rewind , NULL , ZEND_ACC_PUBLIC )
307340 PHP_ME (git2_tree , valid , NULL , ZEND_ACC_PUBLIC )
308341 PHP_ME (git2_tree , getSubtree , arginfo_git2_tree_get_subtree , ZEND_ACC_PUBLIC )
342+ PHP_ME (git2_tree , getEntryByName ,arginfo_git2_tree_get_entry_by_name , ZEND_ACC_PUBLIC )
309343 {NULL ,NULL ,NULL }
310344};
311345
0 commit comments