Skip to content

Commit 43480aa

Browse files
committed
focusing Lord of Diffstruction.
1 parent d2228fe commit 43480aa

12 files changed

Lines changed: 29 additions & 74 deletions

File tree

backend.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ static int php_git2_backend_exists(git_odb_backend *_backend, const git_oid *oid
4444
zend_call_method_with_1_params(&m_backend->self, Z_OBJCE_P(m_backend->self), NULL, "exists", &retval, param);
4545

4646
if (Z_BVAL_P(retval)) {
47-
result = GIT_SUCCESS;
47+
result = GIT_OK;
4848
}
4949

5050
zval_ptr_dtor(&param);
5151
zval_ptr_dtor(&retval);
5252

53-
return (result == GIT_SUCCESS);
53+
return (result == GIT_OK);
5454
}
5555

5656
static int php_git2_backend_write(git_oid *id, git_odb_backend *_backend, const void *buffer, size_t size, git_otype type)
@@ -81,7 +81,7 @@ static int php_git2_backend_write(git_oid *id, git_odb_backend *_backend, const
8181
zval_ptr_dtor(&z_type);
8282

8383
if (Z_TYPE_P(retval) == IS_BOOL && Z_BVAL_P(retval)) {
84-
error = GIT_SUCCESS;
84+
error = GIT_OK;
8585
}
8686
zval_ptr_dtor(&retval);
8787

commit.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ PHP_METHOD(git2_commit, getParents)
392392
zval *tmp = NULL;
393393

394394
error = git_commit_parent(&parent, m_commit->commit, i);
395-
if (error == GIT_SUCCESS) {
395+
if (error == GIT_OK) {
396396
tmp = php_git2_object_new(git_object_owner((git_object *)m_commit->commit), parent TSRMLS_CC);
397397
add_next_index_zval(result, tmp);
398398
}
@@ -438,7 +438,7 @@ PHP_METHOD(git2_commit, getParent)
438438
}
439439

440440
error = git_commit_parent(&parent, m_commit->commit, (unsigned int)index);
441-
if (error == GIT_SUCCESS) {
441+
if (error == GIT_OK) {
442442
result = php_git2_object_new(git_object_owner((git_object *)m_commit->commit), parent TSRMLS_CC);
443443
RETVAL_ZVAL(result,0,1);
444444
}

config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ static int php_git2_config_foreach(const char *var_name, const char *value, void
257257
}
258258
efree(tmp_value);
259259

260-
return GIT_SUCCESS;
260+
return GIT_OK;
261261
}
262262

263263
static int php_git2_config_reload(zval *object, unsigned short dtor TSRMLS_DC)

odb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ PHP_METHOD(git2_odb, exists)
156156

157157
m_odb = PHP_GIT2_GET_OBJECT(php_git2_odb, getThis());
158158

159-
if (git_oid_fromstr(&id, hash) != GIT_SUCCESS) {
159+
if (git_oid_fromstr(&id, hash) != GIT_OK) {
160160
RETURN_FALSE;
161161
}
162162

@@ -188,7 +188,7 @@ PHP_METHOD(git2_odb, read)
188188
}
189189

190190
m_odb = PHP_GIT2_GET_OBJECT(php_git2_odb, getThis());
191-
if (git_oid_fromstr(&id, hash) != GIT_SUCCESS) {
191+
if (git_oid_fromstr(&id, hash) != GIT_OK) {
192192
RETURN_FALSE;
193193
}
194194

php_git2.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
# include "ext/spl/spl_exceptions.h"
3838
# include <date/php_date.h>
3939
# include <git2.h>
40+
# include <git2/errors.h>
4041
# include <git2/odb_backend.h>
4142

4243
extern zend_module_entry git2_module_entry;

reference.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ static int php_git2_ref_foreach_cb(const char *name, void *opaque)
223223

224224
}
225225

226-
return GIT_SUCCESS;
226+
return GIT_OK;
227227
}
228228

