Skip to content

Commit fa767da

Browse files
authored
Merge pull request libgit2#4410 from libgit2/ethomson/readme
Getting started README improvements
2 parents 59ffb51 + 5bcaba5 commit fa767da

File tree

2 files changed

+85
-13
lines changed

2 files changed

+85
-13
lines changed

README.md

Lines changed: 72 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,51 @@ libgit2 - the Git linkable library
66
[![Coverity Scan Build Status](https://scan.coverity.com/projects/639/badge.svg)](https://scan.coverity.com/projects/639)
77

88
`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.
9+
provided as a linkable library with a solid API, allowing to build Git
10+
functionality into your application. Language bindings like
11+
[Rugged](https://github.com/libgit2/rugged) (Ruby),
12+
[LibGit2Sharp](https://github.com/libgit2/libgit2sharp) (.NET),
13+
[pygit2](http://www.pygit2.org/) (Python) and
14+
[NodeGit](http://nodegit.org) (Node) allow you to build Git tooling
15+
in your favorite language.
16+
17+
`libgit2` is used to power Git GUI clients like
18+
[GitKraken](https://gitkraken.com/) and [gmaster](https://gmaster.io/)
19+
and on Git hosting providers like [GitHub](https://github.com/),
20+
[GitLab](https://gitlab.com/) and
21+
[Visual Studio Team Services](https://visualstudio.com/team-services/).
22+
We perform the merge every time you click "merge pull request".
1123

1224
`libgit2` is licensed under a **very permissive license** (GPLv2 with a special
1325
Linking Exception). This basically means that you can link it (unmodified)
1426
with any kind of software without having to release its source code.
1527
Additionally, the example code has been released to the public domain (see the
1628
[separate license](examples/COPYING) for more information).
1729

30+
Quick Start
31+
===========
32+
33+
**Prerequisites** for building libgit2:
34+
35+
1. [CMake](https://cmake.org/), and is recommended to be installed into
36+
your `PATH`.
37+
2. [Python](https://www.python.org) is used by our test framework, and
38+
should be installed into your `PATH`.
39+
3. C compiler: libgit2 is C90 and should compile on most compilers.
40+
* Windows: Visual Studio is recommended
41+
* Mac: Xcode is recommended
42+
* Unix: gcc or clang is recommended.
43+
44+
**Build**
45+
46+
1. Create a build directory beneath the libgit2 source directory, and change
47+
into it: `mkdir build && cd build`
48+
2. Create the cmake build environment: `cmake ..`
49+
3. Build libgit2: `cmake --build .`
50+
51+
Trouble with these steps? Read `TROUBLESHOOTING.md`. More detailed build
52+
guidance is available below.
53+
1854
Getting Help
1955
============
2056

@@ -118,6 +154,9 @@ and internal API/coding conventions we use.
118154
Building libgit2 - Using CMake
119155
==============================
120156

157+
Building
158+
--------
159+
121160
`libgit2` builds cleanly on most platforms without any external dependencies.
122161
Under Unix-like systems, like Linux, \*BSD and Mac OS X, libgit2 expects `pthreads` to be available;
123162
they should be installed by default on all systems. Under Windows, libgit2 uses the native Windows API
@@ -133,19 +172,49 @@ On most systems you can build the library using the following commands
133172

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

175+
Running Tests
176+
-------------
177+
136178
Once built, you can run the tests from the `build` directory with the command
137179

138-
$ make test
180+
$ ctest -V
139181

140182
Alternatively you can run the test suite directly using,
141183

142184
$ ./libgit2_clar
143185

186+
Invoking the test suite directly is useful because it allows you to execute
187+
individual tests, or groups of tests using the `-s` flag. For example, to
188+
run the index tests:
189+
190+
$ ./libgit2_clar -sindex
191+
192+
To run a single test named `index::racy::diff`, which corresponds to the test
193+
function (`test_index_racy__diff`)[https://github.com/libgit2/libgit2/blob/master/tests/index/racy.c#L23]:
194+
195+
$ ./libgit2_clar -sindex::racy::diff
196+
197+
The test suite will print a `.` for every passing test, and an `F` for any
198+
failing test. An `S` indicates that a test was skipped because it is not
199+
applicable to your platform or is particularly expensive.
200+
201+
**Note:** There should be _no_ failing tests when you build an unmodified
202+
source tree from a [release](https://github.com/libgit2/libgit2/releases),
203+
or from the [master branch](https://github.com/libgit2/libgit2/tree/master).
204+
Please contact us or [open an issue](https://github.com/libgit2/libgit2/issues)
205+
if you see test failures.
206+
207+
Installation
208+
------------
209+
144210
To install the library you can specify the install prefix by setting:
145211

146212
$ cmake .. -DCMAKE_INSTALL_PREFIX=/install/prefix
147213
$ cmake --build . --target install
148214

215+
Advanced Usage
216+
--------------
217+
149218
For more advanced use or questions about CMake please read <https://cmake.org/Wiki/CMake_FAQ>.
150219

151220
The following CMake variables are declared:
@@ -177,16 +246,6 @@ If you want to build a universal binary for Mac OS X, CMake sets it
177246
all up for you if you use `-DCMAKE_OSX_ARCHITECTURES="i386;x86_64"`
178247
when configuring.
179248

180-
Windows
181-
-------
182-
183-
You need to run the CMake commands from the Visual Studio command
184-
prompt, not the regular or Windows SDK one. Select the right generator
185-
for your version with the `-G "Visual Studio X" option.
186-
187-
See [the website](http://libgit2.github.com/docs/guides/build-and-link/)
188-
for more detailed instructions.
189-
190249
Android
191250
-------
192251

TROUBLESHOOTING.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Troubleshooting libgit2 Problems
2+
================================
3+
4+
CMake Failures
5+
--------------
6+
7+
* **`Asked for OpenSSL TLS backend, but it wasn't found`**
8+
CMake cannot find your SSL/TLS libraries. By default, libgit2 always
9+
builds with HTTPS support, and you are encouraged to install the
10+
OpenSSL libraries for your system (eg, `apt-get install libssl-dev`).
11+
12+
For development, if you simply want to disable HTTPS support entirely,
13+
pass the `-DUSE_HTTPS=OFF` argument to `cmake` when configuring it.

0 commit comments

Comments
 (0)