-
Notifications
You must be signed in to change notification settings - Fork 78
/
push.c
239 lines (204 loc) · 6.37 KB
/
push.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
#include "php_git2.h"
#include "php_git2_priv.h"
#include "push.h"
static int php_git2_push_status_foreach_cb(const char *ref, const char *msg, void *data)
{
php_git2_t *result;
zval *param_ref, *param_msg, *retval_ptr = NULL;
php_git2_cb_t *p = (php_git2_cb_t*)data;
int retval = 0;
GIT2_TSRMLS_SET(p->tsrm_ls)
Z_ADDREF_P(p->payload);
MAKE_STD_ZVAL(param_ref);
MAKE_STD_ZVAL(param_msg);
ZVAL_NULL(param_ref);
ZVAL_NULL(param_msg);
if (ref != NULL) {
ZVAL_STRING(param_ref, ref, 1);
}
if (msg != NULL) {
ZVAL_STRING(param_msg, msg, 1);
}
if (php_git2_call_function_v(p->fci, p->fcc TSRMLS_CC, &retval_ptr, 3, ¶m_ref, ¶m_msg, &p->payload)) {
zend_list_delete(result->resource_id);
return GIT_EUSER;
}
retval = Z_LVAL_P(retval_ptr);
zval_ptr_dtor(&retval_ptr);
return retval;
}
/* {{{ proto resource git_push_new(resource $remote)
*/
PHP_FUNCTION(git_push_new)
{
php_git2_t *result = NULL, *_remote = NULL;
git_push *out = NULL;
zval *remote = NULL;
int error = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"r", &remote) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(_remote, php_git2_t*, &remote, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
error = git_push_new(&out, PHP_GIT2_V(_remote, remote));
if (php_git2_check_error(error, "git_push_new" TSRMLS_CC)) {
RETURN_FALSE;
}
if (php_git2_make_resource(&result, PHP_GIT2_TYPE_PUSH, out, 1 TSRMLS_CC)) {
RETURN_FALSE;
}
ZVAL_RESOURCE(return_value, GIT2_RVAL_P(result));
}
/* }}} */
/* {{{ proto long git_push_set_options(resource $push, $opts)
*/
PHP_FUNCTION(git_push_set_options)
{
int result = 0;
zval *push = NULL, *opts = NULL;
php_git2_t *_push = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"r<git_push_options>", &push, &opts) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(_push, php_git2_t*, &push, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
//result = git_push_set_options(PHP_GIT2_V(_push, push), opts);
RETURN_LONG(result);
}
/* }}} */
/* {{{ proto long git_push_set_callbacks(resource $push, $pack_progress_cb, $pack_progress_cb_payload, $transfer_progress_cb, $transfer_progress_cb_payload)
*/
PHP_FUNCTION(git_push_set_callbacks)
{
int result = 0;
zval *push = NULL, *pack_progress_cb_payload = NULL, *transfer_progress_cb_payload = NULL;
php_git2_t *_push = NULL;
zend_fcall_info pack_fci = empty_fcall_info;
zend_fcall_info_cache pack_fcc = empty_fcall_info_cache;
zend_fcall_info transfer_fci = empty_fcall_info;
zend_fcall_info_cache transfer_fcc = empty_fcall_info_cache;
php_git2_cb_t *pack_cb = NULL;
php_git2_cb_t *transfer_cb = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"rfzfz", &push, &pack_fci, &pack_fcc, &pack_progress_cb_payload, &transfer_fci, &transfer_fcc, &transfer_progress_cb_payload) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(_push, php_git2_t*, &push, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
if (php_git2_cb_init(&pack_cb, &pack_fci, &pack_fcc, pack_progress_cb_payload TSRMLS_CC)) {
RETURN_FALSE;
}
if (php_git2_cb_init(&transfer_cb, &transfer_fci, &transfer_fcc, transfer_progress_cb_payload TSRMLS_CC)) {
RETURN_FALSE;
}
result = git_push_set_callbacks(PHP_GIT2_V(_push, push), NULL, pack_cb, NULL, transfer_cb);
php_git2_cb_free(pack_cb);
php_git2_cb_free(transfer_cb);
RETURN_LONG(result);
}
/* }}} */
/* {{{ proto long git_push_add_refspec(resource $push, string $refspec)
*/
PHP_FUNCTION(git_push_add_refspec)
{
int result = 0, refspec_len = 0;
zval *push = NULL;
php_git2_t *_push = NULL;
char *refspec = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"rs", &push, &refspec, &refspec_len) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(_push, php_git2_t*, &push, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
result = git_push_add_refspec(PHP_GIT2_V(_push, push), refspec);
RETURN_LONG(result);
}
/* }}} */
/* {{{ proto long git_push_update_tips(resource $push)
*/
PHP_FUNCTION(git_push_update_tips)
{
int result = 0;
zval *push = NULL;
php_git2_t *_push = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"r", &push) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(_push, php_git2_t*, &push, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
result = git_push_update_tips(PHP_GIT2_V(_push, push));
RETURN_LONG(result);
}
/* }}} */
/* {{{ proto long git_push_finish(resource $push)
*/
PHP_FUNCTION(git_push_finish)
{
int result = 0;
zval *push = NULL;
php_git2_t *_push = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"r", &push) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(_push, php_git2_t*, &push, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
result = git_push_finish(PHP_GIT2_V(_push, push));
RETURN_LONG(result);
}
/* }}} */
/* {{{ proto long git_push_unpack_ok(resource $push)
*/
PHP_FUNCTION(git_push_unpack_ok)
{
int result = 0;
zval *push = NULL;
php_git2_t *_push = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"r", &push) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(_push, php_git2_t*, &push, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
result = git_push_unpack_ok(PHP_GIT2_V(_push, push));
RETURN_LONG(result);
}
/* }}} */
/* {{{ proto long git_push_status_foreach(resource $push, Callable callback, mixed $payload)
*/
PHP_FUNCTION(git_push_status_foreach)
{
int result = 0;
zval *push = NULL, *payload = NULL;
php_git2_t *_push = NULL;
zend_fcall_info fci = empty_fcall_info;
zend_fcall_info_cache fcc = empty_fcall_info_cache;
php_git2_cb_t *cb = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"rfz", &push, &fci, &fcc, &payload) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(_push, php_git2_t*, &push, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
if (php_git2_cb_init(&cb, &fci, &fcc, payload TSRMLS_CC)) {
RETURN_FALSE;
}
result = git_push_status_foreach(PHP_GIT2_V(_push, push), php_git2_push_status_foreach_cb, cb);
php_git2_cb_free(cb);
RETURN_LONG(result);
}
/* }}} */
/* {{{ proto void git_push_free(resource $push)
*/
PHP_FUNCTION(git_push_free)
{
zval *push = NULL;
php_git2_t *_push = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"r", &push) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(_push, php_git2_t*, &push, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
if (GIT2_SHOULD_FREE(_push)) {
git_push_free(PHP_GIT2_V(_push, push));
GIT2_SHOULD_FREE(_push) = 0;
};
zval_ptr_dtor(&push);
}
/* }}} */