From 278819d0a8fdd1c003081fac62eee9a63714083e Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Tue, 11 Mar 2025 12:07:00 +0800 Subject: [PATCH] Add repository_init --- README.md | 3 ++- libgit2/repository.ha | 18 ++++++++++++++++++ libgit2/types.ha | 3 +++ diff --git a/README.md b/README.md index c51ae0e15282b43565db86ebb0cb046392173b48..8a8c3962938dab2cd3d2b545bbe4f0e71ddbd7f1 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,8 @@ 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 diff --git a/libgit2/repository.ha b/libgit2/repository.ha new file mode 100644 index 0000000000000000000000000000000000000000..1a26c63df8489cc09992487a9defb7284001ecaf --- /dev/null +++ b/libgit2/repository.ha @@ -0,0 +1,18 @@ +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; diff --git a/libgit2/types.ha b/libgit2/types.ha index 252f95a2dba1fedbcfbcfe6eda3f42224d9c6fce..d6aa6b195767f5aaa2217cc11d305eb4cc00a0bf 100644 --- a/libgit2/types.ha +++ b/libgit2/types.ha @@ -7,3 +7,6 @@ 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; -- 2.48.1