Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
define class <libgit2-error> (<error>)
constant slot libgit2-error-status :: <integer>, required-init-keyword: status:;
constant slot libgit2-error-message :: <string>, init-keyword: message:, init-value: "Unknown error";
end;
define C-mapped-subtype <libgit2-status> (<C-int>)
import-map <integer>,
import-function:
method (result :: <integer>) => (checked :: <integer>)
if (result < 0)
let err = giterr-last();
format-out("ERROR: %s\n", git-error$message(err));
error(make(<libgit2-error>, status: result, message: git-error$message(err)));
else
result;
end;
end;
end;
define C-function git-repository-init
output parameter out_ :: <git-repository**>;
input parameter path_ :: <c-string>;
input parameter is-bare_ :: <C-unsigned-int>;
error-result res :: <libgit2-status>;
c-name: "git_repository_init";
end;
// before
let (err, repo) = git-repository-init("./temp_repo_init_options",
flags: $GIT-REPOSITORY-INIT-MKDIR,
description: "My repository has a custom description.",
origin-url: "http://example.org/");
assert-true(instance?(repo, <git-repository*>));
// after the change
let repo = git-repository-init("./temp_repo_init_options",
flags: $GIT-REPOSITORY-INIT-MKDIR,
description: "My repository has a custom description.",
origin-url: "http://example.org/");
assert-true(instance?(repo, <git-repository*>));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment