]> git.proxmox.com Git - libgit2.git/blob - README.md
Merge pull request #4195 from pks-t/pks/openssl-1.1
[libgit2.git] / README.md
1 libgit2 - the Git linkable library
2 ==================================
3
4 [![Travis Build Status](https://secure.travis-ci.org/libgit2/libgit2.svg?branch=master)](http://travis-ci.org/libgit2/libgit2)
5 [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/xvof5b4t5480a2q3/branch/master?svg=true)](https://ci.appveyor.com/project/libgit2/libgit2/branch/master)
6 [![Coverity Scan Build Status](https://scan.coverity.com/projects/639/badge.svg)](https://scan.coverity.com/projects/639)
7
8 `libgit2` is a portable, pure C implementation of the Git core methods
9 provided as a re-entrant linkable library with a solid API, allowing you to
10 write native speed custom Git applications in any language with bindings.
11
12 `libgit2` is licensed under a **very permissive license** (GPLv2 with a special
13 Linking Exception). This basically means that you can link it (unmodified)
14 with any kind of software without having to release its source code.
15 Additionally, the example code has been released to the public domain (see the
16 [separate license](examples/COPYING) for more information).
17
18 Getting Help
19 ============
20
21 **Join us on Slack**
22
23 Visit [slack.libgit2.org](http://slack.libgit2.org/) to sign up, then join
24 us in `#libgit2`. If you prefer IRC, you can also point your client to our
25 slack channel once you've registered.
26
27 **Getting Help**
28
29 If you have questions about the library, please be sure to check out the
30 [API documentation](http://libgit2.github.com/libgit2/). If you still have
31 questions, reach out to us on Slack or post a question on
32 [StackOverflow](http://stackoverflow.com/questions/tagged/libgit2) (with the `libgit2` tag).
33
34 **Reporting Bugs**
35
36 Please open a [GitHub Issue](https://github.com/libgit2/libgit2/issues) and
37 include as much information as possible. If possible, provide sample code
38 that illustrates the problem you're seeing. If you're seeing a bug only
39 on a specific repository, please provide a link to it if possible.
40
41 We ask that you not open a GitHub Issue for help, only for bug reports.
42
43 What It Can Do
44 ==============
45
46 The goal of this library is to allow its users the ability to handle Git data in
47 their applications from their programming language of choice, as is used in
48 production for many applications including the GitHub.com site, in Plastic SCM
49 and also powering Microsoft's Visual Studio tools for Git.
50
51 It does not aim to replace the git tool or its user-facing commands. Some APIs
52 resemble the plumbing commands as those align closely with the concepts of the
53 Git system, but most commands a user would type are out of scope for this
54 library to implement directly.
55
56 The library provides:
57
58 * SHA conversions, formatting and shortening
59 * abstracted ODB backend system
60 * commit, tag, tree and blob parsing, editing, and write-back
61 * tree traversal
62 * revision walking
63 * index file (staging area) manipulation
64 * reference management (including packed references)
65 * config file management
66 * high level repository management
67 * thread safety and reentrancy
68 * descriptive and detailed error messages
69 * ...and more (over 175 different API calls)
70
71 As libgit2 is purely a consumer of the Git system, we have to
72 adjust to changes made upstream. This has two major consequences:
73
74 * Some changes may require us to change provided interfaces. While we try to
75 implement functions in a generic way so that no future changes are required,
76 we cannot promise a completely stable API.
77 * As we have to keep up with changes in behavior made upstream, we may lag
78 behind in some areas. We usually to document these incompatibilities in our
79 issue tracker with the label "git change".
80
81 Optional dependencies
82 =====================
83
84 While the library provides git functionality without the need for
85 dependencies, it can make use of a few libraries to add to it:
86
87 - pthreads (non-Windows) to enable threadsafe access as well as multi-threaded pack generation
88 - OpenSSL (non-Windows) to talk over HTTPS and provide the SHA-1 functions
89 - LibSSH2 to enable the SSH transport
90 - iconv (OSX) to handle the HFS+ path encoding peculiarities
91
92 Initialization
93 ===============
94
95 The library needs to keep track of some global state. Call
96
97 git_libgit2_init();
98
99 before calling any other libgit2 functions. You can call this function many times. A matching number of calls to
100
101 git_libgit2_shutdown();
102
103 will free the resources. Note that if you have worker threads, you should
104 call `git_libgit2_shutdown` *after* those threads have exited. If you
105 require assistance coordinating this, simply have the worker threads call
106 `git_libgit2_init` at startup and `git_libgit2_shutdown` at shutdown.
107
108 Threading
109 =========
110
111 See [THREADING](THREADING.md) for information
112
113 Conventions
114 ===========
115
116 See [CONVENTIONS](CONVENTIONS.md) for an overview of the external
117 and internal API/coding conventions we use.
118
119 Building libgit2 - Using CMake
120 ==============================
121
122 `libgit2` builds cleanly on most platforms without any external dependencies.
123 Under Unix-like systems, like Linux, \*BSD and Mac OS X, libgit2 expects `pthreads` to be available;
124 they should be installed by default on all systems. Under Windows, libgit2 uses the native Windows API
125 for threading.
126
127 The `libgit2` library is built using [CMake](<https://cmake.org/>) (version 2.8 or newer) on all platforms.
128
129 On most systems you can build the library using the following commands
130
131 $ mkdir build && cd build
132 $ cmake ..
133 $ cmake --build .
134
135 Alternatively you can point the CMake GUI tool to the CMakeLists.txt file and generate platform specific build project or IDE workspace.
136
137 Once built, you can run the tests from the `build` directory with the command
138
139 $ make test
140
141 Alternatively you can run the test suite directly using,
142
143 $ ./libgit2_clar
144
145 To install the library you can specify the install prefix by setting:
146
147 $ cmake .. -DCMAKE_INSTALL_PREFIX=/install/prefix
148 $ cmake --build . --target install
149
150 For more advanced use or questions about CMake please read <https://cmake.org/Wiki/CMake_FAQ>.
151
152 The following CMake variables are declared:
153
154 - `BIN_INSTALL_DIR`: Where to install binaries to.
155 - `LIB_INSTALL_DIR`: Where to install libraries to.
156 - `INCLUDE_INSTALL_DIR`: Where to install headers to.
157 - `BUILD_SHARED_LIBS`: Build libgit2 as a Shared Library (defaults to ON)
158 - `BUILD_CLAR`: Build [Clar](https://github.com/vmg/clar)-based test suite (defaults to ON)
159 - `THREADSAFE`: Build libgit2 with threading support (defaults to ON)
160 - `STDCALL`: Build libgit2 as `stdcall`. Turn off for `cdecl` (Windows; defaults to ON)
161
162 Compiler and linker options
163 ---------------------------
164
165 CMake lets you specify a few variables to control the behavior of the
166 compiler and linker. These flags are rarely used but can be useful for
167 64-bit to 32-bit cross-compilation.
168
169 - `CMAKE_C_FLAGS`: Set your own compiler flags
170 - `CMAKE_FIND_ROOT_PATH`: Override the search path for libraries
171 - `ZLIB_LIBRARY`, `OPENSSL_SSL_LIBRARY` AND `OPENSSL_CRYPTO_LIBRARY`:
172 Tell CMake where to find those specific libraries
173
174 MacOS X
175 -------
176
177 If you want to build a universal binary for Mac OS X, CMake sets it
178 all up for you if you use `-DCMAKE_OSX_ARCHITECTURES="i386;x86_64"`
179 when configuring.
180
181 Windows
182 -------
183
184 You need to run the CMake commands from the Visual Studio command
185 prompt, not the regular or Windows SDK one. Select the right generator
186 for your version with the `-G "Visual Studio X" option.
187
188 See [the website](http://libgit2.github.com/docs/guides/build-and-link/)
189 for more detailed instructions.
190
191 Android
192 -------
193
194 Extract toolchain from NDK using, `make-standalone-toolchain.sh` script.
195 Optionally, crosscompile and install OpenSSL inside of it. Then create CMake
196 toolchain file that configures paths to your crosscompiler (substitute `{PATH}`
197 with full path to the toolchain):
198
199 SET(CMAKE_SYSTEM_NAME Linux)
200 SET(CMAKE_SYSTEM_VERSION Android)
201
202 SET(CMAKE_C_COMPILER {PATH}/bin/arm-linux-androideabi-gcc)
203 SET(CMAKE_CXX_COMPILER {PATH}/bin/arm-linux-androideabi-g++)
204 SET(CMAKE_FIND_ROOT_PATH {PATH}/sysroot/)
205
206 SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
207 SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
208 SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
209
210 Add `-DCMAKE_TOOLCHAIN_FILE={pathToToolchainFile}` to cmake command
211 when configuring.
212
213 Language Bindings
214 ==================================
215
216 Here are the bindings to libgit2 that are currently available:
217
218 * C++
219 * libqgit2, Qt bindings <https://projects.kde.org/projects/playground/libs/libqgit2/repository/>
220 * Chicken Scheme
221 * chicken-git <https://wiki.call-cc.org/egg/git>
222 * D
223 * dlibgit <https://github.com/s-ludwig/dlibgit>
224 * Delphi
225 * GitForDelphi <https://github.com/libgit2/GitForDelphi>
226 * Erlang
227 * Geef <https://github.com/carlosmn/geef>
228 * Go
229 * git2go <https://github.com/libgit2/git2go>
230 * GObject
231 * libgit2-glib <https://wiki.gnome.org/Projects/Libgit2-glib>
232 * Haskell
233 * hgit2 <https://github.com/jwiegley/gitlib>
234 * Java
235 * Jagged <https://github.com/ethomson/jagged>
236 * Julia
237 * LibGit2.jl <https://github.com/jakebolewski/LibGit2.jl>
238 * Lua
239 * luagit2 <https://github.com/libgit2/luagit2>
240 * .NET
241 * libgit2sharp <https://github.com/libgit2/libgit2sharp>
242 * Node.js
243 * nodegit <https://github.com/nodegit/nodegit>
244 * Objective-C
245 * objective-git <https://github.com/libgit2/objective-git>
246 * OCaml
247 * ocaml-libgit2 <https://github.com/fxfactorial/ocaml-libgit2>
248 * Parrot Virtual Machine
249 * parrot-libgit2 <https://github.com/letolabs/parrot-libgit2>
250 * Perl
251 * Git-Raw <https://github.com/jacquesg/p5-Git-Raw>
252 * PHP
253 * php-git <https://github.com/libgit2/php-git>
254 * PowerShell
255 * PSGit <https://github.com/PoshCode/PSGit>
256 * Python
257 * pygit2 <https://github.com/libgit2/pygit2>
258 * R
259 * git2r <https://github.com/ropensci/git2r>
260 * Ruby
261 * Rugged <https://github.com/libgit2/rugged>
262 * Rust
263 * git2-rs <https://github.com/alexcrichton/git2-rs>
264 * Swift
265 * SwiftGit2 <https://github.com/SwiftGit2/SwiftGit2>
266 * Vala
267 * libgit2.vapi <https://github.com/apmasell/vapis/blob/master/libgit2.vapi>
268
269 If you start another language binding to libgit2, please let us know so
270 we can add it to the list.
271
272 How Can I Contribute?
273 ==================================
274
275 We welcome new contributors! We have a number of issues marked as
276 ["up for grabs"](https://github.com/libgit2/libgit2/issues?q=is%3Aissue+is%3Aopen+label%3A%22up+for+grabs%22)
277 and
278 ["easy fix"](https://github.com/libgit2/libgit2/issues?utf8=✓&q=is%3Aissue+is%3Aopen+label%3A%22easy+fix%22)
279 that are good places to jump in and get started. There's much more detailed
280 information in our list of [outstanding projects](PROJECTS.md).
281
282 Please be sure to check the [contribution guidelines](CONTRIBUTING.md) to
283 understand our workflow, and the libgit2 [coding conventions](CONVENTIONS.md).
284
285 License
286 ==================================
287
288 `libgit2` is under GPL2 **with linking exception**. This means you can link to
289 and use the library from any program, proprietary or open source; paid or
290 gratis. However, if you modify libgit2 itself, you must distribute the
291 source to your modified version of libgit2.
292
293 See the [COPYING file](COPYING) for the full license text.