Skip to content

Commit 0f69a32

Browse files
author
Carson Howard
committed
docs: add documentation to state differences from the git cli
1 parent dc27772 commit 0f69a32

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

docs/differences-from-git-cli.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Differences from the Git CLI
2+
3+
In some instances, the functionality of libgit2 deviates slightly from that of the Git CLI. This can because of technical limitations when developing a library, licensing limitations when converting functionality from the CLI to libgit2, or various other reasons.
4+
5+
Repository and Workdir Path Reporting
6+
-------------------------------------
7+
8+
When retrieving the absolute path of a repository from the Git CLI, one could expect the output to lool like so:
9+
10+
```
11+
$ git rev-parse --absolute-git-dir
12+
=> /home/user/projects/libgit2/.git
13+
```
14+
15+
When retrieving the absolute path of a repository from libgit2, one could expect the output to look like:
16+
17+
```
18+
const char *repo_path = git_repository_path(repo);
19+
printf(repo_path);
20+
=> /home/user/projects/libgit2/.git/
21+
```
22+
23+
Notice the trailing slash. While it would be nice to be able to remove the trailing slash from the `git_repository_path` return value, it is considered a breaking change to do so, and relatively high risk for the benefit.
24+
25+
Retrieving the absolute path to the working directory suffers from the same problem.
26+
27+
Git CLI:
28+
29+
```bash
30+
$ git worktree list
31+
=> /home/user/projects/libgit2
32+
```
33+
34+
libgit2:
35+
36+
```c
37+
const char *workdir_path = git_repository_workdir(repo);
38+
printf(workdir_path);
39+
=> /home/user/projects/libgit2/
40+
```

0 commit comments

Comments
 (0)