|
2 | 2 | #include "php_git2_priv.h"
|
3 | 3 | #include "stash.h"
|
4 | 4 |
|
| 5 | +static int php_git2_stash_cb(size_t index, |
| 6 | + const char* message, |
| 7 | + const git_oid *stash_id, |
| 8 | + void *payload) |
| 9 | +{ |
| 10 | + php_git2_t *result; |
| 11 | + zval *param_index, *param_message,*param_stash_id, *retval_ptr = NULL; |
| 12 | + php_git2_cb_t *p = (php_git2_cb_t*)payload; |
| 13 | + int i = 0; |
| 14 | + long retval = 0; |
| 15 | + char _oid[41] = {0}; |
| 16 | + GIT2_TSRMLS_SET(p->tsrm_ls) |
| 17 | + |
| 18 | + git_oid_fmt(_oid, stash_id); |
| 19 | + |
| 20 | + Z_ADDREF_P(p->payload); |
| 21 | + MAKE_STD_ZVAL(param_index); |
| 22 | + MAKE_STD_ZVAL(param_message); |
| 23 | + MAKE_STD_ZVAL(param_stash_id); |
| 24 | + ZVAL_LONG(param_index, index); |
| 25 | + ZVAL_STRING(param_message, message, 1); |
| 26 | + ZVAL_STRING(param_stash_id, _oid, 1); |
| 27 | + |
| 28 | + if (php_git2_call_function_v(p->fci, p->fcc TSRMLS_CC, &retval_ptr, 4, ¶m_index, ¶m_message, ¶m_stash_id, &p->payload)) { |
| 29 | + return GIT_EUSER; |
| 30 | + } |
| 31 | + |
| 32 | + retval = Z_LVAL_P(retval_ptr); |
| 33 | + zval_ptr_dtor(&retval_ptr); |
| 34 | + return retval; |
| 35 | +} |
| 36 | + |
5 | 37 | /* {{{ proto resource git_stash_save(resource $repo, array $stasher, string $message, long $flags)
|
6 | 38 | */
|
7 | 39 | PHP_FUNCTION(git_stash_save)
|
@@ -49,7 +81,7 @@ PHP_FUNCTION(git_stash_foreach)
|
49 | 81 | if (php_git2_cb_init(&cb, &fci, &fcc, payload TSRMLS_CC)) {
|
50 | 82 | RETURN_FALSE;
|
51 | 83 | }
|
52 |
| - //result = git_stash_foreach(PHP_GIT2_V(_repo, repository), <CHANGEME>, cb); |
| 84 | + result = git_stash_foreach(PHP_GIT2_V(_repo, repository), php_git2_stash_cb, cb); |
53 | 85 | php_git2_cb_free(cb);
|
54 | 86 | RETURN_LONG(result);
|
55 | 87 | }
|
|
0 commit comments