Lindenii Project Forge
Login

hare-libgit2

Hare bindings for libgit2 (BROKEN)
Commit info
ID
278819d0a8fdd1c003081fac62eee9a63714083e
Author
Runxi Yu <me@runxiyu.org>
Author date
Tue, 11 Mar 2025 12:07:00 +0800
Committer
Runxi Yu <me@runxiyu.org>
Committer date
Tue, 11 Mar 2025 12:07:36 +0800
Actions
Add repository_init
# Hare bindings for libgit2

This is a set of bindings for [libgit2](https://libgit2.org/).

Most symbols correspond to the libgit2 API directly with the `git_`/`GIT_`
prefix removed.
prefix removed. Where possible, string parameters are accepted as `str` and are
converted to NUL-terminated strings automatically.

## Building and linking

Remember to pass `-lgit2` to `hare build`, or otherwise link against `libgit2`.

## Vendoring 

```
git subtree -P vendor/hare-libgit2/ add ssh://forge.runxiyu.org/hare/:/repos/hare-libgit2/ master
```

## Contributing

Create a branch that begins with `contrib/` and push to the
[main repo](https://forge.runxiyu.org/hare/:/repos/hare-libgit2/)
via SSH directly.

```
git clone ssh://forge.runxiyu.org/hare/:/repos/hare-libgit2/
cd hare-libgit2
git checkout -b contrib/whatever
# edit and commit stuff
git push -u origin HEAD
```

## License

GNU GPL version 2, with an linking exception. See the `COPYING` file for details.
use types::c;


// Creates a new Git repository in the given folder.
//
// is_bare is a boolean that determines whether the repository will be a bare
// repository, or whether it should be created as a working directory with a
// .git inside.
// 
// Returns 0 on success, or an error code.
//
export fn repository_init(out: *nullable *repository, path: str, is_bare: bool) int = {
	let _path = c::fromstr(path);
	let res = _repository_init(out, _path, is_bare);
	free(_path);
	return res;
};
@symbol("git_repository_init") fn _repository_init(out: *nullable *repository, path: *const c::char, is_bare: bool) int;
// Basic type (loose or packed) of any Git object.
export type object_t = enum {
	OBJECT_ANY =     -2, // Object can be any of the following
	OBJECT_INVALID = -1, // Object is invalid.
	OBJECT_COMMIT =   1, // A commit object.
	OBJECT_TREE =     2, // A tree (directory listing) object.
	OBJECT_BLOB =     3, // A file revision object.
	OBJECT_TAG =      4, // An annotated tag object.
};

// Representation of an existing git repository, including all its object contents
export type repository = opaque;