8000 Merge pull request #6908 from libgit2/ethomson/readme · libgit2/libgit2@a9aa214 · GitHub
[go: up one dir, main page]

Skip to content

Commit a9aa214

Browse files
authored
Merge pull request #6908 from libgit2/ethomson/readme
README updates
2 parents 0da8e72 + 41c8c46 commit a9aa214

File tree

1 file changed

+154
-76
lines changed

1 file changed

+154
-76
lines changed

README.md

Lines changed: 154 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,23 @@ libgit2 - the Git linkable library
1010

1111
`libgit2` is a portable, pure C implementation of the Git core methods
1212
provided as a linkable library with a solid API, allowing to build Git
13-
functionality into your application. Language bindings like
14-
[Rugged](https://github.com/libgit2/rugged) (Ruby),
15-
[LibGit2Sharp](https://github.com/libgit2/libgit2sharp) (.NET),
16-
[pygit2](http://www.pygit2.org/) (Python) and
17-
[NodeGit](http://nodegit.org) (Node) allow you to build Git tooling
18-
in your favorite language.
19-
20-
`libgit2` is used to power Git GUI clients like
21-
[GitKraken](https://gitkraken.com/) and [GitButler](https://gitbutler.com/)
22-
and on Git hosting providers like [GitHub](https://github.com/),
23-
[GitLab](https://gitlab.com/) and
24-
[Azure DevOps](https://azure.com/devops).
25-
We perform the merge every time you click "merge pull request".
26-
27-
`libgit2` is licensed under a **very permissive license** (GPLv2 with a special
28-
Linking Exception). This means that you can link against the library with any
29-
kind of software without making that software fall under the GPL.
30-
Changes to libgit2 would still be covered under its GPL license.
31-
Additionally, the example code has been released to the public domain (see the
32-
[separate license](examples/COPYING) for more information).
13+
functionality into your application.
14+
15+
`libgit2` is used in a variety of places, from GUI clients to hosting
16+
providers ("forges") and countless utilities and applications in
17+
between. Because it's written in C, it can be made available to any
18+
other programming language through "bindings", so you can use it in
19+
[Ruby](https://github.com/libgit2/rugged),
20+
[.NET](https://github.com/libgit2/libgit2sharp),
21+
[Python](http://www.pygit2.org/),
22+
[Node.js](http://nodegit.org),
23+
[Rust](https://github.com/rust-lang/git2-rs), and more.
24+
25+
`libgit2` is licensed under a **very permissive license** (GPLv2 with
26+
a special Linking Exception). This means that you can link against
27+
the library with any kind of software without making that software
28+
fall under the GPL. Changes to libgit2 would still be covered under
29+
its GPL license.
3330

3431
Table of Contents
3532
=================
@@ -93,8 +90,8 @@ Quick Start
9390

9491
**Build**
9592

96-
1. Create a build directory beneath the libgit2 source directory, and change
97-
into it: `mkdir build && cd build`
93+
1. Create a build directory beneath the libgit2 source directory,
94+
and change into it: `mkdir build && cd build`
9895
2. Create the cmake build environment: `cmake ..`
9996
3. Build libgit2: `cmake --build .`
10097

@@ -108,22 +105,24 @@ Getting Help
108105

109106
- via IRC: join [#libgit2](https://web.libera.chat/#libgit2) on
110107
[libera](https://libera.chat).
111-
- via Slack: visit [slack.libgit2.org](http://slack.libgit2.org/) to sign up,
112-
then join us in `#libgit2`
108+
- via Slack: visit [slack.libgit2.org](http://slack.libgit2.org/)
109+
to sign up, then join us in `#libgit2`
113110

114111
**Getting Help**
115112

116113
If you have questions about the library, please be sure to check out the
117114
[API documentation](https://libgit2.org/libgit2/). If you still have
118115
questions, reach out to us on Slack or post a question on
119-
[StackOverflow](http://stackoverflow.com/questions/tagged/libgit2) (with the `libgit2` tag).
116+
[StackOverflow](http://stackoverflow.com/questions/tagged/libgit2)
117+
(with the `libgit2` tag).
120118

121119
**Reporting Bugs**
122120

123-
Please open a [GitHub Issue](https://github.com/libgit2/libgit2/issues) and
124-
include as much information as possible. If possible, provide sample code
125-
that illustrates the problem you're seeing. If you're seeing a bug only
126-
on a specific repository, please provide a link to it if possible.
121+
Please open a [GitHub Issue](https://github.com/libgit2/libgit2/issues)
122+
and include as much information as possible. If possible, provide
123+
sample code that illustrates the problem you're seeing. If you're
124+
seeing a bug only on a specific repository, please provide a link to
125+
it if possible.
127126

128127
We ask that you not open a GitHub Issue for help, only for bug reports.
129128

@@ -138,10 +137,10 @@ libgit2 provides you with the ability to manage Git repositories in the
138137
programming language of your choice. It's used in production to power many
139138
applications including GitHub.com, Plastic SCM and Azure DevOps.
140139

141-
It does not aim to replace the git tool or its user-facing commands. Some APIs
142-
resemble the plumbing commands as those align closely with the concepts of the
143-
Git system, but most commands a user would type are out of scope for this
144-
library to implement directly.
140+
It does not aim to replace the git tool or its user-facing commands. Some
141+
APIs resemble the plumbing commands as those align closely with the
142+
concepts of the Git system, but most commands a user would type are out
143+
of scope for this library to implement directly.
145144

146145
The library provides:
147146

@@ -161,23 +160,31 @@ The library provides:
161160
As libgit2 is purely a consumer of the Git system, we have to
162161
adjust to changes made upstream. This has two major consequences:
163162

164-
* Some changes may require us to change provided interfaces. While we try to
165-
implement functions in a generic way so that no future changes are required,
166-
we cannot promise a completely stable API.
167-
* As we have to keep up with changes in behavior made upstream, we may lag
168-
behind in some areas. We usually to document these incompatibilities in our
169-
issue tracker with the label "git change".
163+
* Some changes may require us to change provided interfaces. While
164+
we try to implement functions in a generic way so that no future
165+
changes are required, we cannot promise a completely stable API.
166+
* As we have to keep up with changes in behavior made upstream, we
167+
may lag behind in some areas. We usually to document these
168+
incompatibilities in our issue tracker with the label "git change".
170169

171170
Optional dependencies
172171
=====================
173172

174-
While the library provides git functionality without the need for
175-
dependencies, it can make use of a few libraries to add to it:
176-
177-
- pthreads (non-Windows) to enable threadsafe access as well as multi-threaded pack generation
178-
- OpenSSL (non-Windows) to talk over HTTPS and provide the SHA-1 functions
179-
- LibSSH2 to enable the SSH transport
180-
- iconv (OSX) to handle the HFS+ path encoding peculiarities
173+
While the library provides git functionality with very few
174+
dependencies, some recommended dependencies are used for performance
175+
or complete functionality.
176+
177+
- Hash generation: Git uses SHA1DC (collision detecting SHA1) for
178+
its default hash generation. SHA256 support is experimental, and
179+
optimized support is provided by system libraries on macOS and
180+
Windows, or by the HTTPS library on Unix systems when available.
181+
- Threading: is provided by the system libraries on Windows, and
182+
pthreads on Unix systems.
183+
- HTTPS: is provided by the system libraries on macOS and Windows,
184+
or by OpenSSL or mbedTLS on other Unix systems.
185+
- SSH: is provided by [libssh2](https://libssh2.org/) or by invoking
186+
[OpenSSH](https://www.openssh.com).
187+
- Unicode: is provided by the system libraries on Windows and macOS.
181188

182189
Initialization
183190
===============
@@ -212,27 +219,90 @@ Building libgit2 - Using CMake
212219
Building
213220
--------
214221

215-
`libgit2` builds cleanly on most platforms without any external dependencies.
216-
Under Unix-like systems, like Linux, \*BSD and Mac OS X, libgit2 expects `pthreads` to be available;
217-
they should be installed by default on all systems. Under Windows, libgit2 uses the native Windows API
218-
for threading.
219-
220-
The `libgit2` library is built using [CMake](<https://cmake.org/>) (version 2.8 or newer) on all platforms.
222+
`libgit2` builds cleanly on most platforms without any external
223+
dependencies as a requirement. `libgit2` is built using
224+
[CMake](<https://cmake.org/>) (version 2.8 or newer) on all platforms.
221225

222226
On most systems you can build the library using the following commands
223227

224228
$ mkdir build && cd build
225229
$ cmake ..
226230
$ cmake --build .
227231

228-
To include the examples in the build, use `cmake -DBUILD_EXAMPLES=True ..` instead of `cmake ..`.
229-
230-
The built executable for the examples can then be found in `build/examples`, relative to the toplevel directory.
232+
To include the examples in the build, use `cmake -DBUILD_EXAMPLES=ON ..`
233+
instead of `cmake ..`. The built executable for the examples can then
234+
be found in `build/examples`, relative to the toplevel directory.
231235

232236
Alternatively you can point the CMake GUI tool to the CMakeLists.txt file and generate platform specific build project or IDE workspace.
233237

234238
If you're not familiar with CMake, [a more detailed explanation](https://preshing.com/20170511/how-to-build-a-cmake-based-project/) may be helpful.
235239

240+
Advanced Options
241+
----------------
242+
243+
You can specify a number of options to `cmake` that will change the
244+
way `libgit2` is built. To use this, specify `-Doption=value` during
245+
the initial `cmake` configuration. For example, to enable SHA256
246+
compatibility:
247+
248+
$ mkdir build && cd build
249+
$ cmake -DEXPERIMENTAL_SHA256=ON ..
250+
$ cmake --build .
251+
252+
libgit2 options:
253+
254+
* `EXPERIMENTAL_SHA256=ON`: turns on SHA256 compatibility; note that
255+
this is an API-incompatible change, hence why it is labeled
256+
"experimental"
257+
258+
Build options:
259+
260+
* `BUILD_EXAMPLES=ON`: builds the suite of example code
261+
* `BUILD_FUZZERS=ON`: builds the fuzzing suite
262+
* `ENABLE_WERROR=ON`: build with `-Werror` or the equivalent, which turns
263+
compiler warnings into errors in the libgit2 codebase (but not its
264+
dependencies)
265+
266+
Dependency options:
267+
268+
* `USE_SSH=type`: enables SSH support; `type` can be set to `libssh2`
269+
or `exec` (which will execute an external OpenSSH command)
270+
* `USE_HTTPS=type`: enables HTTPS support; `type` can be set to
271+
`OpenSSL`, `mbedTLS`, `SecureTransport`, `Schannel`, or `WinHTTP`;
272+
the default is `SecureTransport` on macOS, `WinHTTP` on Windows, and
273+
whichever of `OpenSSL` or `mbedTLS` is detected on other platforms.
274+
* `USE_SHA1=type`: selects the SHA1 mechanism to use; `type` can be set
275+
to `CollisionDetection` (default), or `HTTPS` to use the HTTPS
276+
driver specified above as the hashing provider.
277+
* `USE_SHA256=type`: selects the SHA256 mechanism to use; `type` can be
278+
set to `HTTPS` (default) to use the HTTPS driver specified above as
279+
the hashing provider, or `Builtin`.
280+
* `USE_GSSAPI=<on/off>`: enables GSSAPI for SPNEGO authentication on
281+
Unix
282+
* `USE_HTTP_PARSER=type`: selects the HTTP Parser; either `http-parser`
283+
for an external
284+
[`http-parser`](https://github.com/nodejs/http-parser) dependency,
285+
`llhttp` for an external [`llhttp`](https://github.com/nodejs/llhttp)
286+
dependency, or `builtin`
287+
* `REGEX_BACKEND=type`: selects the regular expression backend to use;
288+
one of `regcomp_l`, `pcre2`, `pcre`, `regcomp`, or `builtin`.
289+
* `USE_BUNDLED_ZLIB=type`: selects the zlib dependency to use; one of
290+
`bundled` or `Chromium`.
291+
292+
Locating Dependencies
293+
---------------------
294+
295+
The `libgit2` project uses `cmake` since it helps with cross-platform
296+
projects, especially those with many dependencies. If your dependencies
297+
are in non-standard places, you may want to use the `_ROOT_DIR` options
298+
to specify their location. For example, to specify an OpenSSL location:
299+
300+
$ cmake -DOPENSSL_ROOT_DIR=/tmp/openssl-3.3.2 ..
301+
302+
Since these options are general to CMake, their
303+
[documentation](https://cmake.org/documentation/) may be helpful. If
304+
you have questions about dependencies, please [contact us](#getting-help).
305+
236306
Running Tests
237307
-------------
238308

@@ -248,12 +318,13 @@ Invoking the test suite directly is useful because it allows you to execute
248318
individual tests, or groups of tests using the `-s` flag. For example, to
249319
run the index tests:
250320

251-
$ ./libgit2_tests -sindex
321+
$ ./libgit2_tests -sindex
252322

253-
To run a single test named `index::racy::diff`, which corresponds to the test
254-
function [`test_index_racy__diff`](https://github.com/libgit2/libgit2/blob/main/tests/index/racy.c#L23):
323+
To run a single test named `index::racy::diff`, which corresponds to
324+
the test function
325+
[`test_index_racy__diff`](https://github.com/libgit2/libgit2/blob/main/tests/index/racy.c#L23):
255326

256-
$ ./libgit2_tests -sindex::racy::diff
327+
$ ./libgit2_tests -sindex::racy::diff
257328

258329
The test suite will print a `.` for every passing test, and an `F` for any
259330
failing test. An `S` indicates that a test was skipped because it is not
@@ -262,7 +333,8 @@ applicable to your platform or is particularly expensive.
262333
**Note:** There should be _no_ failing tests when you build an unmodified
263334
source tree from a [release](https://github.com/libgit2/libgit2/releases),
264335
or from the [main branch](https://github.com/libgit2/libgit2/tree/main).
265-
Please contact us or [open an issue](https://github.com/libgit2/libgit2/issues)
336+
Please contact us or
337+
[open an issue](https://github.com/libgit2/libgit2/issues)
266338
if you see test failures.
267339

268340
Installation
@@ -276,7 +348,8 @@ To install the library you can specify the install prefix by setting:
276348
Advanced Usage
277349
--------------
278350

279-
For more advanced use or questions about CMake please read <https://cmake.org/Wiki/CMake_FAQ>.
351+
For more advanced use or questions about CMake please read the
352+
[CMake FAQ](https://cmake.org/Wiki/CMake_FAQ).
280353

281354
The following CMake variables are declared:
282355

@@ -293,6 +366,7 @@ following:
293366
# Create and set up a build directory
294367< 10000 /code>
$ mkdir build && cd build
295368
$ cmake ..
369+
296370
# List all build options and their values
297371
$ cmake -L
298372

@@ -379,16 +453,19 @@ when configuring.
379453
MinGW
380454
-----
381455

382-
If you want to build the library in MinGW environment with SSH support enabled,
383-
you may need to pass `-DCMAKE_LIBRARY_PATH="${MINGW_PREFIX}/${MINGW_CHOST}/lib/"` flag
384-
to CMake when configuring. This is because CMake cannot find the Win32 libraries in
385-
MinGW folders by default and you might see an error message stating that CMake
386-
could not resolve `ws2_32` library during configuration.
456+
If you want to build the library in MinGW environment with SSH support
457+
enabled, you may need to pass
458+
`-DCMAKE_LIBRARY_PATH="${MINGW_PREFIX}/${MINGW_CHOST}/lib/"` flag
459+
to CMake when configuring. This is because CMake cannot find the
460+
Win32 libraries in MinGW folders by default and you might see an
461+
error message stating that CMake could not resolve `ws2_32` library
462+
during configuration.
387463

388-
Another option would be to install `msys2-w32api-runtime` package before configuring.
389-
This package installs the Win32 libraries into `/usr/lib` folder which is by default
390-
recognized as the library path by CMake. Please note though that this package is meant
391-
for MSYS subsystem which is different from MinGW.
464+
Another option would be to install `msys2-w32api-runtime` package before
465+
configuring. This package installs the Win32 libraries into `/usr/lib`
466+
folder which is by default recognized as the library path by CMake.
467+
Please note though that this package is meant for MSYS subsystem which
468+
is different from MinGW.
392469

393470
Language Bindings
394471
==================================
@@ -468,15 +545,16 @@ and
468545
that are good places to jump in and get started. There's much more detailed
469546
information in our list of [outstanding projects](docs/projects.md).
470547

471-
Please be sure to check the [contribution guidelines](docs/contributing.md) to
472-
understand our workflow, and the libgit2 [coding conventions](docs/conventions.md).
548+
Please be sure to check the [contribution guidelines](docs/contributing.md)
549+
to understand our workflow, and the libgit2
550+
[coding conventions](docs/conventions.md).
473551

474552
License
475553
==================================
476554

477-
`libgit2` is under GPL2 **with linking exception**. This means you can link to
478-
and use the library from any program, proprietary or open source; paid or
479-
gratis. However, if you modify libgit2 itself, you must distribute the
480-
source to your modified version of libgit2.
555+
`libgit2` is under GPL2 **with linking exception**. This means you can
556+
link to and use the library from any program, proprietary or open source;
557+
paid or gratis. However, if you modify libgit2 itself, you must distribute
558+
the source to your modified version of libgit2.
481559

482560
See the [COPYING file](COPYING) for the full license text.

0 commit comments

Comments
 (0)
0