|
| 1 | +#include "php_git2.h" |
| 2 | +#include "php_git2_priv.h" |
| 3 | +#include "stash.h" |
| 4 | + |
| 5 | +/* {{{ proto resource git_stash_save(resource $repo, array $stasher, string $message, long $flags) |
| 6 | + */ |
| 7 | +PHP_FUNCTION(git_stash_save) |
| 8 | +{ |
| 9 | + php_git2_t *result = NULL, *_repo = NULL; |
| 10 | + git_oid out = {0}; |
| 11 | + zval *repo = NULL, *stasher = NULL; |
| 12 | + char *message = NULL; |
| 13 | + int message_len = 0, error = 0; |
| 14 | + long flags = 0; |
| 15 | + char buf[41] = {0}; |
| 16 | + |
| 17 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |
| 18 | + "rasl", &repo, &stasher, &message, &message_len, &flags) == FAILURE) { |
| 19 | + return; |
| 20 | + } |
| 21 | + |
| 22 | + ZEND_FETCH_RESOURCE(_repo, php_git2_t*, &repo, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); |
| 23 | + error = git_stash_save(&out, PHP_GIT2_V(_repo, repository), stasher, message, flags); |
| 24 | + if (php_git2_check_error(error, "git_stash_save" TSRMLS_CC)) { |
| 25 | + RETURN_FALSE; |
| 26 | + } |
| 27 | + git_oid_fmt(buf, &out); |
| 28 | + RETURN_STRING(buf, 1); |
| 29 | +} |
| 30 | +/* }}} */ |
| 31 | + |
| 32 | +/* {{{ proto long git_stash_foreach(resource $repo, Callable $callback, $payload) |
| 33 | + */ |
| 34 | +PHP_FUNCTION(git_stash_foreach) |
| 35 | +{ |
| 36 | + int result = 0, error = 0; |
| 37 | + zval *repo = NULL, *callback = NULL, *payload = NULL; |
| 38 | + php_git2_t *_repo = NULL; |
| 39 | + zend_fcall_info fci = empty_fcall_info; |
| 40 | + zend_fcall_info_cache fcc = empty_fcall_info_cache; |
| 41 | + php_git2_cb_t *cb = NULL; |
| 42 | + |
| 43 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |
| 44 | + "rfz", &repo, &fci, &fcc, &payload) == FAILURE) { |
| 45 | + return; |
| 46 | + } |
| 47 | + |
| 48 | + ZEND_FETCH_RESOURCE(_repo, php_git2_t*, &repo, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); |
| 49 | + if (php_git2_cb_init(&cb, &fci, &fcc, payload TSRMLS_CC)) { |
| 50 | + RETURN_FALSE; |
| 51 | + } |
| 52 | + //result = git_stash_foreach(PHP_GIT2_V(_repo, repository), <CHANGEME>, cb); |
| 53 | + php_git2_cb_free(cb); |
| 54 | + RETURN_LONG(result); |
| 55 | +} |
| 56 | +/* }}} */ |
| 57 | + |
| 58 | +/* {{{ proto long git_stash_drop(resource $repo, long $index) |
| 59 | + */ |
| 60 | +PHP_FUNCTION(git_stash_drop) |
| 61 | +{ |
| 62 | + int result = 0, error = 0; |
| 63 | + zval *repo = NULL; |
| 64 | + php_git2_t *_repo = NULL; |
| 65 | + long index = 0; |
| 66 | + |
| 67 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |
| 68 | + "rl", &repo, &index) == FAILURE) { |
| 69 | + return; |
| 70 | + } |
| 71 | + |
| 72 | + ZEND_FETCH_RESOURCE(_repo, php_git2_t*, &repo, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); |
| 73 | + result = git_stash_drop(PHP_GIT2_V(_repo, repository), index); |
| 74 | + RETURN_LONG(result); |
| 75 | +} |
| 76 | +/* }}} */ |
| 77 | + |
0 commit comments