229229
/*

remote.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,14 @@ PHP_METHOD(git2_remote, __construct)
7373
m_repository = PHP_GIT2_GET_OBJECT(php_git2_repository, repository);
7474
m_remote = PHP_GIT2_GET_OBJECT(php_git2_remote, getThis());
7575
if (git_remote_valid_url(path)) {
76-
error = git_remote_new(
76+
/* TODO
77+
error = git_remote_new(
7778
&remote,
7879
m_repository->repository,
7980
path,
8081
NULL
8182
);
83+
*/
8284
} else {
8385
error = git_remote_load(&remote,m_repository->repository, path);
8486
}
@@ -96,14 +98,14 @@ static int php_git2_rename_packfile(char *packname, git_indexer *idx)
9698
slash = strrchr(path, '/');
9799

98100
if (!slash) {
99-
return GIT_EINVALIDARGS;
101+
return -1;
100102
}
101103

102104
memset(oid, 0x0, sizeof(oid));
103105
git_oid_fmt(oid, git_indexer_hash(idx));
104106
ret = sprintf(slash + 1, "pack-%s.pack", oid);
105107
if(ret < 0) {
106-
return GIT_EOSERR;
108+
return -2;
107109
}
108110

109111
return rename(packname, path);
@@ -114,7 +116,7 @@ static int show_ref__cb(git_remote_head *head, void *payload)
114116
char oid[GIT_OID_HEXSZ + 1] = {0};
115117
git_oid_fmt(oid, &head->oid);
116118
printf("%s\t%s\n", oid, head->name);
117-
return GIT_SUCCESS;
119+
return GIT_OK;
118120
}
119121

120122
/*
@@ -141,7 +143,7 @@ PHP_METHOD(git2_remote, fetch)
141143

142144
error = git_remote_connect(m_remote->remote, direction);
143145
error = git_remote_ls(m_remote->remote, &show_ref__cb, NULL);
144-
error = git_remote_download(&packname, m_remote->remote);
146+
//error = git_remote_download(&packname, m_remote->remote);
145147

146148
if (packname != NULL) {
147149
// Create a new instance indexer
@@ -158,7 +160,7 @@ PHP_METHOD(git2_remote, fetch)
158160
PHP_GIT2_EXCEPTION_CHECK(error);
159161
}
160162

161-
error = git_remote_update_tips(m_remote->remote);
163+
//error = git_remote_update_tips(m_remote->remote);
162164
PHP_GIT2_EXCEPTION_CHECK(error);
163165

164166
free(packname);

repository.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ PHP_METHOD(git2_repository, init)
234234
}
235235

236236
ret = git_repository_init(&repository, path, is_bare);
237-
if (ret == GIT_SUCCESS) {
237+
if (ret == GIT_OK) {
238238
zval *object;
239239

240240
MAKE_STD_ZVAL(object);
@@ -310,7 +310,7 @@ PHP_METHOD(git2_repository, discover)
310310
return;
311311
}
312312

313-
if (git_repository_discover(path_buffer,path_size,(const char *)start_path,(int)across_fs, (const char *)ceiling_dirs) == GIT_SUCCESS) {
313+
if (git_repository_discover(path_buffer,path_size,(const char *)start_path,(int)across_fs, (const char *)ceiling_dirs) == GIT_OK) {
314314
RETVAL_STRING(path_buffer, 1);
315315
} else {
316316
RETURN_FALSE;
@@ -338,7 +338,7 @@ PHP_METHOD(git2_repository, exists)
338338
error = git_repository_odb(&odb, m_repository->repository);
339339
PHP_GIT2_EXCEPTION_CHECK(error);
340340

341-
if (git_oid_fromstr(&id, hash) != GIT_SUCCESS) {
341+
if (git_oid_fromstr(&id, hash) != GIT_OK) {
342342
RETURN_FALSE;
343343
}
344344

@@ -374,7 +374,7 @@ PHP_METHOD(git2_repository, lookup)
374374
error = git_repository_odb(&odb, m_repository->repository);
375375
PHP_GIT2_EXCEPTION_CHECK(error);
376376

377-
if (git_oid_fromstrn(&id, hash, hash_len) != GIT_SUCCESS) {
377+
if (git_oid_fromstrn(&id, hash, hash_len) != GIT_OK) {
378378
RETURN_FALSE;
379379
}
380380

tag.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ PHP_METHOD(git2_tag, getTarget)
5757
m_tag = PHP_GIT2_GET_OBJECT(php_git2_tag, getThis());
5858

5959
error = git_tag_target(&object, m_tag->tag);
60-
if (error == GIT_SUCCESS) {
60+
if (error == GIT_OK) {
6161
result = php_git2_object_new((git_repository*)git_object_owner((git_object*)m_tag->tag), object TSRMLS_CC);
6262
RETVAL_ZVAL(result,0,1);
6363
}

tree.c

Lines changed: 3 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@ zend_object_value php_git2_tree_new(zend_class_entry *ce TSRMLS_DC)
4747
return retval;
4848
}
4949

50-
ZEND_BEGIN_ARG_INFO_EX(arginfo_git2_tree_diff, 0,0,2)
51-
ZEND_ARG_INFO(0, old)
52-
ZEND_ARG_INFO(0, new)
53-
ZEND_END_ARG_INFO()
54-
5550
ZEND_BEGIN_ARG_INFO_EX(arginfo_git2_tree_get_subtree, 0,0,1)
5651
ZEND_ARG_INFO(0, path)
5752
ZEND_END_ARG_INFO()
@@ -60,49 +55,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_git2_tree_get_entry_by_name, 0,0,1)
6055
ZEND_ARG_INFO(0, path)
6156
ZEND_END_ARG_INFO()
6257

63-
64-
static int php_git2_tree_diff_cb(const git_tree_diff_data *ptr, void *data)
65-
{
66-
/*
67-
typedef struct {
68-
unsigned int old_attr;
69-
unsigned int new_attr;
70-
git_oid old_oid;
71-
git_oid new_oid;
72-
git_status_t status;
73-
const char *path;
74-
} git_tree_diff_data;
75-
*/
76-
fprintf(stderr,"path:%s\n",ptr->path);
77-
}
7858

