Skip to content

Commit 1753bf9

Browse files
author
Shuhei Tanuma
committed
0.3.0-dev Merge functions branch into develop.
Sorry for big BC. throw away OOP related codes as to improve Maintainability. almost codes were generated by cli script. so please ignore compile warnings at this time. api docs: (see libgit2 api) http://libgit2.github.com/libgit2/#v0.20.0
2 parents f5b094f + 8953e58 commit 1753bf9

File tree

308 files changed

+25012
-8149
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

308 files changed

+25012
-8149
lines changed

.gitignore

+6-7
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
tmp/*
55

66
# ignore tests
7-
tests/*.php
8-
tests/*.sh
9-
tests/*.log
10-
tests/*.diff
11-
tests/*.exp
12-
tests/*.out
13-
tests/mock
7+
tests/*/*.php
8+
tests/*/*.sh
9+
tests/*/*.log
10+
tests/*/*.diff
11+
tests/*/*.exp
12+
tests/*/*.out
1413

1514
# ignore phpized files
1615
Makefile.global

.gitmodules

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[submodule "libgit2"]
22
path = libgit2
3-
url = https://github.com/libgit2/libgit2.git
3+
url = https://github.com/libgit2/libgit2.git
4+
ignore = dirty

README.md

+64-149
Original file line numberDiff line numberDiff line change
@@ -1,199 +1,114 @@
11
# PHP-Git2 - libgit2 bindings in PHP
22

3-
php-git2 is a PHP bindings to the libgit2 linkable C Git library.
4-
this extension are re-writing php-git as that code too dirty.
3+
php-git2 is a PHP bindings to the libgit2 linkable C Git library.
54

6-
# Latest Branch
5+
* API Documentation: http://libgit2.github.com/libgit2/#v0.20.0 (also see Signature conversions section)
6+
* IRC: #php-git on irc.freenode.net.
77

8-
v0.3.0 (switching to functions)
9-
https://github.com/libgit2/php-git/tree/functions
8+
## Status
109

11-
# Important Notice
10+
0.3.0 Alpha (switching to functions)
1211

13-
php-git changed it's API drastically. this changes doesn't care about compatibility between old one.
14-
please check tests cases.
12+
https://docs.google.com/spreadsheet/ccc?key=0AjvShWAWqvfHdDRneEtIUF9GRUZMNVVVR1hpdURiUWc&usp=sharing
1513

16-
# Installing And Running
14+
## How to build
1715

18-
you need to install libgit2 before make php-git.
16+
```
17+
# build libgit2.a
18+
git submodule init && git submodule update
19+
mkdir libgit2/build
20+
cd libgit2/build
21+
cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF -DBUILD_CLAR=OFF ..
22+
cmake --build .
1923
20-
````
21-
git clone https://github.com/libgit2/php-git.git --recursive
22-
cd php-git/libgit2
23-
mkdir build && cd build
24-
cmake ..
25-
cmake -DBUILD_SHARED_LIBS=OFF -build .
26-
make
24+
# build php-git2
2725
cd ../../
2826
phpize
29-
./configure
27+
./configure --enable-git2-debug
3028
make
3129
make install
32-
sudo make install
33-
# add `extension=git2.so` to your php.ini
34-
````
30+
# add extension=git2.so to your php.ini
31+
```
3532

36-
new php-git features almost tested.
33+
## For Contributors
3734

38-
# API
35+
##### Issue first.
3936

40-
## Repository Access
37+
please make a issue first. don't work before creating it.
4138

42-
````php
43-
$repo = new Git2\Repository($path);
44-
/*
45-
bool = $repo->exists(string sha1)
46-
Git2\Object = $repo->lookup(string sha1)
47-
string sha1 = $repo->hash(string content, long type)
48-
string sha1 = $repo->write(string content, long type)
49-
bool = $repo->isBare()
50-
bool = $repo->isEmpty()
51-
bool = $repo->headDetached()
52-
bool = $repo->headOrphan()
53-
string path = Git2\Repository::discover("/Users/chobie/projects/work/repo/lib/subdir");
54-
// => /Users/chobie/projects/work/repo/.git
39+
##### Coding Styles
5540

56-
Git2\Repository = Git2\Repository::init(string $path, bool isBare)
57-
*/
58-
````
41+
follow pecl coding standards (except 8 at this moment).
5942

60-
## Object Access
43+
* http://git.php.net/?p=php-src.git;a=blob_plain;f=CODING_STANDARDS;hb=HEAD
6144

62-
### create new blob
45+
##### Signature conversions
6346

6447
````
65-
$oid = Git2\Blob::create($repo, "Hello World");
66-
/*
67-
$blob = $repo->lookup($oid);
68-
int $blob->getSize();
69-
string $blob->getContent();
70-
*/
71-
````
48+
GIT_EXTERN(int) git_repository_init(
49+
git_repository **out,
50+
const char *path,
51+
unsigned is_bare);
7252
73-
## Tree Access
7453
75-
````
76-
$repo = new Git2\Repository($path);
77-
$tree = $repo->lookup(tree sha); // specify tree sha
78-
foreach ($tree as $oid => $entry) {
79-
/*
80-
bool $entry->isTree();
81-
bool $entry->isBlob();
82-
bool $entry->isSubmodule();
83-
*/
84-
var_dump($entry);
85-
}
86-
````
54+
// error code should handle in extension.
55+
// resource creation or getting functions will return their resource or bool.
56+
resource|bool function git_repository_init(string $path, long $is_bare);
8757
88-
## Ref Management
89-
90-
````
91-
$ref = Git2\Reference::lookup($repo, "refs/heads/master");
92-
sha = $ref->getTarget();
93-
str = $ref->getName();
58+
public struct (e.g: git_config_entry) should consider return as an array.
9459
````
9560

