@@ -44,8 +44,81 @@ zend_object_value php_git2_commit_new(zend_class_entry *ce TSRMLS_DC)
4444 return retval ;
4545}
4646
47+ /*
48+ {{{ proto: Git2\Commit::getMessage()
49+ */
50+ PHP_METHOD (git2_commit , getMessage )
51+ {
52+ char * data ;
53+ php_git2_commit * m_commit ;
54+
55+ m_commit = PHP_GIT2_GET_OBJECT (php_git2_commit , getThis ());
56+
57+ if (m_commit != NULL ) {
58+ if (m_commit -> commit == NULL ) {
59+ RETURN_FALSE ;
60+ }
61+
62+ RETURN_STRING (git_commit_message (m_commit -> commit ),1 );
63+ } else {
64+ RETURN_FALSE ;
65+ }
66+ }
67+ /* }}} */
68+
69+ /*
70+ {{{ proto: Git2\Commit::getMessageEncoding()
71+ */
72+ PHP_METHOD (git2_commit , getMessageEncoding )
73+ {
74+ char * encoding ;
75+ php_git2_commit * m_commit ;
76+
77+ m_commit = PHP_GIT2_GET_OBJECT (php_git2_commit , getThis ());
78+
79+ if (m_commit != NULL ) {
80+ if (m_commit -> commit == NULL ) {
81+ RETURN_FALSE ;
82+ }
83+
84+ encoding = git_commit_message_encoding (m_commit -> commit );
85+ if (encoding != NULL ) {
86+ RETURN_STRING (encoding ,1 );
87+ } else {
88+ RETURN_STRING ("UTF-8" ,1 );
89+ }
90+ }
91+ RETURN_FALSE ;
92+ }
93+ /* }}} */
94+
95+
96+ /*
97+ {{{ proto: Git2\Commit::parentCount()
98+ */
99+ PHP_METHOD (git2_commit , parentCount )
100+ {
101+ unsigned int parent_count = 0 ;
102+ php_git2_commit * m_commit ;
103+
104+ m_commit = PHP_GIT2_GET_OBJECT (php_git2_commit , getThis ());
105+
106+ if (m_commit != NULL ) {
107+ if (m_commit -> commit == NULL ) {
108+ RETURN_FALSE ;
109+ }
110+
111+ parent_count = git_commit_parentcount (m_commit -> commit );
112+ RETURN_LONG (parent_count );
113+ }
114+ RETURN_FALSE ;
115+ }
116+ /* }}} */
47117
48118static zend_function_entry php_git2_commit_methods [] = {
119+ PHP_ME (git2_commit , getMessage , NULL , ZEND_ACC_PUBLIC )
120+ PHP_ME (git2_commit , getMessageEncoding , NULL , ZEND_ACC_PUBLIC )
121+ PHP_ME (git2_commit , parentCount , NULL , ZEND_ACC_PUBLIC )
49122 {NULL ,NULL ,NULL }
50123};
51124
0 commit comments