-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathignore.c
81 lines (64 loc) · 1.84 KB
/
ignore.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include "php_git2.h"
#include "php_git2_priv.h"
#include "ignore.h"
/* {{{ proto long git_ignore_add_rule(resource $repo, string $rules)
*/
PHP_FUNCTION(git_ignore_add_rule)
{
int result;
zval *repo = NULL;
php_git2_t *_repo = NULL;
char *rules = NULL;
size_t rules_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"rs", &repo, &rules, &rules_len) == FAILURE) {
return;
}
if ((_repo = (php_git2_t *) zend_fetch_resource(Z_RES_P(repo), PHP_GIT2_RESOURCE_NAME, git2_resource_handle)) == NULL) {
RETURN_FALSE;
}
result = git_ignore_add_rule(PHP_GIT2_V(_repo, repository), rules);
RETURN_LONG(result);
}
/* }}} */
/* {{{ proto long git_ignore_clear_internal_rules(resource $repo)
*/
PHP_FUNCTION(git_ignore_clear_internal_rules)
{
int result;
zval *repo = NULL;
php_git2_t *_repo = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"r", &repo) == FAILURE) {
return;
}
if ((_repo = (php_git2_t *) zend_fetch_resource(Z_RES_P(repo), PHP_GIT2_RESOURCE_NAME, git2_resource_handle)) == NULL) {
RETURN_FALSE;
}
result = git_ignore_clear_internal_rules(PHP_GIT2_V(_repo, repository));
RETURN_LONG(result);
}
/* }}} */
/* {{{ proto long git_ignore_path_is_ignored(resource $repo, string $path)
*/
PHP_FUNCTION(git_ignore_path_is_ignored)
{
int ignored = 0, error;
zval *repo = NULL;
php_git2_t *_repo = NULL;
char *path = NULL;
size_t path_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"rs", &repo, &path, &path_len) == FAILURE) {
return;
}
if ((_repo = (php_git2_t *) zend_fetch_resource(Z_RES_P(repo), PHP_GIT2_RESOURCE_NAME, git2_resource_handle)) == NULL) {
RETURN_FALSE;
}
error = git_ignore_path_is_ignored(&ignored, PHP_GIT2_V(_repo, repository), path);
if (php_git2_check_error(error, "git_ignore_path_is_ignored" TSRMLS_CC)) {
RETURN_FALSE;
}
RETURN_BOOL(ignored);
}
/* }}} */