79-
typedef struct{
80-
zval *old;
81-
zval *new;
82-
zval *result;
83-
} php_git2_tree_diff_cb_t;
84-
/*
85-
{{{ proto: Git2\Tree::diff($old, $new)
86-
@todo: think this behavior
87-
*/
88-
PHP_METHOD(git2_tree, diff)
89-
{
90-
zval *old, *new;
91-
php_git2_tree *m_old, *m_new;
92-
php_git2_tree_diff_cb_t payload;
93-
94-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
95-
"OO", &old, git2_tree_class_entry, &new, git2_tree_class_entry) == FAILURE) {
96-
return;
97-
}
98-
99-
m_old = PHP_GIT2_GET_OBJECT(php_git2_tree, old);
100-
m_new = PHP_GIT2_GET_OBJECT(php_git2_tree, new);
101-
102-
git_tree_diff(m_old->tree,m_new->tree, &php_git2_tree_diff_cb, &payload);
103-
}
104-
/* }}} */
105-
10659

10760
/* Iterator Implementation */
10861

@@ -224,7 +177,7 @@ static int get_subtree(git_tree **result, git_tree *root, char *path)
224177
git_tree_entry_id(entry)
225178
);
226179

227-
if (error == GIT_SUCCESS) {
180+
if (error == GIT_OK) {
228181
target = tmp_result;
229182
} else {
230183
return -1;
@@ -243,7 +196,7 @@ static int get_subtree(git_tree **result, git_tree *root, char *path)
243196
git_object_id((const git_object *)entry)
244197
);
245198

246-
if (error == GIT_SUCCESS) {
199+
if (error == GIT_OK) {
247200
target = tmp_result;
248201
} else {
249202
return -1;
@@ -288,7 +241,7 @@ PHP_METHOD(git2_tree, getSubtree)
288241
* this method returns specified subtree or false.
289242
*/
290243
error = get_subtree(&subtree, object->tree, path);
291-
if (error == GIT_SUCCESS) {
244+
if (error == GIT_OK) {
292245
zval *result;
293246

294247
result = php_git2_object_new(git_object_owner((git_object *)object->tree), (git_object *)subtree TSRMLS_CC);
@@ -331,7 +284,6 @@ PHP_METHOD(git2_tree, getEntryByName)
331284

332285

333286
static zend_function_entry php_git2_tree_methods[] = {
334-
PHP_ME(git2_tree, diff, arginfo_git2_tree_diff, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
335287
/* Iterator Implementation */
336288
PHP_ME(git2_tree, current, NULL, ZEND_ACC_PUBLIC)
337289
PHP_ME(git2_tree, key, NULL, ZEND_ACC_PUBLIC)

0 commit comments

Comments
 (0)