|
2 | 2 | #include "php_git2_priv.h"
|
3 | 3 | #include "diff.h"
|
4 | 4 |
|
5 |
| -/* {{{ proto void git_diff_free(diff) |
6 |
| -*/ |
| 5 | +/* {{{ proto void git_diff_free(resource $diff) |
| 6 | + */ |
7 | 7 | PHP_FUNCTION(git_diff_free)
|
8 | 8 | {
|
| 9 | + zval *diff = NULL; |
| 10 | + php_git2_t *_diff = NULL; |
| 11 | + |
| 12 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |
| 13 | + "r", &diff) == FAILURE) { |
| 14 | + return; |
| 15 | + } |
| 16 | + |
| 17 | + ZEND_FETCH_RESOURCE(_diff, php_git2_t*, &diff, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); |
| 18 | + if (_diff->should_free_v) { |
| 19 | + git_diff_free(PHP_GIT2_V(_diff, diff)); |
| 20 | + }; |
| 21 | + zval_ptr_dtor(&diff); |
9 | 22 | }
|
| 23 | +/* }}} */ |
10 | 24 |
|
11 |
| -/* {{{ proto resource git_diff_tree_to_tree(repo, old_tree, new_tree, opts) |
12 |
| -*/ |
| 25 | + |
| 26 | +/* {{{ proto long git_diff_tree_to_tree(resource $repo, resource $old_tree, resource $new_tree, $opts) |
| 27 | + */ |
13 | 28 | PHP_FUNCTION(git_diff_tree_to_tree)
|
14 | 29 | {
|
| 30 | + int result = 0; |
| 31 | + git_diff *diff = NULL; |
| 32 | + zval *repo = NULL; |
| 33 | + php_git2_t *_repo = NULL; |
| 34 | + zval *old_tree = NULL; |
| 35 | + php_git2_t *_old_tree = NULL; |
| 36 | + zval *new_tree = NULL; |
| 37 | + php_git2_t *_new_tree = NULL; |
| 38 | + zval *opts = NULL; |
| 39 | + int error = 0; |
| 40 | + |
| 41 | + /* TODO(chobie): generate converter */ |
| 42 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |
| 43 | + "rrra", &repo, &old_tree, &new_tree, &opts) == FAILURE) { |
| 44 | + return; |
| 45 | + } |
| 46 | + |
| 47 | + ZEND_FETCH_RESOURCE(_repo, php_git2_t*, &repo, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); |
| 48 | + ZEND_FETCH_RESOURCE(_old_tree, php_git2_t*, &old_tree, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); |
| 49 | + ZEND_FETCH_RESOURCE(_new_tree, php_git2_t*, &new_tree, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); |
| 50 | + result = git_diff_tree_to_tree(&diff, PHP_GIT2_V(_repo, repository), PHP_GIT2_V(_old_tree, tree), PHP_GIT2_V(_new_tree, tree), opts); |
| 51 | + RETURN_LONG(result); |
15 | 52 | }
|
| 53 | +/* }}} */ |
16 | 54 |
|
17 |
| -/* {{{ proto resource git_diff_tree_to_index(repo, old_tree, index, opts) |
18 |
| -*/ |
| 55 | + |
| 56 | +/* {{{ proto long git_diff_tree_to_index(resource $repo, resource $old_tree, resource $index, $opts) |
| 57 | + */ |
19 | 58 | PHP_FUNCTION(git_diff_tree_to_index)
|
20 | 59 | {
|
| 60 | + int result = 0; |
| 61 | + git_diff *diff = NULL; |
| 62 | + zval *repo = NULL; |
| 63 | + php_git2_t *_repo = NULL; |
| 64 | + zval *old_tree = NULL; |
| 65 | + php_git2_t *_old_tree = NULL; |
| 66 | + zval *index = NULL; |
| 67 | + php_git2_t *_index = NULL; |
| 68 | + zval *opts = NULL; |
| 69 | + int error = 0; |
| 70 | + |
| 71 | + /* TODO(chobie): generate converter */ |
| 72 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |
| 73 | + "rrra", &repo, &old_tree, &index, &opts) == FAILURE) { |
| 74 | + return; |
| 75 | + } |
| 76 | + |
| 77 | + ZEND_FETCH_RESOURCE(_repo, php_git2_t*, &repo, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); |
| 78 | + ZEND_FETCH_RESOURCE(_old_tree, php_git2_t*, &old_tree, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); |
| 79 | + ZEND_FETCH_RESOURCE(_index, php_git2_t*, &index, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); |
| 80 | + result = git_diff_tree_to_index(&diff, PHP_GIT2_V(_repo, repository), PHP_GIT2_V(_old_tree, tree), PHP_GIT2_V(_index, index), opts); |
| 81 | + RETURN_LONG(result); |
21 | 82 | }
|
| 83 | +/* }}} */ |
22 | 84 |
|
23 |
| -/* {{{ proto resource git_diff_index_to_workdir(repo, index, opts) |
24 |
| -*/ |
| 85 | + |
| 86 | +/* {{{ proto long git_diff_index_to_workdir(resource $repo, resource $index, $opts) |
| 87 | + */ |
25 | 88 | PHP_FUNCTION(git_diff_index_to_workdir)
|
26 | 89 | {
|
| 90 | + int result = 0; |
| 91 | + git_diff *diff = NULL; |
| 92 | + zval *repo = NULL; |
| 93 | + php_git2_t *_repo = NULL; |
| 94 | + zval *index = NULL; |
| 95 | + php_git2_t *_index = NULL; |
| 96 | + zval *opts = NULL; |
| 97 | + int error = 0; |
| 98 | + |
| 99 | + /* TODO(chobie): generate converter */ |
| 100 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |
| 101 | + "rra", &repo, &index, &opts) == FAILURE) { |
| 102 | + return; |
| 103 | + } |
| 104 | + |
| 105 | + ZEND_FETCH_RESOURCE(_repo, php_git2_t*, &repo, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); |
| 106 | + ZEND_FETCH_RESOURCE(_index, php_git2_t*, &index, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); |
| 107 | + result = git_diff_index_to_workdir(&diff, PHP_GIT2_V(_repo, repository), PHP_GIT2_V(_index, index), opts); |
| 108 | + RETURN_LONG(result); |
27 | 109 | }
|
| 110 | +/* }}} */ |
28 | 111 |
|
29 |
| -/* {{{ proto resource git_diff_tree_to_workdir(repo, old_tree, opts) |
30 |
| -*/ |
| 112 | + |
| 113 | +/* {{{ proto long git_diff_tree_to_workdir(resource $repo, resource $old_tree, $opts) |
| 114 | + */ |
31 | 115 | PHP_FUNCTION(git_diff_tree_to_workdir)
|
32 | 116 | {
|
| 117 | + int result = 0; |
| 118 | + git_diff *diff = NULL; |
| 119 | + zval *repo = NULL; |
| 120 | + php_git2_t *_repo = NULL; |
| 121 | + zval *old_tree = NULL; |
| 122 | + php_git2_t *_old_tree = NULL; |
| 123 | + zval *opts = NULL; |
| 124 | + int error = 0; |
| 125 | + |
| 126 | + /* TODO(chobie): generate converter */ |
| 127 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |
| 128 | + "rra", &repo, &old_tree, &opts) == FAILURE) { |
| 129 | + return; |
| 130 | + } |
| 131 | + |
| 132 | + ZEND_FETCH_RESOURCE(_repo, php_git2_t*, &repo, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); |
| 133 | + ZEND_FETCH_RESOURCE(_old_tree, php_git2_t*, &old_tree, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); |
| 134 | + result = git_diff_tree_to_workdir(&diff, PHP_GIT2_V(_repo, repository), PHP_GIT2_V(_old_tree, tree), opts); |
| 135 | + RETURN_LONG(result); |
33 | 136 | }
|
| 137 | +/* }}} */ |
34 | 138 |
|
35 |
| -/* {{{ proto resource git_diff_tree_to_workdir_with_index(repo, old_tree, opts) |
36 |
| -*/ |
| 139 | + |
| 140 | +/* {{{ proto long git_diff_tree_to_workdir_with_index(resource $repo, resource $old_tree, $opts) |
| 141 | + */ |
37 | 142 | PHP_FUNCTION(git_diff_tree_to_workdir_with_index)
|
38 | 143 | {
|
| 144 | + int result = 0; |
| 145 | + git_diff *diff = NULL; |
| 146 | + zval *repo = NULL; |
| 147 | + php_git2_t *_repo = NULL; |
| 148 | + zval *old_tree = NULL; |
| 149 | + php_git2_t *_old_tree = NULL; |
| 150 | + zval *opts = NULL; |
| 151 | + int error = 0; |
| 152 | + |
| 153 | + /* TODO(chobie): generate converter */ |
| 154 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |
| 155 | + "rra", &repo, &old_tree, &opts) == FAILURE) { |
| 156 | + return; |
| 157 | + } |
| 158 | + |
| 159 | + ZEND_FETCH_RESOURCE(_repo, php_git2_t*, &repo, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); |
| 160 | + ZEND_FETCH_RESOURCE(_old_tree, php_git2_t*, &old_tree, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); |
| 161 | + result = git_diff_tree_to_workdir_with_index(&diff, PHP_GIT2_V(_repo, repository), PHP_GIT2_V(_old_tree, tree), opts); |
| 162 | + RETURN_LONG(result); |
39 | 163 | }
|
| 164 | +/* }}} */ |
40 | 165 |
|
41 |
| -/* {{{ proto long git_diff_merge(onto, from) |
42 |
| -*/ |
| 166 | + |
| 167 | +/* {{{ proto long git_diff_merge(resource $onto, resource $from) |
| 168 | + */ |
43 | 169 | PHP_FUNCTION(git_diff_merge)
|
44 | 170 | {
|
| 171 | + int result = 0; |
| 172 | + zval *onto = NULL; |
| 173 | + php_git2_t *_onto = NULL; |
| 174 | + zval *from = NULL; |
| 175 | + php_git2_t *_from = NULL; |
| 176 | + int error = 0; |
| 177 | + |
| 178 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |
| 179 | + "rr", &onto, &from) == FAILURE) { |
| 180 | + return; |
| 181 | + } |
| 182 | + |
| 183 | + ZEND_FETCH_RESOURCE(_onto, php_git2_t*, &onto, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); |
| 184 | + ZEND_FETCH_RESOURCE(_from, php_git2_t*, &from, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); |
| 185 | + result = git_diff_merge(PHP_GIT2_V(_onto, diff), PHP_GIT2_V(_from, diff)); |
| 186 | + RETURN_LONG(result); |
45 | 187 | }
|
| 188 | +/* }}} */ |
46 | 189 |
|
47 |
| -/* {{{ proto long git_diff_find_similar(diff, options) |
48 |
| -*/ |
| 190 | + |
| 191 | +/* {{{ proto long git_diff_find_similar(resource $diff, $options) |
| 192 | + */ |
49 | 193 | PHP_FUNCTION(git_diff_find_similar)
|
50 | 194 | {
|
| 195 | + int result = 0; |
| 196 | + zval *diff = NULL; |
| 197 | + php_git2_t *_diff = NULL; |
| 198 | + zval *options = NULL; |
| 199 | + int error = 0; |
| 200 | + |
| 201 | + /* TODO(chobie): generate converter */ |
| 202 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |
| 203 | + "ra", &diff, &options) == FAILURE) { |
| 204 | + return; |
| 205 | + } |
| 206 | + |
| 207 | + ZEND_FETCH_RESOURCE(_diff, php_git2_t*, &diff, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); |
| 208 | + result = git_diff_find_similar(PHP_GIT2_V(_diff, diff), options); |
| 209 | + RETURN_LONG(result); |
51 | 210 | }
|
| 211 | +/* }}} */ |
52 | 212 |
|
53 |
| -/* {{{ proto long git_diff_options_init(options, version) |
54 |
| -*/ |
| 213 | + |
| 214 | +/* {{{ proto long git_diff_options_init( $options, long $version) |
| 215 | + */ |
55 | 216 | PHP_FUNCTION(git_diff_options_init)
|
56 | 217 | {
|
| 218 | + int result = 0; |
| 219 | + zval *options = NULL; |
| 220 | + long version = 0; |
| 221 | + int error = 0; |
| 222 | + |
| 223 | + /* TODO(chobie): generate converter */ |
| 224 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |
| 225 | + "al", &options, &version) == FAILURE) { |
| 226 | + return; |
| 227 | + } |
| 228 | + |
| 229 | + result = git_diff_options_init(options, version); |
| 230 | + RETURN_LONG(result); |
57 | 231 | }
|
| 232 | +/* }}} */ |
58 | 233 |
|
59 |
| -/* {{{ proto resource git_diff_num_deltas(diff) |
60 |
| -*/ |
| 234 | + |
| 235 | +/* {{{ proto long git_diff_num_deltas(resource $diff) |
| 236 | + */ |
61 | 237 | PHP_FUNCTION(git_diff_num_deltas)
|
62 | 238 | {
|
| 239 | + size_t result = 0; |
| 240 | + zval *diff = NULL; |
| 241 | + php_git2_t *_diff = NULL; |
| 242 | + |
| 243 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |
| 244 | + "r", &diff) == FAILURE) { |
| 245 | + return; |
| 246 | + } |
| 247 | + |
| 248 | + ZEND_FETCH_RESOURCE(_diff, php_git2_t*, &diff, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); |
| 249 | + result = git_diff_num_deltas(PHP_GIT2_V(_diff, diff)); |
| 250 | + RETURN_LONG(result); |
63 | 251 | }
|
| 252 | +/* }}} */ |
64 | 253 |
|
65 |
| -/* {{{ proto resource git_diff_num_deltas_of_type(diff, type) |
66 |
| -*/ |
| 254 | + |
| 255 | +/* {{{ proto long git_diff_num_deltas_of_type(resource $diff, $type) |
| 256 | + */ |
67 | 257 | PHP_FUNCTION(git_diff_num_deltas_of_type)
|
68 | 258 | {
|
| 259 | + size_t result = 0; |
| 260 | + zval *diff = NULL; |
| 261 | + php_git2_t *_diff = NULL; |
| 262 | + long type = 0; |
| 263 | + |
| 264 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |
| 265 | + "rl", &diff, &type) == FAILURE) { |
| 266 | + return; |
| 267 | + } |
| 268 | + |
| 269 | + ZEND_FETCH_RESOURCE(_diff, php_git2_t*, &diff, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); |
| 270 | + result = git_diff_num_deltas_of_type(PHP_GIT2_V(_diff, diff), type); |
| 271 | + RETURN_LONG(result); |
69 | 272 | }
|
| 273 | +/* }}} */ |
70 | 274 |
|
71 |
| -/* {{{ proto resource git_diff_get_delta(diff, idx) |
72 |
| -*/ |
| 275 | + |
| 276 | +/* {{{ proto resource git_diff_get_delta(resource $diff, long $idx) |
| 277 | + */ |
73 | 278 | PHP_FUNCTION(git_diff_get_delta)
|
74 | 279 | {
|
| 280 | + const git_diff_delta *result = NULL; |
| 281 | + zval *diff = NULL; |
| 282 | + php_git2_t *_diff = NULL; |
| 283 | + long idx = 0; |
| 284 | + |
| 285 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |
| 286 | + "rl", &diff, &idx) == FAILURE) { |
| 287 | + return; |
| 288 | + } |
| 289 | + |
| 290 | + ZEND_FETCH_RESOURCE(_diff, php_git2_t*, &diff, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); |
| 291 | + result = git_diff_get_delta(PHP_GIT2_V(_diff, diff), idx); |
| 292 | + /* TODO(chobie): implement this */ |
75 | 293 | }
|
| 294 | +/* }}} */ |
76 | 295 |
|
77 |
| -/* {{{ proto long git_diff_is_sorted_icase(diff) |
78 |
| -*/ |
| 296 | + |
| 297 | +/* {{{ proto long git_diff_is_sorted_icase(resource $diff) |
| 298 | + */ |
79 | 299 | PHP_FUNCTION(git_diff_is_sorted_icase)
|
80 | 300 | {
|
| 301 | + int result = 0; |
| 302 | + zval *diff = NULL; |
| 303 | + php_git2_t *_diff = NULL; |
| 304 | + int error = 0; |
| 305 | + |
| 306 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |
| 307 | + "r", &diff) == FAILURE) { |
| 308 | + return; |
| 309 | + } |
| 310 | + |
| 311 | + ZEND_FETCH_RESOURCE(_diff, php_git2_t*, &diff, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); |
| 312 | + result = git_diff_is_sorted_icase(PHP_GIT2_V(_diff, diff)); |
| 313 | + RETURN_BOOL(result); |
81 | 314 | }
|
| 315 | +/* }}} */ |
| 316 | + |
82 | 317 |
|
83 | 318 | /* {{{ proto long git_diff_foreach(diff, file_cb, hunk_cb, line_cb, payload)
|
84 | 319 | */
|
|
0 commit comments