]> git.proxmox.com Git - libgit2.git/blame - README.md
openssl: we already had the function, just needed the header
[libgit2.git] / README.md
CommitLineData
4b7483a2 1libgit2 - the Git linkable library
20b5d300 2==================================
4b7483a2 3
c5c8ece1 4[![Travis Build Status](https://secure.travis-ci.org/libgit2/libgit2.svg?branch=master)](http://travis-ci.org/libgit2/libgit2)
7cfbf3b7 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)
4caf0df0 6[![Coverity Scan Build Status](https://scan.coverity.com/projects/639/badge.svg)](https://scan.coverity.com/projects/639)
37029314 7
486bc366
RB
8`libgit2` is a portable, pure C implementation of the Git core methods
9provided as a re-entrant linkable library with a solid API, allowing you to
10write native speed custom Git applications in any language with bindings.
4b7483a2 11
dcfdb977
BS
12`libgit2` is licensed under a **very permissive license** (GPLv2 with a special
13Linking Exception). This basically means that you can link it (unmodified)
14with any kind of software without having to release its source code.
15Additionally, the example code has been released to the public domain (see the
16[separate license](examples/COPYING) for more information).
b760fbf5 17
20b5d300 18* Website: [libgit2.github.com](http://libgit2.github.com)
3e3d332b 19* StackOverflow Tag: [libgit2](http://stackoverflow.com/questions/tagged/libgit2)
20b5d300 20* Issues: [GitHub Issues](https://github.com/libgit2/libgit2/issues) (Right here!)
1181ca0c 21* API documentation: <http://libgit2.github.com/libgit2/>
20b5d300 22* IRC: [#libgit2](irc://irc.freenode.net/libgit2) on irc.freenode.net.
3e3d332b 23* Mailing list: The libgit2 mailing list was
68a19ca9 24 traditionally hosted in Librelist but has been deprecated. We encourage you to
41a93cc6 25 [use StackOverflow](http://stackoverflow.com/questions/tagged/libgit2) instead for any questions regarding
68a19ca9
RB
26 the library, or [open an issue](https://github.com/libgit2/libgit2/issues)
27 on GitHub for bug reports. The mailing list archives are still available at
3e3d332b
MW
28 <http://librelist.com/browser/libgit2/>.
29
4b7483a2
SC
30
31What It Can Do
20b5d300 32==============
4b7483a2 33
486bc366
RB
34`libgit2` is already very usable and is being used in production for many
35applications including the GitHub.com site, in Plastic SCM and also powering
36Microsoft's Visual Studio tools for Git. The library provides:
c5b97d5a 37
b760fbf5 38* SHA conversions, formatting and shortening
5689a8d5 39* abstracted ODB backend system
7548b8af 40* commit, tag, tree and blob parsing, editing, and write-back
4b7483a2 41* tree traversal
b760fbf5
VM
42* revision walking
43* index file (staging area) manipulation
b760fbf5 44* reference management (including packed references)
7548b8af
VM
45* config file management
46* high level repository management
47* thread safety and reentrancy
48* descriptive and detailed error messages
49* ...and more (over 175 different API calls)
b760fbf5 50
2baee9f8
CMN
51Optional dependencies
52=====================
53
54While the library provides git functionality without the need for
55dependencies, it can make use of a few libraries to add to it:
56
57- pthreads (non-Windows) to enable threadsafe access as well as multi-threaded pack generation
58- OpenSSL (non-Windows) to talk over HTTPS and provide the SHA-1 functions
2c22193b 59- LibSSH2 to enable the SSH transport
2baee9f8
CMN
60- iconv (OSX) to handle the HFS+ path encoding peculiarities
61
ed09e044
CMN
62Initialization
63===============
64
65The library needs to keep track of some global state. Call
66
67 git_libgit2_init();
68
69before calling any other libgit2 functions. You can call this function many times. A matching number of calls to
70
71 git_libgit2_shutdown();
72
ecf1c3c3
ET
73will free the resources. Note that if you have worker threads, you should
74call `git_libgit2_shutdown` *after* those threads have exited. If you
75require assistance coordinating this, simply have the worker threads call
76`git_libgit2_init` at startup and `git_libgit2_shutdown` at shutdown.
ed09e044 77
15bea02c
CMN
78Threading
79=========
80
81See [THREADING](THREADING.md) for information
82
7548b8af
VM
83Building libgit2 - Using CMake
84==============================
ec821ca6 85
20b5d300 86`libgit2` builds cleanly on most platforms without any external dependencies.
a07d8994 87Under Unix-like systems, like Linux, \*BSD and Mac OS X, libgit2 expects `pthreads` to be available;
bbcc7ffc
VM
88they should be installed by default on all systems. Under Windows, libgit2 uses the native Windows API
89for threading.
90
1181ca0c 91The `libgit2` library is built using [CMake](<https://cmake.org/>) (version 2.8 or newer) on all platforms.
4b7483a2 92
e0d9e12e 93On most systems you can build the library using the following commands
4b7483a2 94
e0d9e12e
VM
95 $ mkdir build && cd build
96 $ cmake ..
97 $ cmake --build .
c5b97d5a 98
e0d9e12e
VM
99Alternatively you can point the CMake GUI tool to the CMakeLists.txt file and generate platform specific build project or IDE workspace.
100
101To install the library you can specify the install prefix by setting:
4b7483a2 102
e0d9e12e
VM
103 $ cmake .. -DCMAKE_INSTALL_PREFIX=/install/prefix
104 $ cmake --build . --target install
4b7483a2 105
1181ca0c 106For more advanced use or questions about CMake please read <https://cmake.org/Wiki/CMake_FAQ>.
c5b97d5a 107
7548b8af
VM
108The following CMake variables are declared:
109
9795a40f 110- `BIN_INSTALL_DIR`: Where to install binaries to.
77ace82d 111- `LIB_INSTALL_DIR`: Where to install libraries to.
9795a40f 112- `INCLUDE_INSTALL_DIR`: Where to install headers to.
f0890fcc 113- `BUILD_SHARED_LIBS`: Build libgit2 as a Shared Library (defaults to ON)
221ee54b 114- `BUILD_CLAR`: Build [Clar](https://github.com/vmg/clar)-based test suite (defaults to ON)
79b0ae4e 115- `THREADSAFE`: Build libgit2 with threading support (defaults to ON)
66bf4dbc
CMN
116- `STDCALL`: Build libgit2 as `stdcall`. Turn off for `cdecl` (Windows; defaults to ON)
117
118Compiler and linker options
119---------------------------
120
121CMake lets you specify a few variables to control the behavior of the
122compiler and linker. These flags are rarely used but can be useful for
12364-bit to 32-bit cross-compilation.
124
125- `CMAKE_C_FLAGS`: Set your own compiler flags
126- `CMAKE_FIND_ROOT_PATH`: Override the search path for libraries
127- `ZLIB_LIBRARY`, `OPENSSL_SSL_LIBRARY` AND `OPENSSL_CRYPTO_LIBRARY`:
128Tell CMake where to find those specific libraries
129
130MacOS X
131-------
132
133If you want to build a universal binary for Mac OS X, CMake sets it
134all up for you if you use `-DCMAKE_OSX_ARCHITECTURES="i386;x86_64"`
135when configuring.
136
137Windows
138-------
139
140You need to run the CMake commands from the Visual Studio command
141prompt, not the regular or Windows SDK one. Select the right generator
142for your version with the `-G "Visual Studio X" option.
143
1181ca0c 144See [the website](http://libgit2.github.com/docs/guides/build-and-link/)
66bf4dbc 145for more detailed instructions.
c5b97d5a 146
01cd5ae3
KA
147Android
148-------
149
150Extract toolchain from NDK using, `make-standalone-toolchain.sh` script.
63d1fad4
NK
151Optionally, crosscompile and install OpenSSL inside of it. Then create CMake
152toolchain file that configures paths to your crosscompiler (substitute `{PATH}`
01cd5ae3
KA
153with full path to the toolchain):
154
155 SET(CMAKE_SYSTEM_NAME Linux)
156 SET(CMAKE_SYSTEM_VERSION Android)
775d831b 157
01cd5ae3
KA
158 SET(CMAKE_C_COMPILER {PATH}/bin/arm-linux-androideabi-gcc)
159 SET(CMAKE_CXX_COMPILER {PATH}/bin/arm-linux-androideabi-g++)
160 SET(CMAKE_FIND_ROOT_PATH {PATH}/sysroot/)
775d831b 161
01cd5ae3
KA
162 SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
163 SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
164 SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
165
57aa839c 166Add `-DCMAKE_TOOLCHAIN_FILE={pathToToolchainFile}` to cmake command
01cd5ae3
KA
167when configuring.
168
e0d9e12e
VM
169Language Bindings
170==================================
4b7483a2 171
e0d9e12e 172Here are the bindings to libgit2 that are currently available:
4b7483a2 173
b8d08292
AL
174* C++
175 * libqgit2, Qt bindings <https://projects.kde.org/projects/playground/libs/libqgit2/>
0e8144fe
EH
176* Chicken Scheme
177 * chicken-git <https://wiki.call-cc.org/egg/git>
26127ea7 178* D
e702dc2e 179 * dlibgit <https://github.com/s-ludwig/dlibgit>
b8d08292
AL
180* Delphi
181 * GitForDelphi <https://github.com/libgit2/GitForDelphi>
182* Erlang
a402179a 183 * Geef <https://github.com/carlosmn/geef>
b8d08292 184* Go
f2cda906 185 * git2go <https://github.com/libgit2/git2go>
b8d08292 186* GObject
1ce509fe 187 * libgit2-glib <https://wiki.gnome.org/Projects/Libgit2-glib>
b8d08292 188* Haskell
1181ca0c 189 * hgit2 <https://github.com/jwiegley/gitlib>
4ef9a508
ET
190* Java
191 * Jagged <https://github.com/ethomson/jagged>
d747ec18 192* Julia
193 * LibGit2.jl <https://github.com/jakebolewski/LibGit2.jl>
b8d08292
AL
194* Lua
195 * luagit2 <https://github.com/libgit2/luagit2>
196* .NET
b8d08292
AL
197 * libgit2sharp <https://github.com/libgit2/libgit2sharp>
198* Node.js
199 * node-gitteh <https://github.com/libgit2/node-gitteh>
1181ca0c 200 * nodegit <https://github.com/nodegit/nodegit>
b8d08292
AL
201* Objective-C
202 * objective-git <https://github.com/libgit2/objective-git>
203* OCaml
69560cc0 204 * ocaml-libgit2 <https://github.com/fxfactorial/ocaml-libgit2>
b8d08292
AL
205* Parrot Virtual Machine
206 * parrot-libgit2 <https://github.com/letolabs/parrot-libgit2>
207* Perl
2ef20da0 208 * Git-Raw <https://github.com/jacquesg/p5-Git-Raw>
b8d08292
AL
209* PHP
210 * php-git <https://github.com/libgit2/php-git>
4ef9a508
ET
211* PowerShell
212 * GitPowerShell <https://github.com/ethomson/gitpowershell>
b8d08292
AL
213* Python
214 * pygit2 <https://github.com/libgit2/pygit2>
562516ec
SW
215* R
216 * git2r <https://github.com/ropensci/git2r>
b8d08292
AL
217* Ruby
218 * Rugged <https://github.com/libgit2/rugged>
b4913705
AC
219* Rust
220 * git2-rs <https://github.com/alexcrichton/git2-rs>
35425b51
BG
221* Swift
222 * Gift <https://github.com/modocache/Gift>
b8d08292
AL
223* Vala
224 * libgit2.vapi <https://github.com/apmasell/vapis/blob/master/libgit2.vapi>
4b7483a2
SC
225
226If you start another language binding to libgit2, please let us know so
227we can add it to the list.
228
b8d08292 229How Can I Contribute?
c5b97d5a
SC
230==================================
231
486bc366 232Check the [contribution guidelines](CONTRIBUTING.md) to understand our
22829b74 233workflow, the libgit2 [coding conventions](CONVENTIONS.md), and our list of
486bc366 234[good starting projects](PROJECTS.md).
c5b97d5a 235
932d1baf 236License
4b7483a2 237==================================
486bc366 238
18925129 239`libgit2` is under GPL2 **with linking exception**. This means you can link to
486bc366
RB
240and use the library from any program, proprietary or open source; paid or
241gratis. However, you cannot modify libgit2 and distribute it without
4b7483a2
SC
242supplying the source.
243
486bc366 244See the [COPYING file](COPYING) for the full license text.