22#include "git2_exception.h"
33#include "git2_remote.h"
44#include "git2_repository.h"
5+ #include "git2_php_util.h"
56
67static zend_class_entry * php_git2_remote_ce ;
78static zend_object_handlers php_git2_remote_handler ;
@@ -193,18 +194,22 @@ static PHP_METHOD(Remote, disconnect) {
193194
194195ZEND_BEGIN_ARG_INFO_EX (arginfo_remote_download , 0 , 0 , 0 )
195196 ZEND_ARG_INFO (0 , refspecs )
197+ ZEND_ARG_INFO (0 , opts )
196198ZEND_END_ARG_INFO ()
197199
198200static PHP_METHOD (Remote , download ) {
199201 HashTable * refspecs = NULL ;
202+ HashTable * opts = NULL ;
200203
201- if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "|a " , & refspecs ) != SUCCESS ) {
204+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "|aa " , & refspecs , & opts ) != SUCCESS ) {
202205 return ;
203206 }
204207
205208 GIT2_REMOTE_FETCH ();
206- // TODO add git_fetch_options handling
209+
207210 git_fetch_options git_opts = GIT_FETCH_OPTIONS_INIT ;
211+ git2_parse_fetch_options (& git_opts , opts );
212+
208213 git_strarray git_refspecs ;
209214 git_refspecs .count = 0 ;
210215
@@ -223,18 +228,22 @@ static PHP_METHOD(Remote, download) {
223228
224229ZEND_BEGIN_ARG_INFO_EX (arginfo_remote_fetch , 0 , 0 , 0 )
225230 ZEND_ARG_INFO (0 , refspecs )
231+ ZEND_ARG_INFO (0 , opts )
226232ZEND_END_ARG_INFO ()
227233
228234static PHP_METHOD (Remote , fetch ) {
229235 HashTable * refspecs = NULL ;
236+ HashTable * opts = NULL ;
230237
231- if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "|a " , & refspecs ) != SUCCESS ) {
238+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "|aa " , & refspecs , & opts ) != SUCCESS ) {
232239 return ;
233240 }
234241
235242 GIT2_REMOTE_FETCH ();
236- // TODO add git_fetch_options handling and reflog_message
243+
237244 git_fetch_options git_opts = GIT_FETCH_OPTIONS_INIT ;
245+ git2_parse_fetch_options (& git_opts , opts );
246+
238247 git_strarray git_refspecs ;
239248 git_refspecs .count = 0 ;
240249
@@ -254,14 +263,29 @@ static PHP_METHOD(Remote, fetch) {
254263}
255264
256265ZEND_BEGIN_ARG_INFO_EX (arginfo_remote_upload , 0 , 0 , 0 )
266+ ZEND_ARG_INFO (0 , refspecs )
267+ ZEND_ARG_INFO (0 , opts )
257268ZEND_END_ARG_INFO ()
258269
259270static PHP_METHOD (Remote , upload ) {
260- if (zend_parse_parameters_none () == FAILURE ) return ;
271+ HashTable * refspecs = NULL ;
272+ HashTable * opts = NULL ;
273+
274+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "|aa" , & refspecs , & opts ) != SUCCESS ) {
275+ return ;
276+ }
261277 GIT2_REMOTE_FETCH ();
262- // TODO add git_push_options handling
263278
264- int res = git_remote_upload (intern -> remote , NULL , NULL );
279+ git_push_options git_opts ;
280+ git2_parse_push_options (& git_opts , opts );
281+
282+ git_strarray git_refspecs ;
283+ git_refspecs .count = 0 ;
284+
285+ if (refspecs )
286+ php_git2_ht_to_strarray (& git_refspecs , refspecs );
287+
288+ int res = git_remote_upload (intern -> remote , & git_refspecs , & git_opts );
265289
266290 if (res == 0 ) {
267291 RETURN_TRUE ;
@@ -270,14 +294,29 @@ static PHP_METHOD(Remote, upload) {
270294}
271295
272296ZEND_BEGIN_ARG_INFO_EX (arginfo_remote_push , 0 , 0 , 0 )
297+ ZEND_ARG_INFO (0 , refspecs )
298+ ZEND_ARG_INFO (0 , opts )
273299ZEND_END_ARG_INFO ()
274300
275301static PHP_METHOD (Remote , push ) {
276- if (zend_parse_parameters_none () == FAILURE ) return ;
302+ HashTable * refspecs = NULL ;
303+ HashTable * opts = NULL ;
304+
305+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "|aa" , & refspecs , & opts ) != SUCCESS ) {
306+ return ;
307+ }
277308 GIT2_REMOTE_FETCH ();
278- // TODO add git_push_options handling
279309
280- int res = git_remote_push (intern -> remote , NULL , NULL );
310+ git_push_options git_opts ;
311+ git2_parse_push_options (& git_opts , opts );
312+
313+ git_strarray git_refspecs ;
314+ git_refspecs .count = 0 ;
315+
316+ if (refspecs )
317+ php_git2_ht_to_strarray (& git_refspecs , refspecs );
318+
319+ int res = git_remote_push (intern -> remote , & git_refspecs , & git_opts );
281320
282321 if (res == 0 ) {
283322 RETURN_TRUE ;
0 commit comments