feat(commit): add ability to create commit with different number of parents

This commit is contained in:
Aleksey Kulikov 2021-08-30 16:45:37 +03:00
parent c90561ed8f
commit 94b4116adf
15 changed files with 217 additions and 260 deletions

View file

@ -38,6 +38,26 @@ Pointer<git_oid> fromSHA(String hex) {
}
}
/// Copy an already raw oid into a git_oid structure.
///
/// Throws a [LibGit2Error] if error occured.
Pointer<git_oid> fromRaw(Array<Uint8> raw) {
final out = calloc<git_oid>();
var rawC = calloc<Uint8>(20);
for (var i = 0; i < 20; i++) {
rawC[i] = raw[i];
}
final error = libgit2.git_oid_fromraw(out, rawC);
calloc.free(rawC);
if (error < 0) {
throw LibGit2Error(libgit2.git_error_last());
} else {
return out;
}
}
/// Format a git_oid into a hex string.
///
/// Throws a [LibGit2Error] if error occured.