Skip to content

Commit 00cc5cf

Browse files
committed
[push] add stubs
1 parent 07f5b41 commit 00cc5cf

File tree

6 files changed

+323
-1
lines changed

6 files changed

+323
-1
lines changed

config.m4

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ PHP_ARG_ENABLE(git2-debug, for git2 debug support,
77
if test $PHP_GIT2 != "no"; then
88
PHP_SUBST(GIT2_SHARED_LIBADD)
99

10-
PHP_NEW_EXTENSION(git2, php_git2.c repository.c commit.c tree.c clone.c blob.c helper.c revwalk.c treebuilder.c reference.c g_config.c object.c index.c revparse.c branch.c tag.c status.c cred.c remote.c transport.c diff.c checkout.c filter.c ignore.c indexer.c pathspec.c patch.c merge.c note.c odb.c reflog.c blame.c packbuilder.c stash.c signature.c attr.c reset.c message.c submodule.c giterr.c, $ext_shared)
10+
PHP_NEW_EXTENSION(git2, php_git2.c repository.c commit.c tree.c clone.c blob.c helper.c revwalk.c treebuilder.c reference.c g_config.c object.c index.c revparse.c branch.c tag.c status.c cred.c remote.c transport.c diff.c checkout.c filter.c ignore.c indexer.c pathspec.c patch.c merge.c note.c odb.c reflog.c blame.c packbuilder.c stash.c signature.c attr.c reset.c message.c submodule.c giterr.c push.c, $ext_shared)
1111
PHP_ADD_INCLUDE([$ext_srcdir/libgit2/include])
1212

1313
# for now

ng.php

+1
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ public function shouldResource(Arg $arg)
392392
"git_blame",
393393
"git_packbuilder",
394394
"git_submodule",
395+
"git_push",
395396
);
396397
}
397398

php_git2.c

+15
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
#include "submodule.h"
6464
#include "attr.h"
6565
#include "giterr.h"
66+
#include "push.h"
6667

6768
int git2_resource_handle;
6869

