Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git_commit_create: allow NULL parameter for update_ref #76

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,14 +409,14 @@ PHP_FUNCTION(git_commit_nth_gen_ancestor)
/* }}} */

/* {{{ proto resource git_commit_create(
resource $repo, string $update_ref, array $author, array $committer,
resource $repo, mixed $update_ref, array $author, array $committer,
string $message_encoding, string $message, resource $tree, array $parents)
*/
PHP_FUNCTION(git_commit_create)
{
zval *repo, *tree, *parents, *committer, *author, **element;
char *update_ref = {0}, *message_encoding = {0}, *message = {0};
int update_ref_len, message_encoding_len, message_len, parent_count = 0, error = 0, i;
zval *repo, *tree, *parents, *committer, *author, *update_ref, **element;
char *message_encoding = {0}, *message = {0};
int message_encoding_len, message_len, parent_count = 0, error = 0, i;
php_git2_t *_repo, *_tree;
git_signature __author, __committer;
char out[GIT2_OID_HEXSIZE] = {0};
Expand All @@ -425,12 +425,19 @@ PHP_FUNCTION(git_commit_create)
HashPosition pos;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"rsaassra", &repo, &update_ref, &update_ref_len, &author,
"rzaassra", &repo, &update_ref, &author,
&committer, &message_encoding, &message_encoding_len, &message,
&message_len, &tree, &parents) == FAILURE) {
return;
}

/**
* Check update_ref type
*/
if(Z_TYPE_P(update_ref) != IS_STRING && Z_TYPE_P(update_ref) != IS_NULL) {
return;
}

memset(&__author, '\0', sizeof(git_signature));
memset(&__committer, '\0', sizeof(git_signature));

Expand Down Expand Up @@ -468,7 +475,7 @@ PHP_FUNCTION(git_commit_create)
error = git_commit_create(
&oid,
PHP_GIT2_V(_repo, repository),
update_ref,
Z_TYPE_P(update_ref) == IS_STRING ? Z_STRVAL_P(update_ref) : NULL,
&__author,
&__committer,
message_encoding,
Expand Down
2 changes: 1 addition & 1 deletion commit.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ PHP_FUNCTION(git_commit_parent_id);
PHP_FUNCTION(git_commit_nth_gen_ancestor);

/* {{{ proto resource git_commit_create(
resource $repo, string $update_ref, array $author, array $committer,
resource $repo, mixed $update_ref, array $author, array $committer,
string $message_encoding, string $message, resource $tree, array $parents)
*/
PHP_FUNCTION(git_commit_create);
Expand Down