96-
````
97-
foreach (Git2\Reference::each($repo) as $ref) {
98-
echo $ref->getName() . PHP_EOL;
99-
}
100-
````
61+
##### file name rules.
10162

63+
basically, we rely libgit2 grouping at this time. (`branch` group functions should be in branch.c)
64+
some group (e.g config) will conflicts php header files. we choose `g_` prefix for now.
10265

103-
## Commit
66+
check grouping here libgit2.github.com/libgit2/#v0.20.0
10467

105-
````
106-
<?php
107-
date_default_timezone_set('Asia/Tokyo');
108-
$repo = Git2\Repository::init("/path/to/repo",true);
109-
110-
$author = new Git2\Signature("Shuhei Tanuma","[email protected]",new DateTime());
111-
112-
$bld = new Git2\TreeBuilder();
113-
$bld->insert(new Git2\TreeEntry(array(
114-
"name" => "README.txt",
115-
"oid" => "63542fbea05732b78711479a31557bd1b0aa2116",
116-
"attributes" => octdec('100644'),
117-
)));
118-
$tree = $bld->write($repo);
119-
120-
$parent = "";
121-
$parents = array();
122-
$parent = Git2\Commit::create($repo, array(
123-
"author" => $author,
124-
"committer" => $author,
125-
"message" => "Hello World",
126-
"tree" => $tree,
127-
"parents" => $parents,
128-
));
129-
````
68+
##### generating files
13069

131-
## Revision Walking
70+
if you wanna try to work new file. please use gen.php and generate stubs. as declarations are bored task.
71+
(sometimes, this generator might output wrong headers. then just comment out or fix generator)
13272

13373
````
134-
$repo = new Git2\Repository($path);
135-
$walker = new Git2\Walker($repo);
136-
/* specify HEAD oid */
137-
$walker->push("6e20138dc38f9f626107f1cd3ef0f9838c43defe");
138-
139-
foreach ($walker as $oid => $commit) {
140-
printf("oid: %s\n", $oid);
141-
printf("message: %s\n", $commit->getMessage());
142-
}
74+
PRINT_HEADER=1 php ng.php libgit2/include/git2/branch.h > branch.h
75+
php ng.php libgit2/include/git2/branch.h > branch.c
14376
````
14477

145-
## Config access
78+
you can generate `PHP_FE` with this. past it to `php_git2.c`
14679

14780
````
148-
$config = new Git2\Config("path/to/git/config");
149-
$config->get("core.bare");
150-
$config->store("core.bare","1");
151-
152-
// Git2\Config supports read / write dimension.
153-
$config['core.bare']
154-
$config['core.bare'] = 1;
81+
php fe.php target.c
15582
````
15683

157-
## ODB operation
84+
Note: usually, these generators might output needless variables. DON'T PR `prettify codes` at this moment.
85+
As we have more than 500 php functions. we like to use some fixer command than fix by hand.
15886

159-
````
160-
$repo = Git2\Repository::init("/path/to/repo",true);
161-
$odb = $repo->odb // read only property
162-
Git\OdbObject $odb->read(sha1) // returns uncompressed git raw data.
163-
string $odb->hash(string contents, int type)// same as Git2\Repository::hash
164-
string $odb->write(string contents, int type)// same as Git2\Repository::write
165-
bool $odb->exists(sha1)// same as Git2\Repository::exists
166-
````
87+
##### documents
16788

168-
## Reflog
169-
will be add.
89+
use prototype.
17090

171-
## Remote access (Experimental)
91+
```
92+
/* {{{ proto int abs(int number)
93+
Returns the absolute value of the number */
94+
PHP_FUNCTION(abs)
95+
{
96+
...
97+
}
98+
/* }}} */
99+
```
172100

173-
this API will be change.
101+
document will generate later. please check source code before publish docs.
174102

175-
````
176-
$repo = new Git2\Repository("/path/to/.git");
177-
$remote = new Git2\Remote($repo,"http://github.com/libgit2/php-git.git");
178-
// for now, remote can fetch files only. that does not update references.
179-
$remote->fetch();
180-
````
103+
##### testing
181104

182-
## Author
183-
* Shuhei Tanuma
105+
[group]/[function].phpt
184106

185-
## Contributors
107+
##### policy
186108

187-
* Anthony Van de Gejuchte
188-
* Cameron Eagans
189-
* Graham Weldon
190-
* James Titcumb
191-
* Matthieu Moquet
192-
* Ryusuke SEKIYAMA
193-
* Shuhei Tanuma
194-
* Vasileios Georgitzikis
195-
* tsteiner
109+
* don't create OOP interface in extension for ease of maintenance.
110+
* follow latest libgit2 api. don't consider BC at this time.
196111

197112
## LICENSE
198113

199-
MIT License
114+
MIT License

0 commit comments

Comments
 (0)