@@ -44,6 +44,12 @@ zend_object_value php_git2_blob_new(zend_class_entry *ce TSRMLS_DC)
44
44
return retval ;
45
45
}
46
46
47
+ ZEND_BEGIN_ARG_INFO_EX (arginfo_git2_blob_create , 0 ,0 ,2 )
48
+ ZEND_ARG_INFO (0 , repository )
49
+ ZEND_ARG_INFO (0 , contents )
50
+ ZEND_END_ARG_INFO ()
51
+
52
+
47
53
48
54
/*
49
55
{{{ proto: Git2\Blob::__toString()
@@ -67,9 +73,43 @@ PHP_METHOD(git2_blob, __toString)
67
73
}
68
74
/* }}} */
69
75
76
+ /*
77
+ {{{ proto: Git2\Blob::create(Git2\Repository $repository, string $contents)
78
+ */
79
+ PHP_METHOD (git2_blob , create )
80
+ {
81
+ char * contents ;
82
+ int contents_len , error = 0 ;
83
+ zval * repository ;
84
+ php_git2_repository * m_repository ;
85
+ char oid_out [GIT_OID_HEXSZ ] = {0 };
86
+ git_oid oid ;
87
+
88
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
89
+ "Os" , & repository , git2_repository_class_entry , & contents , & contents_len ) == FAILURE ) {
90
+ return ;
91
+ }
92
+
93
+ m_repository = PHP_GIT2_GET_OBJECT (php_git2_repository , repository );
94
+
95
+ if (m_repository != NULL ) {
96
+ if (m_repository -> repository == NULL ) {
97
+ RETURN_FALSE ;
98
+ }
99
+
100
+ error = git_blob_create_frombuffer (& oid , m_repository -> repository , contents , contents_len );
101
+ git_oid_fmt (oid_out , & oid );
102
+ RETVAL_STRINGL (oid_out ,GIT_OID_HEXSZ ,1 );
103
+ } else {
104
+ RETURN_FALSE ;
105
+ }
106
+ }
107
+ /* }}} */
108
+
70
109
71
110
static zend_function_entry php_git2_blob_methods [] = {
72
- PHP_ME (git2_blob , __toString , NULL , ZEND_ACC_PUBLIC )
111
+ PHP_ME (git2_blob , __toString , NULL , ZEND_ACC_PUBLIC )
112
+ PHP_ME (git2_blob , create , arginfo_git2_blob_create , ZEND_ACC_PUBLIC | ZEND_ACC_STATIC )
73
113
{NULL ,NULL ,NULL }
74
114
};
75
115
0 commit comments