]>
Commit | Line | Data |
---|---|---|
4b7483a2 SC |
1 | libgit2 - the Git linkable library |
2 | ================================== | |
3 | ||
4 | libgit2 is a portable, pure C implementation of the Git core methods provided as a | |
5 | re-entrant linkable library with a solid API, allowing you to write native | |
6 | speed custom Git applications in any language with bindings. | |
7 | ||
4b7483a2 SC |
8 | Why Do We Need It |
9 | ================================== | |
10 | ||
11 | In the current Git project, though a libgit.a file is produced it is | |
12 | not re-entrant (it will call <code>die()</code> on basically any error) | |
13 | and it has no stable or well-designed public API. As there is no good | |
14 | way to link to this effectively, a new library was needed that fulfilled | |
15 | these requirements. Thus libgit2. | |
16 | ||
17 | Though it would be nice to use the same library that Git itself uses, | |
18 | Git actually has a pretty simple storage format and just having native | |
19 | access to that is pretty useful. Eventually we would like to have most | |
20 | of the functionality of the core Git tools or even get the library | |
21 | integrated into Git itself, but in the meantime having a cleanly designed | |
22 | and maintained linkable Git library with a public API will likely be helpful | |
23 | to lots of people. | |
24 | ||
25 | What It Can Do | |
26 | ================================== | |
27 | ||
28 | libgit2 is already very usable. | |
29 | * raw <-> hex SHA conversions | |
30 | * raw object reading (loose and packed) | |
31 | * raw object writing (loose) | |
32 | * revlist walker | |
33 | * commit, tag and tree object parsing and write-back | |
34 | * tree traversal | |
35 | * basic index file (staging area) operations | |
36 | ||
b97b386d VM |
37 | Building libgit2 - Unix systems |
38 | ================================== | |
39 | ||
40 | In Unix-like systems, like Linux, *BSD and Mac OS X, libgit2 has | |
41 | the following dependencies: | |
4b7483a2 | 42 | |
b97b386d VM |
43 | - Python 2.5-3.1 <http://www.python.org> |
44 | Used by run the build system; no extra libraries required. | |
45 | Should probably ship installed with your OS. | |
46 | ||
47 | - zlib 1.2+ <http://www.zlib.net/> | |
48 | ||
49 | - LibSSL <http://www.openssl.org/> | |
50 | Only needed if you want to re-use OpenSSL's SHA1 routines; | |
51 | libgit2 compiles its own routines by default. | |
52 | ||
53 | To build it, first configure the build system by running: | |
54 | ||
55 | $ ./waf configure | |
56 | ||
57 | Then build the library, either in its shared (libgit2.so) or static form (libgit2.a) | |
58 | ||
59 | $ ./waf build-static | |
60 | $ ./waf build-shared | |
61 | ||
62 | You can then test the library with: | |
63 | ||
64 | $ ./waf test | |
65 | ||
66 | And finally you can install it with (you may need to sudo): | |
67 | ||
68 | $ ./waf install | |
69 | ||
70 | Building libgit2 - Windows MSVC++ | |
4b7483a2 SC |
71 | ================================== |
72 | ||
b97b386d VM |
73 | When building under Windows using the MSVC compiler, libgit2 has |
74 | the following dependencies: | |
75 | ||
76 | - Python 2.5-3.1 <http://www.python.org> | |
77 | Used by run the build system; no extra libraries required. | |
78 | ||
79 | - zlib 1.2+ (Windows API Version) <http://www.zlib.net/> | |
80 | Make sure you compile the ZLib library using the MSVC solution | |
81 | that ships in its source distribution. | |
82 | Alternatively, you may download precompiled binaries from: | |
83 | http://www.winimage.com/zLibDll/ | |
84 | ||
85 | - LibSSL <http://www.openssl.org/> | |
86 | Only needed if you want to re-use OpenSSL's SHA1 routines; | |
87 | libgit2 compiles its own routines by default. | |
88 | ||
89 | To build it, first configure the build system by running: | |
90 | ||
91 | $ ./waf configure | |
92 | ||
93 | Then build the library, either in its shared (libgit2.dll) or static form (libgit2.lib) | |
94 | ||
95 | $ ./waf build-static | |
96 | $ ./waf build-shared | |
97 | ||
98 | You can then test the library with: | |
99 | ||
100 | $ ./waf test | |
101 | ||
102 | Lastly, you can manually install the generated *.lib and *.dll files, depending on | |
103 | your preferences. | |
104 | ||
105 | Building libgit2 - Windows MinGW | |
106 | ================================== | |
107 | ||
108 | When building under Windows using the GCC compiler that ships with MinGW, | |
109 | libgit2 has the following dependencies: | |
110 | ||
111 | - Python 2.5-3.1 <http://www.python.org> | |
112 | Used by run the build system; no extra libraries required. | |
113 | ||
114 | - zlib 1.2+ <http://www.zlib.net/> | |
115 | ||
116 | - pthreads-w32 <http://sourceware.org/pthreads-win32/> | |
117 | Or an equivalent pthreads implementation for non-POSIX systems | |
118 | ||
119 | - LibSSL <http://www.openssl.org/> | |
120 | Only needed if you want to re-use OpenSSL's SHA1 routines; | |
121 | libgit2 compiles its own routines by default. | |
122 | ||
123 | To build it, first configure the build system and force GCC as the compiler, | |
124 | instead of the default MSVC: | |
125 | ||
126 | $ ./waf configure --check-c-compiler=gcc | |
127 | ||
128 | Then build the library, either in its shared (libgit2.so) or static form (libgit2.a) | |
129 | ||
130 | $ ./waf build-static | |
131 | $ ./waf build-shared | |
132 | ||
133 | You can then test the library with: | |
134 | ||
135 | $ ./waf test | |
136 | ||
137 | And finally you can install it with: | |
138 | ||
139 | $ ./waf install | |
140 | ||
141 | ||
142 | Configuration settings | |
143 | ================================== | |
144 | ||
145 | The waf build system for libgit2 accepts the following flags: | |
146 | ||
147 | --debug | |
148 | build the library with debug symbols. | |
149 | Defaults to off. | |
150 | ||
151 | --sha1=[builtin|ppc|openssl] | |
152 | use the builtin SHA1 functions, the optimized PPC versions | |
153 | or the SHA1 functions from LibCrypto (OpenSSL). | |
154 | Defaults to 'builtin'. | |
4b7483a2 | 155 | |
b97b386d VM |
156 | You can run `./waf --help` to see a full list of install options and |
157 | targets. | |
4b7483a2 SC |
158 | |
159 | Language Bindings | |
160 | ================================== | |
161 | ||
162 | So you want to use Git from your favorite programming language. Here are | |
163 | the bindings to libgit2 that are currently available: | |
164 | ||
165 | == Ruby == | |
166 | ||
167 | Ribbit is the reference library used to make sure the | |
168 | libgit2 API is sane. This should be mostly up to date. | |
169 | ||
170 | http://github.com/libgit2/ribbit | |
171 | ||
172 | ||
173 | == Erlang == | |
174 | ||
175 | Geef is an example of an Erlang NIF binding to libgit2. A bit out of | |
176 | date, but basically works. Best as a proof of concept of what you could | |
177 | do with Erlang and NIFs with libgit2. | |
178 | ||
179 | http://github.com/schacon/geef | |
180 | ||
181 | ||
182 | If you start another language binding to libgit2, please let us know so | |
183 | we can add it to the list. | |
184 | ||
185 | License | |
186 | ================================== | |
187 | libgit2 is under GPL2 with linking exemption, which basically means you | |
188 | can link to the library with any program, commercial, open source or | |
189 | other. However, you cannot modify libgit2 and distribute it without | |
190 | supplying the source. | |
191 | ||
192 | See the COPYING file for the full license text. |