Skip to content

Commit 2c4cce5

Browse files
committed
Allow clone options bare and ignore_cert
1 parent 9a33238 commit 2c4cce5

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

clone.c

+28-3
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,50 @@
22
#include "php_git2_priv.h"
33
#include "clone.h"
44

5+
static void php_git2_git_clone_options_to_array(git_clone_options *options, zval **out TSRMLS_DC)
6+
{
7+
zval *result, *pathspec;
8+
9+
MAKE_STD_ZVAL(result);
10+
array_init(result);
11+
12+
add_assoc_long_ex(result, ZEND_STRS("version"), options->version);
13+
add_assoc_long_ex(result, ZEND_STRS("bare"), options->bare);
14+
add_assoc_long_ex(result, ZEND_STRS("ignore_cert_errors"), options->ignore_cert_errors);
15+
/* TODO: make other options available */
16+
*out = result;
17+
}
18+
19+
static void php_git2_array_to_git_clone_options(git_clone_options *options, zval *array TSRMLS_DC)
20+
{
21+
options->version = php_git2_read_arrval_long2(array, ZEND_STRS("version"), 1 TSRMLS_CC);
22+
options->bare = php_git2_read_arrval_long2(array, ZEND_STRS("bare"), 0 TSRMLS_CC);
23+
options->ignore_cert_errors = php_git2_read_arrval_long2(array, ZEND_STRS("ignore_cert_errors"), 0 TSRMLS_CC);
24+
}
25+
526
/* {{{ proto resource git_clone(string $url, string $localpath[, array $options])
627
*/
728
PHP_FUNCTION(git_clone)
829
{
930
char *url, *localpath;
1031
int url_len, localpath_len;
11-
zval *options;// = GIT_OPTIONS_INIT;
32+
zval *opts = NULL;// = GIT_OPTIONS_INIT;
1233
php_git2_t *git2;
1334
git_repository *repository;
1435
int error;
36+
git_clone_options options = GIT_CLONE_OPTIONS_INIT;
1537

1638
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
17-
"ss|a", &url, &url_len, &localpath, &localpath_len, &options) == FAILURE) {
39+
"ss|a", &url, &url_len, &localpath, &localpath_len, &opts) == FAILURE) {
1840
return;
1941
}
2042

2143
/* TODO(chobie): convert options to git_clone_options */
2244

23-
error = git_clone(&repository, url, localpath, NULL);
45+
php_git2_array_to_git_clone_options(&options, opts TSRMLS_CC);
46+
47+
48+
error = git_clone(&repository, url, localpath, &options);
2449
if (php_git2_check_error(error, "git_clone" TSRMLS_CC)) {
2550
RETURN_FALSE
2651
}

0 commit comments

Comments
 (0)