Skip to content

Commit f47a0d7

Browse files
committed
allow null values for fetch/download/push/upload
1 parent 234f102 commit f47a0d7

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

git2_php_util.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ void git2_parse_checkout_options(git_checkout_options *opts, HashTable *ht) {
180180

181181
void git2_parse_fetch_options(git_fetch_options *opts, HashTable *ht) {
182182
zval *data;
183-
184183
if (ht == NULL) return; // skip if null
185184

186185
ARRAY_FETCH_OPTIONS(callbacks, git2_parse_remote_callbacks);

git2_remote.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ static PHP_METHOD(Remote, download) {
201201
HashTable *refspecs = NULL;
202202
HashTable *opts = NULL;
203203

204-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|aa", &refspecs, &opts) != SUCCESS) {
204+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a!a!", &refspecs, &opts) != SUCCESS) {
205205
return;
206206
}
207207

@@ -234,19 +234,19 @@ ZEND_END_ARG_INFO()
234234
static PHP_METHOD(Remote, fetch) {
235235
HashTable *refspecs = NULL;
236236
HashTable *opts = NULL;
237+
git_fetch_options git_opts = GIT_FETCH_OPTIONS_INIT;
238+
git_strarray git_refspecs;
239+
git_refspecs.count = 0;
237240

238-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|aa", &refspecs, &opts) != SUCCESS) {
241+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a!a!", &refspecs, &opts) != SUCCESS) {
239242
return;
240243
}
241244

242245
GIT2_REMOTE_FETCH();
243246

244-
git_fetch_options git_opts = GIT_FETCH_OPTIONS_INIT;
247+
// parse parameters
245248
git2_parse_fetch_options(&git_opts, opts);
246249

247-
git_strarray git_refspecs;
248-
git_refspecs.count = 0;
249-
250250
if (refspecs)
251251
php_git2_ht_to_strarray(&git_refspecs, refspecs);
252252

@@ -271,7 +271,7 @@ static PHP_METHOD(Remote, upload) {
271271
HashTable *refspecs = NULL;
272272
HashTable *opts = NULL;
273273

274-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|aa", &refspecs, &opts) != SUCCESS) {
274+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a!a!", &refspecs, &opts) != SUCCESS) {
275275
return;
276276
}
277277
GIT2_REMOTE_FETCH();
@@ -302,7 +302,7 @@ static PHP_METHOD(Remote, push) {
302302
HashTable *refspecs = NULL;
303303
HashTable *opts = NULL;
304304

305-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|aa", &refspecs, &opts) != SUCCESS) {
305+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a!a!", &refspecs, &opts) != SUCCESS) {
306306
return;
307307
}
308308
GIT2_REMOTE_FETCH();

0 commit comments

Comments
 (0)