-
Notifications
You must be signed in to change notification settings - Fork 78
/
reset.c
52 lines (45 loc) · 1.65 KB
/
reset.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "php_git2.h"
#include "php_git2_priv.h"
#include "reset.h"
/* {{{ proto long git_reset(resource $repo, resource $target, $reset_type)
*/
PHP_FUNCTION(git_reset)
{
int result = 0;
zval *repo = NULL, *target = NULL;
php_git2_t *_repo = NULL, *_target = NULL;
long reset_type = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"rrl", &repo, &target, &reset_type) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(_repo, php_git2_t*, &repo, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
ZEND_FETCH_RESOURCE(_target, php_git2_t*, &target, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
result = git_reset(PHP_GIT2_V(_repo, repository), PHP_GIT2_V(_target, object), reset_type);
RETURN_LONG(result);
}
/* }}} */
/* {{{ proto long git_reset_default(resource $repo, resource $target, array $pathspecs)
*/
PHP_FUNCTION(git_reset_default)
{
int result = 0;
zval *repo = NULL, *target = NULL, *pathspecs = NULL, *array = NULL;
php_git2_t *_repo = NULL, *_target = NULL;
git_strarray _pathspecs = {0};
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"rra", &repo, &target, &pathspecs) == FAILURE) {
return;
}
if (zend_hash_num_elements(pathspecs) > 0) {
php_git2_array_to_strarray(&_pathspecs, pathspecs TSRMLS_CC);
}
ZEND_FETCH_RESOURCE(_repo, php_git2_t*, &repo, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
ZEND_FETCH_RESOURCE(_target, php_git2_t*, &target, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
result = git_reset_default(PHP_GIT2_V(_repo, repository), PHP_GIT2_V(_target, object), &_pathspecs);
if (zend_hash_num_elements(pathspecs) > 0) {
git_strarray_free(&array);
}
RETURN_LONG(result);
}
/* }}} */