Skip to content

Commit bd04439

Browse files
committed
[blob] add git_blob_create_frombuffer test
1 parent bd4b046 commit bd04439

16 files changed

+41
-34
lines changed

blob.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@ PHP_FUNCTION(git_blob_create_frombuffer)
1212
int buffer_len;
1313
int error;
1414
git_oid id;
15-
char out[41] = {0};
15+
char out[GIT2_OID_HEXSIZE] = {0};
1616

1717
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
1818
"rs", &repository, &buffer, &buffer_len) == FAILURE) {
1919
return;
2020
}
2121

2222
ZEND_FETCH_RESOURCE(git2, php_git2_t*, &repository, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
23-
2423
error = git_blob_create_frombuffer(&id, PHP_GIT2_V(git2, repository), buffer, buffer_len);
2524
if (php_git2_check_error(error, "git_blob_create_frombuffer" TSRMLS_CC)) {
2625
RETURN_FALSE
@@ -46,7 +45,7 @@ PHP_FUNCTION(git_blob_create_fromdisk)
4645
int path_len;
4746
int error;
4847
git_oid id;
49-
char out[41] = {0};
48+
char out[GIT2_OID_HEXSIZE] = {0};
5049

5150
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
5251
"rs", &repository, &path, &path_len) == FAILURE) {
@@ -74,7 +73,7 @@ PHP_FUNCTION(git_blob_create_fromworkdir)
7473
int path_len;
7574
int error;
7675
git_oid id;
77-
char out[41] = {0};
76+
char out[GIT2_OID_HEXSIZE] = {0};
7877

7978
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
8079
"rs", &repository, &path, &path_len) == FAILURE) {
@@ -124,7 +123,7 @@ PHP_FUNCTION(git_blob_id)
124123
{
125124
zval *blob;
126125
php_git2_t *git2;
127-
char out[41] = {0};
126+
char out[GIT2_OID_HEXSIZE] = {0};
128127
const git_oid *id;
129128

130129
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,

commit.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ PHP_FUNCTION(git_commit_id)
121121
{
122122
zval *commit;
123123
php_git2_t *_commit;
124-
char out[41] = {0};
124+
char out[GIT2_OID_HEXSIZE] = {0};
125125
const git_oid *id;
126126

127127
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
@@ -293,7 +293,7 @@ PHP_FUNCTION(git_commit_tree_id)
293293
{
294294
zval *commit;
295295
php_git2_t *_commit;
296-
char out[41] = {0};
296+
char out[GIT2_OID_HEXSIZE] = {0};
297297
const git_oid *id;
298298

299299
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
@@ -362,7 +362,7 @@ PHP_FUNCTION(git_commit_parent_id)
362362
php_git2_t *_commit;
363363
long n;
364364
git_oid *oid;
365-
char out[41] = {0};
365+
char out[GIT2_OID_HEXSIZE] = {0};
366366

367367
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
368368
"rl", &commit, &n) == FAILURE) {
@@ -417,7 +417,7 @@ PHP_FUNCTION(git_commit_create)
417417
int update_ref_len, message_encoding_len, message_len, parent_count = 0, error = 0, i;
418418
php_git2_t *_repo, *_author, *_committer, *_tree;
419419
git_signature __author, __committer;
420-
char out[41] = {0};
420+
char out[GIT2_OID_HEXSIZE] = {0};
421421
git_oid oid;
422422
const git_commit **__parents = NULL;
423423
HashPosition pos;

filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ PHP_FUNCTION(git_filter_source_id)
308308
const git_oid *result = NULL;
309309
zval *src = NULL;
310310
php_git2_t *_src = NULL;
311-
char __result[41] = {0};
311+
char __result[GIT2_OID_HEXSIZE] = {0};
312312

313313
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
314314
"r", &src) == FAILURE) {

index.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static int php_git2_array_to_index_entry(git_index_entry *entry, zval *array TSR
3535
static void php_git2_index_entry_to_array(const git_index_entry *entry, zval **result TSRMLS_DC)
3636
{
3737
zval *tmp, *ctime, *mtime;
38-
char buf[41] = {0};
38+
char buf[GIT2_OID_HEXSIZE] = {0};
3939

4040
MAKE_STD_ZVAL(tmp);
4141
MAKE_STD_ZVAL(ctime);
@@ -283,7 +283,7 @@ PHP_FUNCTION(git_index_write_tree)
283283
php_git2_t *_index;
284284
int error = 0;
285285
git_oid id;
286-
char out[41] = {0};
286+
char out[GIT2_OID_HEXSIZE] = {0};
287287

288288
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
289289
"r", &index) == FAILURE) {
@@ -307,7 +307,7 @@ PHP_FUNCTION(git_index_write_tree_to)
307307
zval *repo;
308308
php_git2_t *_repo;
309309
git_oid id;
310-
char out[41]= {0};
310+
char out[GIT2_OID_HEXSIZE]= {0};
311311
int error = 0;
312312

313313
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,

merge.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ PHP_FUNCTION(git_merge_base)
1616
int two_len = 0;
1717
git_oid __two;
1818
int error = 0;
19-
char result[41] = {0};
19+
char result[GIT2_OID_HEXSIZE] = {0};
2020

2121
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
2222
"rss", &repo, &one, &one_len, &two, &two_len) == FAILURE) {
@@ -316,7 +316,7 @@ PHP_FUNCTION(git_merge_result_fastforward_oid)
316316
zval *merge_result = NULL;
317317
php_git2_t *_merge_result = NULL;
318318
int error = 0;
319-
char buffer[41] = {0};
319+
char buffer[GIT2_OID_HEXSIZE] = {0};
320320

321321
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
322322
"r", &merge_result) == FAILURE) {

ng.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ public function generateDeclarations(Printer $printer, Func $f)
519519
$printer->put("`type` error = 0;\n", "type", $f->getReturnType());
520520
}
521521
if (preg_match("/git_oid/", $f->getReturnType())) {
522-
$printer->put("char __result[41] = {0};\n");
522+
$printer->put("char __result[GIT2_OID_HEXSIZE] = {0};\n");
523523
}
524524
if (preg_match("/_owner$/", $f->getName())) {
525525
$printer->put("php_git2_t *__result = NULL;\n");

object.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ PHP_FUNCTION(git_object_id)
9898
zval *obj;
9999
php_git2_t *_obj;
100100
const git_oid *id;
101-
char buf[41] = {0};
101+
char buf[GIT2_OID_HEXSIZE] = {0};
102102

103103
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
104104
"r", &obj) == FAILURE) {

php_git2.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@
4848
#include "limits.h"
4949

5050
#include "git2.h"
51-
#include "git2/sys/filter.h"
51+
#include "git2/odb.h"
5252
#include "git2/odb_backend.h"
5353
#include "git2/trace.h"
54+
#include "git2/sys/filter.h"
5455

5556
#include "date/php_date.h"
5657

php_git2_priv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ do {\
5757
val->mutable = 0;\
5858
} while (0);\
5959

60+
#define GIT2_OID_HEXSIZE (GIT_OID_HEXSZ+1)
61+
6062
#include "helper.h"
6163

6264
#endif

reference.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ PHP_FUNCTION(git_reference_name_to_id)
4242
char *name = {0};
4343
int name_len;
4444
git_oid id;
45-
char out[41] = {0};
45+
char out[GIT2_OID_HEXSIZE] = {0};
4646
int error;
4747

4848
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
@@ -196,7 +196,7 @@ PHP_FUNCTION(git_reference_target_peel)
196196
zval *ref;
197197
php_git2_t *_ref;
198198
git_oid *oid;
199-
char out[41] = {0};
199+
char out[GIT2_OID_HEXSIZE] = {0};
200200

201201
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
202202
"r", &ref) == FAILURE) {

0 commit comments

Comments
 (0)