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