FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
php-git/revparse.c at develop · libgit2/php-git · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
libgit2
/
php-git
Public
Notifications
You must be signed in to change notification settings
Fork
76
Star
566
Code
Issues
31
Pull requests
5
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
php-git
/
revparse.c
Copy path
More file actions
More file actions
Latest commit
History
History
History
122 lines (103 loc) · 3.24 KB
Breadcrumbs
php-git
/
revparse.c
Copy path
File metadata and controls
122 lines (103 loc) · 3.24 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#include
"php_git2.h"
#include
"php_git2_priv.h"
#include
"revparse.h"
/* {{{ proto resource git_revparse_single(resource $repo, string $spec)
*/
PHP_FUNCTION
(
git_revparse_single
)
{
php_git2_t
*
result
=
NULL
,
*
_repo
=
NULL
;
git_object
*
out
=
NULL
;
zval
*
repo
=
NULL
;
char
*
spec
=
NULL
;
int
spec_len
=
0
,
error
=
0
;
if
(
zend_parse_parameters
(
ZEND_NUM_ARGS
()
TSRMLS_CC
,
"rs"
,
&
repo
,
&
spec
,
&
spec_len
)
==
FAILURE
) {
return
;
}
ZEND_FETCH_RESOURCE
(
_repo
,
php_git2_t
*
,
&
repo
,
-1
,
PHP_GIT2_RESOURCE_NAME
,
git2_resource_handle
);
error
=
git_revparse_single
(
&
out
,
PHP_GIT2_V
(
_repo
,
repository
),
spec
);
if
(
php_git2_check_error
(
error
,
"git_revparse_single"
TSRMLS_CC
)) {
RETURN_FALSE
;
}
if
(
php_git2_make_resource
(
&
result
,
PHP_GIT2_TYPE_OBJECT
,
out
,
0
TSRMLS_CC
)) {
RETURN_FALSE
;
}
ZVAL_RESOURCE
(
return_value
,
GIT2_RVAL_P
(
result
));
}
/* }}} */
/* {{{ proto array git_revparse_ext(resource $repo, string $spec)
*/
PHP_FUNCTION
(
git_revparse_ext
)
{
zval
*
array
,
*
a
,
*
b
;
php_git2_t
*
result
=
NULL
,
*
result2
=
NULL
;
git_object
*
object_out
=
NULL
;
git_reference
*
reference_out
=
NULL
;
zval
*
repo
=
NULL
;
php_git2_t
*
_repo
=
NULL
;
char
*
spec
=
NULL
;
int
spec_len
=
0
;
int
error
=
0
;
if
(
zend_parse_parameters
(
ZEND_NUM_ARGS
()
TSRMLS_CC
,
"rs"
,
&
repo
,
&
spec
,
&
spec_len
)
==
FAILURE
) {
return
;
}
ZEND_FETCH_RESOURCE
(
_repo
,
php_git2_t
*
,
&
repo
,
-1
,
PHP_GIT2_RESOURCE_NAME
,
git2_resource_handle
);
error
=
git_revparse_ext
(
&
object_out
,
&
reference_out
,
PHP_GIT2_V
(
_repo
,
repository
),
spec
);
if
(
php_git2_check_error
(
error
,
"git_revparse_ext"
TSRMLS_CC
)) {
RETURN_FALSE
;
}
MAKE_STD_ZVAL
(
array
);
MAKE_STD_ZVAL
(
a
);
MAKE_STD_ZVAL
(
b
);
if
(
php_git2_make_resource
(
&
result
,
PHP_GIT2_TYPE_OBJECT
,
object_out
,
0
TSRMLS_CC
)) {
RETURN_FALSE
;
}
ZVAL_RESOURCE
(
a
,
GIT2_RVAL_P
(
result
));
if
(
php_git2_make_resource
(
&
result2
,
PHP_GIT2_TYPE_REFERENCE
,
reference_out
,
0
TSRMLS_CC
)) {
RETURN_FALSE
;
}
ZVAL_RESOURCE
(
b
,
GIT2_RVAL_P
(
result2
));
array_init
(
array
);
add_next_index_zval
(
array
,
a
);
add_next_index_zval
(
array
,
b
);
RETURN_ZVAL
(
array
,
0
,
1
);
}
/* }}} */
/* {{{ proto array git_revparse(resource $repo, string $spec)
*/
PHP_FUNCTION
(
git_revparse
)
{
git_revspec
revspec
;
zval
*
repo
=
NULL
;
php_git2_t
*
_repo
=
NULL
,
*
_from
=
NULL
,
*
_to
=
NULL
;
zval
*
result
=
NULL
,
*
from
,
*
to
;
char
*
spec
=
NULL
;
int
spec_len
=
0
;
int
error
=
0
;
if
(
zend_parse_parameters
(
ZEND_NUM_ARGS
()
TSRMLS_CC
,
"rs"
,
&
repo
,
&
spec
,
&
spec_len
)
==
FAILURE
) {
return
;
}
ZEND_FETCH_RESOURCE
(
_repo
,
php_git2_t
*
,
&
repo
,
-1
,
PHP_GIT2_RESOURCE_NAME
,
git2_resource_handle
);
memset
(
&
revspec
,
'\0'
,
sizeof
(
revspec
));
error
=
git_revparse
(
&
revspec
,
PHP_GIT2_V
(
_repo
,
repository
),
spec
);
if
(
php_git2_check_error
(
error
,
"git_revparse"
TSRMLS_CC
)) {
RETURN_FALSE
;
}
MAKE_STD_ZVAL
(
result
);
if
(
php_git2_make_resource
(
&
_from
,
PHP_GIT2_TYPE_OBJECT
,
revspec
.
from
,
0
TSRMLS_CC
)) {
RETURN_FALSE
;
}
ZVAL_RESOURCE
(
from
,
GIT2_RVAL_P
(
_from
));
if
(
php_git2_make_resource
(
&
_to
,
PHP_GIT2_TYPE_OBJECT
,
revspec
.
to
,
0
TSRMLS_CC
)) {
RETURN_FALSE
;
}
ZVAL_RESOURCE
(
to
,
GIT2_RVAL_P
(
_to
));
array_init
(
result
);
add_assoc_zval_ex
(
result
,
ZEND_STRS
(
"from"
),
from
);
add_assoc_zval_ex
(
result
,
ZEND_STRS
(
"to"
),
to
);
add_assoc_long_ex
(
result
,
ZEND_STRS
(
"flags"
),
revspec
.
flags
);
RETURN_ZVAL
(
result
,
0
,
1
);
}
/* }}} */
Back
|
FazBrowse Home
|
New Git URL