@@ -93,10 +93,10 @@ zend_object_value php_git_commit_new(zend_class_entry *ce TSRMLS_DC)
9393
9494PHP_METHOD (git_commit , __construct )
9595{
96+ zval * object = getThis ();
9697 zval * z_repository ;
9798 git_commit * commit ;
9899 git_repository * repository ;
99- zval * object = getThis ();
100100 int ret ;
101101
102102 if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
@@ -141,20 +141,19 @@ PHP_METHOD(git_commit, getShortMessage)
141141PHP_METHOD (git_commit , getTree )
142142{
143143 php_git_commit_t * this = (php_git_commit_t * ) zend_object_store_get_object (getThis () TSRMLS_CC );
144- git_tree * ref_tree ;
144+ git_tree * ref_tree , * tree ;
145+ git_oid * tree_oid ;
146+ zval * git_tree , * entry ;
147+
148+ const git_oid * oid = git_object_id ((git_object * )ref_tree );
145149 git_commit_tree (& ref_tree , this -> object );
146- const git_oid * oid = git_object_id ((git_object * )ref_tree );
147150
148- git_tree * tree ;
149151 int ret = git_object_lookup ((git_object * * )& tree , git_object_owner ((git_object * )this -> object ),oid , GIT_OBJ_TREE );
150152 if (ret != GIT_SUCCESS ) {
151153 php_error_docref (NULL TSRMLS_CC , E_ERROR , "specified tree not found." );
152154 return ;
153155 }
154156
155- git_oid * tree_oid ;
156- zval * git_tree ;
157- zval * entry ;
158157
159158 MAKE_STD_ZVAL (git_tree );
160159 object_init_ex (git_tree , git_tree_class_entry );
@@ -232,20 +231,23 @@ PHP_METHOD(git_commit, setParents)
232231PHP_METHOD (git_commit , write )
233232{
234233 php_git_commit_t * this = (php_git_commit_t * ) zend_object_store_get_object (getThis () TSRMLS_CC );
235- git_oid oid ;
236- php_git_signature_t * author ;
237- php_git_signature_t * committer ;
234+ git_oid oid , tree_oid , * * parents , * * p , * tmp ;
235+ php_git_signature_t * author , * committer ;
236+ zval * z_author , * z_committer , * z_parents , * * data ;
237+ char * update_ref , * message , * tree_oid_str = NULL ;
238+ char out [GIT_OID_HEXSZ + 1 ];
239+ int count , i , update_ref_len = 0 ;
240+ git_reference * ref ;
238241
239- char * update_ref = NULL ;
240- int update_ref_len = 0 ;
242+ HashTable * array_hash ;
243+ HashPosition pointer ;
241244
242245 if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
243246 "|s" , & update_ref ,& update_ref_len ) == FAILURE ){
244247 return ;
245248 }
246249
247250 if (ZEND_NUM_ARGS () == 0 ) {
248- git_reference * ref ;
249251 if (git_reference_lookup (& ref ,this -> repository ,"HEAD" )== GIT_SUCCESS ){
250252 if (git_reference_type (ref ) == GIT_REF_SYMBOLIC ) {
251253 git_reference * ref2 ;
@@ -258,27 +260,22 @@ PHP_METHOD(git_commit, write)
258260 }
259261
260262
261- git_oid tree_oid ;
262- char * tree_oid_str = Z_STRVAL_P (zend_read_property (git_commit_class_entry , getThis (),"tree" ,sizeof ("tree" )- 1 , 0 TSRMLS_CC ));
263+ tree_oid_str = Z_STRVAL_P (zend_read_property (git_commit_class_entry , getThis (),"tree" ,sizeof ("tree" )- 1 , 0 TSRMLS_CC ));
263264 git_oid_fromstr (& tree_oid , tree_oid_str );
264265
265- zval * z_author = zend_read_property (git_commit_class_entry , getThis (),"author" ,sizeof ("author" )- 1 , 0 TSRMLS_CC );
266+ z_author = zend_read_property (git_commit_class_entry , getThis (),"author" ,sizeof ("author" )- 1 , 0 TSRMLS_CC );
266267 author = (php_git_signature_t * ) zend_object_store_get_object (z_author TSRMLS_CC );
267268
268- zval * z_committer = zend_read_property (git_commit_class_entry , getThis (),"committer" ,sizeof ("committer" )- 1 , 0 TSRMLS_CC );
269+ z_committer = zend_read_property (git_commit_class_entry , getThis (),"committer" ,sizeof ("committer" )- 1 , 0 TSRMLS_CC );
269270 committer = (php_git_signature_t * ) zend_object_store_get_object (z_committer TSRMLS_CC );
270271
271- zval * z_parents = zend_read_property (git_commit_class_entry , getThis (),"parents" ,sizeof ("parents" )- 1 , 0 TSRMLS_CC );
272+ z_parents = zend_read_property (git_commit_class_entry , getThis (),"parents" ,sizeof ("parents" )- 1 , 0 TSRMLS_CC );
272273
273- int count = zend_hash_num_elements (Z_ARRVAL_P (z_parents ));
274+ count = zend_hash_num_elements (Z_ARRVAL_P (z_parents ));
274275
275276
276- HashTable * array_hash = Z_ARRVAL_P (z_parents );
277- HashPosition pointer ;
278- git_oid * tmp ;
279- zval * * data ;
280- git_oid * * p ;
281- git_oid * * parents = (git_oid * * )calloc (count ,sizeof (git_oid ));
277+ array_hash = Z_ARRVAL_P (z_parents );
278+ parents = (git_oid * * )calloc (count ,sizeof (git_oid ));
282279 p = parents ;
283280
284281 for (zend_hash_internal_pointer_reset_ex (array_hash , & pointer );
@@ -293,7 +290,7 @@ PHP_METHOD(git_commit, write)
293290 p ++ ;
294291 }
295292
296- char * message = Z_STRVAL_P (zend_read_property (git_commit_class_entry , getThis (),"message" ,sizeof ("message" )- 1 , 0 TSRMLS_CC ));
293+ message = Z_STRVAL_P (zend_read_property (git_commit_class_entry , getThis (),"message" ,sizeof ("message" )- 1 , 0 TSRMLS_CC ));
297294 git_commit_create (& oid ,
298295 this -> repository ,
299296 update_ref ,
@@ -305,10 +302,8 @@ PHP_METHOD(git_commit, write)
305302 parents
306303 );
307304
308- char out [GIT_OID_HEXSZ + 1 ];
309305 git_oid_to_string (out ,GIT_OID_HEXSZ + 1 ,& oid );
310306
311- int i ;
312307 for (i = 0 ; i < count ;i ++ ){
313308 free (parents [i ]);
314309 }
0 commit comments