Skip to content

Commit 4ef6d03

Browse files
committed
fix merge functions
1 parent f77bba3 commit 4ef6d03

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

merge.c

+14-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "php_git2.h"
22
#include "php_git2_priv.h"
33
#include "merge.h"
4+
45
/* {{{ proto resource git_merge_base(resource $repo, string $one, string $two)
56
*/
67
PHP_FUNCTION(git_merge_base)
@@ -202,24 +203,30 @@ PHP_FUNCTION(git_merge_trees)
202203
}
203204
/* }}} */
204205

205-
/* {{{ proto resource git_merge(resource $repo, long $their_heads_len, $opts)
206+
/* {{{ proto resource git_merge(resource $repo, array $their_heads, array $opts)
206207
*/
207208
PHP_FUNCTION(git_merge)
208209
{
209-
php_git2_t *result = NULL, *_repo = NULL;
210+
php_git2_t *result = NULL, *_repo = NULL, *_their_head = NULL;
210211
git_merge_result *out = NULL;
211-
zval *repo = NULL, *opts = NULL;
212+
zval *repo = NULL, *opts = NULL, *theirhead = NULL;
212213
git_merge_head *their_heads = NULL;
214+
git_merge_head *heads[1];
213215
long their_heads_len = 0;
214216
int error = 0;
217+
git_merge_opts options = GIT_MERGE_OPTS_INIT;
215218

216219
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
217-
"rl<git_merge_opts>", &repo, &their_heads_len, &opts) == FAILURE) {
220+
"rza", &repo, &theirhead, &opts) == FAILURE) {
218221
return;
219222
}
220-
223+
221224
ZEND_FETCH_RESOURCE(_repo, php_git2_t*, &repo, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
222-
error = git_merge(&out, PHP_GIT2_V(_repo, repository), &their_heads, their_heads_len, opts);
225+
ZEND_FETCH_RESOURCE(_their_head, php_git2_t*, &theirhead, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
226+
heads[0] = PHP_GIT2_V(_their_head, merge_head);
227+
options.merge_flags = GIT_MERGE_NO_FASTFORWARD;
228+
229+
error = git_merge(&out, PHP_GIT2_V(_repo, repository), heads, 1, &options);
223230
if (php_git2_check_error(error, "git_merge" TSRMLS_CC)) {
224231
RETURN_FALSE;
225232
}
@@ -289,7 +296,7 @@ PHP_FUNCTION(git_merge_result_fastforward_oid)
289296
RETURN_FALSE;
290297
}
291298
git_oid_fmt(buf, &out);
292-
RETURN_SRING(buf, 1);
299+
RETURN_STRING(buf, 1);
293300
}
294301
/* }}} */
295302

0 commit comments

Comments
 (0)