@@ -263,6 +264,8 @@ int php_git2_make_resource(php_git2_t **out, enum php_git2_resource_type type, v
263264
case PHP_GIT2_TYPE_SUBMODULE:
264265
PHP_GIT2_V(result, submodule) = (git_submodule*)resource;
265266
break;
267+
case PHP_GIT2_TYPE_PUSH:
268+
PHP_GIT2_V(result, push) = (git_push*)resource;
266269
default:
267270
php_error_docref(NULL TSRMLS_CC, E_ERROR, "passed resource type does not support. probably bug.");
268271
}
@@ -896,6 +899,18 @@ static zend_function_entry php_git2_functions[] = {
896899
PHP_FE(giterr_set_str, arginfo_giterr_set_str)
897900
PHP_FE(giterr_set_oom, arginfo_giterr_set_oom)
898901

902+
/* push */
903+
PHP_FE(git_push_new, arginfo_git_push_new)
904+
PHP_FE(git_push_set_options, arginfo_git_push_set_options)
905+
PHP_FE(git_push_set_callbacks, arginfo_git_push_set_callbacks)
906+
PHP_FE(git_push_add_refspec, arginfo_git_push_add_refspec)
907+
PHP_FE(git_push_update_tips, arginfo_git_push_update_tips)
908+
PHP_FE(git_push_finish, arginfo_git_push_finish)
909+
PHP_FE(git_push_unpack_ok, arginfo_git_push_unpack_ok)
910+
PHP_FE(git_push_status_foreach, arginfo_git_push_status_foreach)
911+
PHP_FE(git_push_free, arginfo_git_push_free)
912+
913+
899914
/* misc */
900915
PHP_FE(git_resource_type, arginfo_git_resource_type)
901916
PHP_FE_END

php_git2.h

+2
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ enum php_git2_resource_type {
123123
PHP_GIT2_TYPE_BLAME,
124124
PHP_GIT2_TYPE_PACKBUILDER,
125125
PHP_GIT2_TYPE_SUBMODULE,
126+
PHP_GIT2_TYPE_PUSH,
126127
};
127128

128129
typedef struct php_git2_t {
@@ -173,6 +174,7 @@ typedef struct php_git2_t {
173174
git_blame *blame;
174175
git_packbuilder *packbuilder;
175176
git_submodule *submodule;
177+
git_push *push;
176178
} v;
177179
int should_free_v;
178180
int resource_id;

push.c

+193
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
#include "php_git2.h"
2+
#include "php_git2_priv.h"
3+
#include "push.h"
4+
5+
/* {{{ proto resource git_push_new(resource $remote)
6+
*/
7+
PHP_FUNCTION(git_push_new)
8+
{
9+
php_git2_t *result = NULL, *_remote = NULL;
10+
git_push *out = NULL;
11+
zval *remote = NULL;
12+
int error = 0;
13+
14+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
15+
"r", &remote) == FAILURE) {
16+
return;
17+
}
18+
19+
ZEND_FETCH_RESOURCE(_remote, php_git2_t*, &remote, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
20+
error = git_push_new(&out, PHP_GIT2_V(_remote, remote));
21+
if (php_git2_check_error(error, "git_push_new" TSRMLS_CC)) {
22+
RETURN_FALSE;
23+
}
24+
if (php_git2_make_resource(&result, PHP_GIT2_TYPE_PUSH, out, 1 TSRMLS_CC)) {
25+
RETURN_FALSE;
26+
}
27+
ZVAL_RESOURCE(return_value, GIT2_RVAL_P(result));
28+
}
29+
/* }}} */
30+
31+
/* {{{ proto long git_push_set_options(resource $push, $opts)
32+
*/
33+
PHP_FUNCTION(git_push_set_options)
34+
{
35+
int result = 0, error = 0;
36+
zval *push = NULL, *opts = NULL;
37+
php_git2_t *_push = NULL;
38+
39+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
40+
"r<git_push_options>", &push, &opts) == FAILURE) {
41+
return;
42+
}
43+
44+
ZEND_FETCH_RESOURCE(_push, php_git2_t*, &push, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
45+
//result = git_push_set_options(PHP_GIT2_V(_push, push), opts);
46+
RETURN_LONG(result);
47+
}
48+
/* }}} */
49+
50+
/* {{{ proto long git_push_set_callbacks(resource $push, $pack_progress_cb, $pack_progress_cb_payload, $transfer_progress_cb, $transfer_progress_cb_payload)
51+
*/
52+
PHP_FUNCTION(git_push_set_callbacks)
53+
{
54+
int result = 0, error = 0;
55+
zval *push = NULL, *pack_progress_cb = NULL, *pack_progress_cb_payload = NULL, *transfer_progress_cb = NULL, *transfer_progress_cb_payload = NULL;
56+
php_git2_t *_push = NULL;
57+
zend_fcall_info fci = empty_fcall_info;
58+
zend_fcall_info_cache fcc = empty_fcall_info_cache;
59+
php_git2_cb_t *cb = NULL;
60+
61+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
62+
"rfz<git_push_transfer_progress>z", &push, &fci, &fcc, &pack_progress_cb_payload, &transfer_progress_cb, &transfer_progress_cb_payload) == FAILURE) {
63+
return;
64+
}
65+
66+
ZEND_FETCH_RESOURCE(_push, php_git2_t*, &push, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
67+
// if (php_git2_cb_init(&cb, &fci, &fcc, payload TSRMLS_CC)) {
68+
// RETURN_FALSE;
69+
// }
70+
//result = git_push_set_callbacks(PHP_GIT2_V(_push, push), <CHANGEME>, cb, transfer_progress_cb, cb);
71+
php_git2_cb_free(cb);
72+
RETURN_LONG(result);
73+
}
74+
/* }}} */
75+
76+
/* {{{ proto long git_push_add_refspec(resource $push, string $refspec)
77+
*/
78+
PHP_FUNCTION(git_push_add_refspec)
79+
{
80+
int result = 0, refspec_len = 0, error = 0;
81+
zval *push = NULL;
82+
php_git2_t *_push = NULL;
83+
char *refspec = NULL;
84+
85+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
86+
"rs", &push, &refspec, &refspec_len) == FAILURE) {
87+
return;
88+
}
89+
90+
ZEND_FETCH_RESOURCE(_push, php_git2_t*, &push, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
91+
result = git_push_add_refspec(PHP_GIT2_V(_push, push), refspec);
92+
RETURN_LONG(result);
93+
}
94+
/* }}} */
95+
96+
/* {{{ proto long git_push_update_tips(resource $push)
97+
*/
98+
PHP_FUNCTION(git_push_update_tips)
99+
{
100+
int result = 0, error = 0;
101+
zval *push = NULL;
102+
php_git2_t *_push = NULL;
103+
104+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
105+
"r", &push) == FAILURE) {
106+
return;
107+
}
108+
109+
ZEND_FETCH_RESOURCE(_push, php_git2_t*, &push, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
110+
result = git_push_update_tips(PHP_GIT2_V(_push, push));
111+
RETURN_LONG(result);
112+
}
113+
/* }}} */
114+
115+
/* {{{ proto long git_push_finish(resource $push)
116+
*/
117+
PHP_FUNCTION(git_push_finish)
118+
{
119+
int result = 0, error = 0;
120+
zval *push = NULL;
121+
php_git2_t *_push = NULL;
122+
123+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
124+
"r", &push) == FAILURE) {
125+
return;
126+
}
127+
128+
ZEND_FETCH_RESOURCE(_push, php_git2_t*, &push, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
129+
result = git_push_finish(PHP_GIT2_V(_push, push));
130+
RETURN_LONG(result);
131+
}
132+
/* }}} */
133+
134+
/* {{{ proto long git_push_unpack_ok(resource $push)
135+
*/
136+
PHP_FUNCTION(git_push_unpack_ok)
137+
{
138+
int result = 0, error = 0;
139+
zval *push = NULL;
140+
php_git2_t *_push = NULL;
141+
142+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
143+
"r", &push) == FAILURE) {
144+
return;
145+
}
146+
147+
ZEND_FETCH_RESOURCE(_push, php_git2_t*, &push, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
148+
result = git_push_unpack_ok(PHP_GIT2_V(_push, push));
149+
RETURN_LONG(result);
150+
}
151+
/* }}} */
152+
153+
/* {{{ proto long git_push_status_foreach(resource $push, string $ref, string $msg, $data), $data)
154+
*/
155+
PHP_FUNCTION(git_push_status_foreach)
156+
{
157+
int result = 0, ref_len = 0, msg_len = 0, error = 0;
158+
zval *push = NULL;
159+
php_git2_t *_push = NULL;
160+
char *ref = NULL, *msg = NULL;
161+
162+
// if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
163+
// "rss<void><void>", &push, &ref, &ref_len, &msg, &msg_len, &data, &data) == FAILURE) {
164+
// return;
165+
// }
166+
167+
ZEND_FETCH_RESOURCE(_push, php_git2_t*, &push, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
168+
//result = git_push_status_foreach(PHP_GIT2_V(_push, push), ref, msg, data);
169+
RETURN_LONG(result);
170+
}
171+
/* }}} */
172+
173+
/* {{{ proto void git_push_free(resource $push)
174+
*/
175+
PHP_FUNCTION(git_push_free)
176+
{
177+
zval *push = NULL;
178+
php_git2_t *_push = NULL;
179+
180+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
181+
"r", &push) == FAILURE) {
182+
return;
183+
}
184+
185+
ZEND_FETCH_RESOURCE(_push, php_git2_t*, &push, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
186+
if (GIT2_SHOULD_FREE(_push)) {
187+
git_push_free(PHP_GIT2_V(_push, push));
188+
GIT2_SHOULD_FREE(_push) = 0;
189+
};
190+
zval_ptr_dtor(&push);
191+
}
192+
/* }}} */
193+

