diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..bfe6af5ccf --- /dev/null +++ b/.travis.yml @@ -0,0 +1,26 @@ +language: php + +php: + - 5.3 + - 5.4 + - 5.5 + +install: + - sudo apt-get -qq update + - sudo apt-get -qq install cmake libssh2-1-dev openssh-client openssh-server + +script: + - script/cibuild.sh + +notifications: + irc: + channels: + - irc.freenode.net#php-git + on_success: change + on_failure: always + use_notice: true + skip_join: true + slack: + on_success: always + on_failure: always + secure: KH9+7GLccFrGWe+E6RhSqHxh+w5DIdsVxn41Iqb2C8rfm5rrnK0KVDTWJXk2BDHc2B1ab28o6m/Vcd8C/lgURd7yx4QfUASQRrHEn4FfpsB7UgES+/aENb59ma3DVz5PqVDUSVSvABU9OCqEkLmN/9w2mL/q3rW4slUq4LzMweI= diff --git a/README.md b/README.md index a2ba044ddb..175ec8fcc2 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,10 @@ php-git2 is a PHP bindings to the libgit2 linkable C Git library. * API Documentation: http://libgit2.github.com/libgit2/#v0.20.0 (also see Signature conversions section) * IRC: #php-git on irc.freenode.net. +## Requirements + +PHP 5.3 above + ## Status 0.3.0 Alpha (switching to functions) @@ -15,12 +19,22 @@ https://docs.google.com/spreadsheet/ccc?key=0AjvShWAWqvfHdDRneEtIUF9GRUZMNVVVR1h ``` # build libgit2.a +## For 32bit systems git submodule init && git submodule update mkdir libgit2/build cd libgit2/build cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF -DBUILD_CLAR=OFF .. cmake --build . +# For 64bit systems +git submodule init && git submodule update +mkdir libgit2/build +cd libgit2/build +cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF -DBUILD_CLAR=OFF +-DCMAKE_C_FLAGS=-fPIC .. +cmake --build . + + # build php-git2 cd ../../ phpize diff --git a/clone.c b/clone.c index 6bd6337883..095aa5dc38 100644 --- a/clone.c +++ b/clone.c @@ -2,25 +2,50 @@ #include "php_git2_priv.h" #include "clone.h" +static void php_git2_git_clone_options_to_array(git_clone_options *options, zval **out TSRMLS_DC) +{ + zval *result, *pathspec; + + MAKE_STD_ZVAL(result); + array_init(result); + + add_assoc_long_ex(result, ZEND_STRS("version"), options->version); + add_assoc_long_ex(result, ZEND_STRS("bare"), options->bare); + add_assoc_long_ex(result, ZEND_STRS("ignore_cert_errors"), options->ignore_cert_errors); + /* TODO: make other options available */ + *out = result; +} + +static void php_git2_array_to_git_clone_options(git_clone_options *options, zval *array TSRMLS_DC) +{ + options->version = php_git2_read_arrval_long2(array, ZEND_STRS("version"), 1 TSRMLS_CC); + options->bare = php_git2_read_arrval_long2(array, ZEND_STRS("bare"), 0 TSRMLS_CC); + options->ignore_cert_errors = php_git2_read_arrval_long2(array, ZEND_STRS("ignore_cert_errors"), 0 TSRMLS_CC); +} + /* {{{ proto resource git_clone(string $url, string $localpath[, array $options]) */ PHP_FUNCTION(git_clone) { char *url, *localpath; int url_len, localpath_len; - zval *options;// = GIT_OPTIONS_INIT; + zval *opts = NULL;// = GIT_OPTIONS_INIT; php_git2_t *git2; git_repository *repository; int error; + git_clone_options options = GIT_CLONE_OPTIONS_INIT; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, - "ss|a", &url, &url_len, &localpath, &localpath_len, &options) == FAILURE) { + "ss|a", &url, &url_len, &localpath, &localpath_len, &opts) == FAILURE) { return; } /* TODO(chobie): convert options to git_clone_options */ - error = git_clone(&repository, url, localpath, NULL); + php_git2_array_to_git_clone_options(&options, opts TSRMLS_CC); + + + error = git_clone(&repository, url, localpath, &options); if (php_git2_check_error(error, "git_clone" TSRMLS_CC)) { RETURN_FALSE } diff --git a/diff.c b/diff.c index 68002ec878..7acd39a64c 100644 --- a/diff.c +++ b/diff.c @@ -288,7 +288,7 @@ PHP_FUNCTION(git_diff_get_delta) ZEND_FETCH_RESOURCE(_diff, php_git2_t*, &diff, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); result = git_diff_get_delta(PHP_GIT2_V(_diff, diff), idx); - php_git2_git_diff_delta_to_array(result, &_result TSRMLS_CC); + php_git2_diff_delta_to_array(result, &_result TSRMLS_CC); RETURN_ZVAL(_result, 0, 1); } /* }}} */ diff --git a/g_config.c b/g_config.c index 29fdcf8a8a..cb15c30ad5 100644 --- a/g_config.c +++ b/g_config.c @@ -119,7 +119,7 @@ static void php_git2_config_set_with(INTERNAL_FUNCTION_PARAMETERS, enum php_git2 } case PHP_GIT2_CONFIG_BOOL: { if (Z_TYPE_P(value) != IS_BOOL) { - convert_to_bool(value); + convert_to_boolean(value); } error = git_config_set_bool(PHP_GIT2_V(_cfg, config), name, Z_LVAL_P(value)); if (php_git2_check_error(error, "git_config_set_bool" TSRMLS_CC)) { diff --git a/php_git2.h b/php_git2.h index 78a3f0f76e..4c5493a976 100644 --- a/php_git2.h +++ b/php_git2.h @@ -27,7 +27,7 @@ #define PHP_GIT2_H #define PHP_GIT2_EXTNAME "git2" -#define PHP_GIT2_EXTVER "0.2.0" +#define PHP_GIT2_EXTVER "0.3.0" #ifdef HAVE_CONFIG_H #include "config.h" @@ -237,4 +237,4 @@ typedef struct php_git2_odb_backend_foreach_callback { extern zend_class_entry *php_git2_odb_backend_foreach_callback_class_entry; -#endif /* PHP_GIT2_H */ \ No newline at end of file +#endif /* PHP_GIT2_H */ diff --git a/ref.php b/ref.php new file mode 100644 index 0000000000..0235eeea8d --- /dev/null +++ b/ref.php @@ -0,0 +1,19 @@ +getFunctions() as $func) { + /** @var ReflectionFunction $func */ + + $name = $func->getName(); + $result[$name] = array(); + foreach ($func->getParameters() as $param) { + /** @var ReflectionParameter $param */ + $result[$name][] = '$' . $param->getName(); + } +} + +echo " $params) { + printf("function %s(%s){}\n", $func, join(", ", $params)); +} diff --git a/script/cibuild.sh b/script/cibuild.sh new file mode 100755 index 0000000000..720213790d --- /dev/null +++ b/script/cibuild.sh @@ -0,0 +1,13 @@ +export NO_INTERACTION=1 +export TESTS="--show-diff -q" + +mkdir $TRAVIS_BUILD_DIR/libgit2/build +cd $TRAVIS_BUILD_DIR/libgit2/build +cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF -DBUILD_CLAR=OFF -DCMAKE_C_FLAGS=-fPIC .. +cmake --build . +cd $TRAVIS_BUILD_DIR + +phpize +./configure +make +make test diff --git a/status.c b/status.c index 4f9c9670da..072d713895 100644 --- a/status.c +++ b/status.c @@ -152,7 +152,7 @@ PHP_FUNCTION(git_status_file) } ZEND_FETCH_RESOURCE(_repo, php_git2_t*, &repo, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); - result = git_status_file(status_flags, PHP_GIT2_V(_repo, repository), path); + result = git_status_file(&status_flags, PHP_GIT2_V(_repo, repository), path); RETURN_LONG(result); } /* }}} */ @@ -280,4 +280,4 @@ PHP_FUNCTION(git_status_options_new) php_git2_git_status_options_to_array(&options, &result TSRMLS_CC); RETURN_ZVAL(result, 0, 1); -} \ No newline at end of file +} diff --git a/stubs/git2.php b/stubs/git2.php new file mode 100644 index 0000000000..7b1229e428 --- /dev/null +++ b/stubs/git2.php @@ -0,0 +1,549 @@ + +--FILE-- +