Skip to content

Commit c9d9fb4

Browse files
committed
added exception when calling Git2\Commit::create
1 parent 0878e22 commit c9d9fb4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

commit.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ PHP_METHOD(git2_commit, create)
223223
if (zend_hash_find(hash,"author",sizeof("author"),(void **)&value_pp) != FAILURE) {
224224
z_author = *value_pp;
225225
m_author = PHP_GIT2_GET_OBJECT(php_git2_signature,z_author);
226+
} else {
227+
zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC,"key 'author' required");
228+
return;
226229
}
227230

228231
if (zend_hash_find(hash,"committer",sizeof("committer"),(void **)&value_pp) != FAILURE) {
@@ -243,6 +246,9 @@ PHP_METHOD(git2_commit, create)
243246
m_tree = PHP_GIT2_GET_OBJECT(php_git2_tree, z_tree);
244247
tree = m_tree->tree;
245248
}
249+
} else {
250+
zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC,"key 'tree' required");
251+
return;
246252
}
247253

248254
if (zend_hash_find(hash,"parents",sizeof("parents"),(void **)&value_pp) != FAILURE) {
@@ -259,6 +265,9 @@ PHP_METHOD(git2_commit, create)
259265

260266
if (zend_hash_find(hash,"message",sizeof("message"),(void **)&value_pp) != FAILURE) {
261267
message = Z_STRVAL_PP(value_pp);
268+
} else {
269+
zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC,"key 'message' required");
270+
return;
262271
}
263272

264273
if (zend_hash_find(hash,"encoding",sizeof("encoding"),(void **)&value_pp) != FAILURE) {

0 commit comments

Comments
 (0)