push.h

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/*
2+
* PHP Libgit2 Extension
3+
*
4+
* https://github.com/libgit2/php-git
5+
*
6+
* Copyright 2014 Shuhei Tanuma. All rights reserved.
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
#ifndef PHP_GIT2_PUSH_H
27+
#define PHP_GIT2_PUSH_H
28+
29+
ZEND_BEGIN_ARG_INFO_EX(arginfo_git_push_new, 0, 0, 1)
30+
ZEND_ARG_INFO(0, remote)
31+
ZEND_END_ARG_INFO()
32+
33+
ZEND_BEGIN_ARG_INFO_EX(arginfo_git_push_set_options, 0, 0, 2)
34+
ZEND_ARG_INFO(0, push)
35+
ZEND_ARG_INFO(0, opts)
36+
ZEND_END_ARG_INFO()
37+
38+
ZEND_BEGIN_ARG_INFO_EX(arginfo_git_push_set_callbacks, 0, 0, 5)
39+
ZEND_ARG_INFO(0, push)
40+
ZEND_ARG_INFO(0, pack_progress_cb)
41+
ZEND_ARG_INFO(0, pack_progress_cb_payload)
42+
ZEND_ARG_INFO(0, transfer_progress_cb)
43+
ZEND_ARG_INFO(0, transfer_progress_cb_payload)
44+
ZEND_END_ARG_INFO()
45+
46+
ZEND_BEGIN_ARG_INFO_EX(arginfo_git_push_add_refspec, 0, 0, 2)
47+
ZEND_ARG_INFO(0, push)
48+
ZEND_ARG_INFO(0, refspec)
49+
ZEND_END_ARG_INFO()
50+
51+
ZEND_BEGIN_ARG_INFO_EX(arginfo_git_push_update_tips, 0, 0, 1)
52+
ZEND_ARG_INFO(0, push)
53+
ZEND_END_ARG_INFO()
54+
55+
ZEND_BEGIN_ARG_INFO_EX(arginfo_git_push_finish, 0, 0, 1)
56+
ZEND_ARG_INFO(0, push)
57+
ZEND_END_ARG_INFO()
58+
59+
ZEND_BEGIN_ARG_INFO_EX(arginfo_git_push_unpack_ok, 0, 0, 1)
60+
ZEND_ARG_INFO(0, push)
61+
ZEND_END_ARG_INFO()
62+
63+
ZEND_BEGIN_ARG_INFO_EX(arginfo_git_push_status_foreach, 0, 0, 5)
64+
ZEND_ARG_INFO(0, push)
65+
ZEND_ARG_INFO(0, ref)
66+
ZEND_ARG_INFO(0, msg)
67+
ZEND_ARG_INFO(0, data)
68+
ZEND_ARG_INFO(0, data)
69+
ZEND_END_ARG_INFO()
70+
71+
ZEND_BEGIN_ARG_INFO_EX(arginfo_git_push_free, 0, 0, 1)
72+
ZEND_ARG_INFO(0, push)
73+
ZEND_END_ARG_INFO()
74+
75+
/* {{{ proto resource git_push_new(remote)
76+
*/
77+
PHP_FUNCTION(git_push_new);
78+
79+
/* {{{ proto long git_push_set_options(push, opts)
80+
*/
81+
PHP_FUNCTION(git_push_set_options);
82+
83+
/* {{{ proto long git_push_set_callbacks(push, pack_progress_cb, pack_progress_cb_payload, transfer_progress_cb, transfer_progress_cb_payload)
84+
*/
85+
PHP_FUNCTION(git_push_set_callbacks);
86+
87+
/* {{{ proto long git_push_add_refspec(push, refspec)
88+
*/
89+
PHP_FUNCTION(git_push_add_refspec);
90+
91+
/* {{{ proto long git_push_update_tips(push)
92+
*/
93+
PHP_FUNCTION(git_push_update_tips);
94+
95+
/* {{{ proto long git_push_finish(push)
96+
*/
97+
PHP_FUNCTION(git_push_finish);
98+
99+
/* {{{ proto long git_push_unpack_ok(push)
100+
*/
101+
PHP_FUNCTION(git_push_unpack_ok);
102+
103+
/* {{{ proto long git_push_status_foreach(push, ref, msg, data), data)
104+
*/
105+
PHP_FUNCTION(git_push_status_foreach);
106+
107+
/* {{{ proto void git_push_free(push)
108+
*/
109+
PHP_FUNCTION(git_push_free);
110+
111+
#endif

0 commit comments

Comments
 (0)