Skip to content

Commit 20ebb68

Browse files
committed
add message
1 parent 323f805 commit 20ebb68

File tree

4 files changed

+70
-1
lines changed

4 files changed

+70
-1
lines changed

config.m4

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ PHP_ARG_ENABLE(git2-debug, for git2 debug support,
77
if test $PHP_GIT2 != "no"; then
88
PHP_SUBST(GIT2_SHARED_LIBADD)
99

10-
PHP_NEW_EXTENSION(git2, php_git2.c repository.c commit.c tree.c clone.c blob.c helper.c revwalk.c treebuilder.c reference.c g_config.c object.c index.c revparse.c branch.c tag.c status.c cred.c remote.c transport.c diff.c checkout.c filter.c ignore.c indexer.c pathspec.c patch.c merge.c note.c odb.c reflog.c blame.c packbuilder.c stash.c signature.c reset.c, $ext_shared)
10+
PHP_NEW_EXTENSION(git2, php_git2.c repository.c commit.c tree.c clone.c blob.c helper.c revwalk.c treebuilder.c reference.c g_config.c object.c index.c revparse.c branch.c tag.c status.c cred.c remote.c transport.c diff.c checkout.c filter.c ignore.c indexer.c pathspec.c patch.c merge.c note.c odb.c reflog.c blame.c packbuilder.c stash.c signature.c reset.c message.c, $ext_shared)
1111
PHP_ADD_INCLUDE([$ext_srcdir/libgit2/include])
1212

1313
# for now

message.c

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include "php_git2.h"
2+
#include "php_git2_priv.h"
3+
#include "message.h"
4+
5+
/* {{{ proto resource git_message_prettify(long $out_size, string $message, long $strip_comments)
6+
*/
7+
PHP_FUNCTION(git_message_prettify)
8+
{
9+
php_git2_t *result = NULL;
10+
char out = NULL, *message = NULL;
11+
long out_size = 0, strip_comments = 0;
12+
int message_len = 0, error = 0;
13+
14+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
15+
"lsl", &out_size, &message, &message_len, &strip_comments) == FAILURE) {
16+
return;
17+
}
18+
19+
error = git_message_prettify(&out, out_size, message, strip_comments);
20+
if (php_git2_check_error(error, "git_message_prettify" TSRMLS_CC)) {
21+
RETURN_FALSE;
22+
}
23+
RETURN_STRING(out, 1);
24+
}
25+
/* }}} */
26+

message.h

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* PHP Libgit2 Extension
3+
*
4+
* https://github.com/libgit2/php-git
5+
*
6+
* Copyright 2014 Shuhei Tanuma. All rights reserved.
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
#ifndef PHP_GIT2_MESSAGE_H
27+
#define PHP_GIT2_MESSAGE_H
28+
29+
ZEND_BEGIN_ARG_INFO_EX(arginfo_git_message_prettify, 0, 0, 3)
30+
ZEND_ARG_INFO(0, out_size)
31+
ZEND_ARG_INFO(0, message)
32+
ZEND_ARG_INFO(0, strip_comments)
33+
ZEND_END_ARG_INFO()
34+
35+
/* {{{ proto resource git_message_prettify(out_size, message, strip_comments)
36+
*/
37+
PHP_FUNCTION(git_message_prettify);
38+
39+
#endif

php_git2.c

+4
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
#include "stash.h"
6060
#include "signature.h"
6161
#include "reset.h"
62+
#include "message.h"
6263

6364
int git2_resource_handle;
6465

@@ -809,6 +810,9 @@ static zend_function_entry php_git2_functions[] = {
809810
PHP_FE(git_reset, arginfo_git_reset)
810811
PHP_FE(git_reset_default, arginfo_git_reset_default)
811812

813+
/* message */
814+
PHP_FE(git_message_prettify, arginfo_git_message_prettify)
815+
812816
/* misc */
813817
PHP_FE(git_resource_type, arginfo_git_resource_type)
814818
PHP_FE_END

0 commit comments

Comments
 (0)