mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-04 20:29:08 -04:00
refactor: remove unnecessary local variables
This commit is contained in:
parent
cfa5268af2
commit
20ca75639d
48 changed files with 446 additions and 237 deletions
|
@ -25,20 +25,27 @@ dynamic getAttribute({
|
||||||
calloc.free(nameC);
|
calloc.free(nameC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
}
|
}
|
||||||
|
|
||||||
final attributeValue = libgit2.git_attr_value(out.value);
|
final attributeValue = libgit2.git_attr_value(out.value);
|
||||||
|
|
||||||
if (attributeValue == git_attr_value_t.GIT_ATTR_VALUE_UNSPECIFIED) {
|
if (attributeValue == git_attr_value_t.GIT_ATTR_VALUE_UNSPECIFIED) {
|
||||||
|
calloc.free(out);
|
||||||
return null;
|
return null;
|
||||||
} else if (attributeValue == git_attr_value_t.GIT_ATTR_VALUE_TRUE) {
|
} else if (attributeValue == git_attr_value_t.GIT_ATTR_VALUE_TRUE) {
|
||||||
|
calloc.free(out);
|
||||||
return true;
|
return true;
|
||||||
} else if (attributeValue == git_attr_value_t.GIT_ATTR_VALUE_FALSE) {
|
} else if (attributeValue == git_attr_value_t.GIT_ATTR_VALUE_FALSE) {
|
||||||
|
calloc.free(out);
|
||||||
return false;
|
return false;
|
||||||
} else if (attributeValue == git_attr_value_t.GIT_ATTR_VALUE_STRING) {
|
} else if (attributeValue == git_attr_value_t.GIT_ATTR_VALUE_STRING) {
|
||||||
return out.value.cast<Utf8>().toDartString();
|
final result = out.value.cast<Utf8>().toDartString();
|
||||||
|
calloc.free(out);
|
||||||
|
return result;
|
||||||
} else {
|
} else {
|
||||||
|
calloc.free(out);
|
||||||
throw Exception('The attribute value from libgit2 is invalid');
|
throw Exception('The attribute value from libgit2 is invalid');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import 'libgit2_bindings.dart';
|
||||||
Pointer<git_blame> file({
|
Pointer<git_blame> file({
|
||||||
required Pointer<git_repository> repoPointer,
|
required Pointer<git_repository> repoPointer,
|
||||||
required String path,
|
required String path,
|
||||||
int? flags,
|
required int flags,
|
||||||
int? minMatchCharacters,
|
int? minMatchCharacters,
|
||||||
Oid? newestCommit,
|
Oid? newestCommit,
|
||||||
Oid? oldestCommit,
|
Oid? oldestCommit,
|
||||||
|
@ -27,12 +27,13 @@ Pointer<git_blame> file({
|
||||||
);
|
);
|
||||||
|
|
||||||
if (optionsError < 0) {
|
if (optionsError < 0) {
|
||||||
|
calloc.free(out);
|
||||||
|
calloc.free(pathC);
|
||||||
|
calloc.free(options);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags != null) {
|
options.ref.flags = flags;
|
||||||
options.ref.flags = flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (minMatchCharacters != null) {
|
if (minMatchCharacters != null) {
|
||||||
options.ref.min_match_characters = minMatchCharacters;
|
options.ref.min_match_characters = minMatchCharacters;
|
||||||
|
@ -56,7 +57,11 @@ Pointer<git_blame> file({
|
||||||
|
|
||||||
final error = libgit2.git_blame_file(out, repoPointer, pathC, options);
|
final error = libgit2.git_blame_file(out, repoPointer, pathC, options);
|
||||||
|
|
||||||
|
calloc.free(pathC);
|
||||||
|
calloc.free(options);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
|
|
@ -15,6 +15,7 @@ Pointer<git_blob> lookup({
|
||||||
final error = libgit2.git_blob_lookup(out, repoPointer, oidPointer);
|
final error = libgit2.git_blob_lookup(out, repoPointer, oidPointer);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -30,8 +31,7 @@ Pointer<git_oid> id(Pointer<git_blob> blob) => libgit2.git_blob_id(blob);
|
||||||
/// Searching for NUL bytes and looking for a reasonable ratio of printable to
|
/// Searching for NUL bytes and looking for a reasonable ratio of printable to
|
||||||
/// non-printable characters among the first 8000 bytes.
|
/// non-printable characters among the first 8000 bytes.
|
||||||
bool isBinary(Pointer<git_blob> blob) {
|
bool isBinary(Pointer<git_blob> blob) {
|
||||||
final result = libgit2.git_blob_is_binary(blob);
|
return libgit2.git_blob_is_binary(blob) == 1 ? true : false;
|
||||||
return result == 1 ? true : false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a read-only buffer with the raw content of a blob.
|
/// Get a read-only buffer with the raw content of a blob.
|
||||||
|
@ -40,8 +40,7 @@ bool isBinary(Pointer<git_blob> blob) {
|
||||||
/// internally by the object and shall not be free'd. The pointer may be invalidated
|
/// internally by the object and shall not be free'd. The pointer may be invalidated
|
||||||
/// at a later time.
|
/// at a later time.
|
||||||
String content(Pointer<git_blob> blob) {
|
String content(Pointer<git_blob> blob) {
|
||||||
final result = libgit2.git_blob_rawcontent(blob);
|
return libgit2.git_blob_rawcontent(blob).cast<Utf8>().toDartString();
|
||||||
return result.cast<Utf8>().toDartString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the size in bytes of the contents of a blob.
|
/// Get the size in bytes of the contents of a blob.
|
||||||
|
@ -57,12 +56,17 @@ Pointer<git_oid> create({
|
||||||
}) {
|
}) {
|
||||||
final out = calloc<git_oid>();
|
final out = calloc<git_oid>();
|
||||||
final bufferC = buffer.toNativeUtf8().cast<Void>();
|
final bufferC = buffer.toNativeUtf8().cast<Void>();
|
||||||
final error =
|
final error = libgit2.git_blob_create_from_buffer(
|
||||||
libgit2.git_blob_create_from_buffer(out, repoPointer, bufferC, len);
|
out,
|
||||||
|
repoPointer,
|
||||||
|
bufferC,
|
||||||
|
len,
|
||||||
|
);
|
||||||
|
|
||||||
calloc.free(bufferC);
|
calloc.free(bufferC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out;
|
return out;
|
||||||
|
@ -79,12 +83,16 @@ Pointer<git_oid> createFromWorkdir({
|
||||||
}) {
|
}) {
|
||||||
final out = calloc<git_oid>();
|
final out = calloc<git_oid>();
|
||||||
final relativePathC = relativePath.toNativeUtf8().cast<Int8>();
|
final relativePathC = relativePath.toNativeUtf8().cast<Int8>();
|
||||||
final error =
|
final error = libgit2.git_blob_create_from_workdir(
|
||||||
libgit2.git_blob_create_from_workdir(out, repoPointer, relativePathC);
|
out,
|
||||||
|
repoPointer,
|
||||||
|
relativePathC,
|
||||||
|
);
|
||||||
|
|
||||||
calloc.free(relativePathC);
|
calloc.free(relativePathC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out;
|
return out;
|
||||||
|
@ -102,7 +110,10 @@ Pointer<git_oid> createFromDisk({
|
||||||
final pathC = path.toNativeUtf8().cast<Int8>();
|
final pathC = path.toNativeUtf8().cast<Int8>();
|
||||||
final error = libgit2.git_blob_create_from_disk(out, repoPointer, pathC);
|
final error = libgit2.git_blob_create_from_disk(out, repoPointer, pathC);
|
||||||
|
|
||||||
|
calloc.free(pathC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out;
|
return out;
|
||||||
|
|
|
@ -21,6 +21,7 @@ List<Pointer<git_reference>> list({
|
||||||
);
|
);
|
||||||
|
|
||||||
if (iteratorError < 0) {
|
if (iteratorError < 0) {
|
||||||
|
libgit2.git_branch_iterator_free(iterator.value);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,6 +66,7 @@ Pointer<git_reference> lookup({
|
||||||
calloc.free(branchNameC);
|
calloc.free(branchNameC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -101,6 +103,7 @@ Pointer<git_reference> create({
|
||||||
calloc.free(branchNameC);
|
calloc.free(branchNameC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -109,17 +112,12 @@ Pointer<git_reference> create({
|
||||||
|
|
||||||
/// Delete an existing branch reference.
|
/// Delete an existing branch reference.
|
||||||
///
|
///
|
||||||
/// Note that if the deletion succeeds, the reference object will not be valid anymore,
|
|
||||||
/// and will be freed.
|
|
||||||
///
|
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void delete(Pointer<git_reference> branch) {
|
void delete(Pointer<git_reference> branch) {
|
||||||
final error = libgit2.git_branch_delete(branch);
|
final error = libgit2.git_branch_delete(branch);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
|
||||||
reference_bindings.free(branch);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,15 +134,19 @@ void rename({
|
||||||
final out = calloc<Pointer<git_reference>>();
|
final out = calloc<Pointer<git_reference>>();
|
||||||
final newBranchNameC = newBranchName.toNativeUtf8().cast<Int8>();
|
final newBranchNameC = newBranchName.toNativeUtf8().cast<Int8>();
|
||||||
final forceC = force ? 1 : 0;
|
final forceC = force ? 1 : 0;
|
||||||
final error =
|
final error = libgit2.git_branch_move(
|
||||||
libgit2.git_branch_move(out, branchPointer, newBranchNameC, forceC);
|
out,
|
||||||
|
branchPointer,
|
||||||
|
newBranchNameC,
|
||||||
|
forceC,
|
||||||
|
);
|
||||||
|
|
||||||
calloc.free(newBranchNameC);
|
calloc.free(newBranchNameC);
|
||||||
|
reference_bindings.free(out.value);
|
||||||
|
calloc.free(out);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
|
||||||
reference_bindings.free(out.value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,6 +190,7 @@ String name(Pointer<git_reference> ref) {
|
||||||
final error = libgit2.git_branch_name(out, ref);
|
final error = libgit2.git_branch_name(out, ref);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
final result = out.value.cast<Utf8>().toDartString();
|
final result = out.value.cast<Utf8>().toDartString();
|
||||||
|
|
|
@ -33,7 +33,6 @@ void head({
|
||||||
for (final p in pathPointers) {
|
for (final p in pathPointers) {
|
||||||
calloc.free(p);
|
calloc.free(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
calloc.free(strArray);
|
calloc.free(strArray);
|
||||||
calloc.free(optsC);
|
calloc.free(optsC);
|
||||||
|
|
||||||
|
@ -65,7 +64,6 @@ void index({
|
||||||
for (final p in pathPointers) {
|
for (final p in pathPointers) {
|
||||||
calloc.free(p);
|
calloc.free(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
calloc.free(strArray);
|
calloc.free(strArray);
|
||||||
calloc.free(optsC);
|
calloc.free(optsC);
|
||||||
|
|
||||||
|
@ -99,7 +97,6 @@ void tree({
|
||||||
for (final p in pathPointers) {
|
for (final p in pathPointers) {
|
||||||
calloc.free(p);
|
calloc.free(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
calloc.free(strArray);
|
calloc.free(strArray);
|
||||||
calloc.free(optsC);
|
calloc.free(optsC);
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ Pointer<git_commit> lookup({
|
||||||
final error = libgit2.git_commit_lookup(out, repoPointer, oidPointer);
|
final error = libgit2.git_commit_lookup(out, repoPointer, oidPointer);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -40,6 +41,7 @@ Pointer<git_commit> lookupPrefix({
|
||||||
);
|
);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -68,6 +70,7 @@ Pointer<Pointer<git_annotated_commit>> annotatedLookup({
|
||||||
);
|
);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out;
|
return out;
|
||||||
|
@ -127,6 +130,7 @@ Pointer<git_oid> create({
|
||||||
calloc.free(parentsC);
|
calloc.free(parentsC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out;
|
return out;
|
||||||
|
@ -139,20 +143,14 @@ Pointer<git_oid> create({
|
||||||
/// in that case UTF-8 is assumed.
|
/// in that case UTF-8 is assumed.
|
||||||
String messageEncoding(Pointer<git_commit> commit) {
|
String messageEncoding(Pointer<git_commit> commit) {
|
||||||
final result = libgit2.git_commit_message_encoding(commit);
|
final result = libgit2.git_commit_message_encoding(commit);
|
||||||
|
return result == nullptr ? 'utf-8' : result.cast<Utf8>().toDartString();
|
||||||
if (result == nullptr) {
|
|
||||||
return 'utf-8';
|
|
||||||
} else {
|
|
||||||
return result.cast<Utf8>().toDartString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the full message of a commit.
|
/// Get the full message of a commit.
|
||||||
///
|
///
|
||||||
/// The returned message will be slightly prettified by removing any potential leading newlines.
|
/// The returned message will be slightly prettified by removing any potential leading newlines.
|
||||||
String message(Pointer<git_commit> commit) {
|
String message(Pointer<git_commit> commit) {
|
||||||
final out = libgit2.git_commit_message(commit);
|
return libgit2.git_commit_message(commit).cast<Utf8>().toDartString();
|
||||||
return out.cast<Utf8>().toDartString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the id of a commit.
|
/// Get the id of a commit.
|
||||||
|
@ -215,6 +213,8 @@ Pointer<git_index> revertCommit({
|
||||||
libgit2.git_merge_options_init(opts, GIT_MERGE_OPTIONS_VERSION);
|
libgit2.git_merge_options_init(opts, GIT_MERGE_OPTIONS_VERSION);
|
||||||
|
|
||||||
if (optsError < 0) {
|
if (optsError < 0) {
|
||||||
|
calloc.free(out);
|
||||||
|
calloc.free(opts);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,6 +230,7 @@ Pointer<git_index> revertCommit({
|
||||||
calloc.free(opts);
|
calloc.free(opts);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
|
|
@ -15,6 +15,7 @@ Pointer<git_config> newConfig() {
|
||||||
final error = libgit2.git_config_new(out);
|
final error = libgit2.git_config_new(out);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -32,6 +33,7 @@ Pointer<git_config> open(String path) {
|
||||||
calloc.free(pathC);
|
calloc.free(pathC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -50,6 +52,7 @@ Pointer<git_config> openDefault() {
|
||||||
final error = libgit2.git_config_open_default(out);
|
final error = libgit2.git_config_open_default(out);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -74,9 +77,12 @@ String findGlobal() {
|
||||||
final error = libgit2.git_config_find_global(out);
|
final error = libgit2.git_config_find_global(out);
|
||||||
|
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw Error();
|
throw Error();
|
||||||
} else {
|
} else {
|
||||||
return out.ref.ptr.cast<Utf8>().toDartString();
|
final result = out.ref.ptr.cast<Utf8>().toDartString();
|
||||||
|
calloc.free(out);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,9 +96,12 @@ String findSystem() {
|
||||||
final error = libgit2.git_config_find_system(out);
|
final error = libgit2.git_config_find_system(out);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.ref.ptr.cast<Utf8>().toDartString();
|
final result = out.ref.ptr.cast<Utf8>().toDartString();
|
||||||
|
calloc.free(out);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,9 +116,12 @@ String findXdg() {
|
||||||
final error = libgit2.git_config_find_xdg(out);
|
final error = libgit2.git_config_find_xdg(out);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.ref.ptr.cast<Utf8>().toDartString();
|
final result = out.ref.ptr.cast<Utf8>().toDartString();
|
||||||
|
calloc.free(out);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,6 +137,7 @@ Pointer<git_config> snapshot(Pointer<git_config> config) {
|
||||||
final error = libgit2.git_config_snapshot(out, config);
|
final error = libgit2.git_config_snapshot(out, config);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -145,6 +158,7 @@ Pointer<git_config_entry> getEntry({
|
||||||
calloc.free(name);
|
calloc.free(name);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
|
|
@ -19,6 +19,7 @@ Pointer<git_credential> username(String username) {
|
||||||
calloc.free(usernameC);
|
calloc.free(usernameC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -36,13 +37,17 @@ Pointer<git_credential> userPass({
|
||||||
final usernameC = username.toNativeUtf8().cast<Int8>();
|
final usernameC = username.toNativeUtf8().cast<Int8>();
|
||||||
final passwordC = password.toNativeUtf8().cast<Int8>();
|
final passwordC = password.toNativeUtf8().cast<Int8>();
|
||||||
|
|
||||||
final error =
|
final error = libgit2.git_credential_userpass_plaintext_new(
|
||||||
libgit2.git_credential_userpass_plaintext_new(out, usernameC, passwordC);
|
out,
|
||||||
|
usernameC,
|
||||||
|
passwordC,
|
||||||
|
);
|
||||||
|
|
||||||
calloc.free(usernameC);
|
calloc.free(usernameC);
|
||||||
calloc.free(passwordC);
|
calloc.free(passwordC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -78,6 +83,7 @@ Pointer<git_credential> sshKey({
|
||||||
calloc.free(passPhraseC);
|
calloc.free(passPhraseC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -96,6 +102,7 @@ Pointer<git_credential> sshKeyFromAgent(String username) {
|
||||||
calloc.free(usernameC);
|
calloc.free(usernameC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -131,6 +138,7 @@ Pointer<git_credential> sshKeyFromMemory({
|
||||||
calloc.free(passPhraseC);
|
calloc.free(passPhraseC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
|
|
@ -33,6 +33,7 @@ Pointer<git_describe_result> commit({
|
||||||
calloc.free(opts);
|
calloc.free(opts);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -68,6 +69,7 @@ Pointer<git_describe_result> workdir({
|
||||||
calloc.free(opts);
|
calloc.free(opts);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -91,6 +93,8 @@ String format({
|
||||||
);
|
);
|
||||||
|
|
||||||
if (optsError < 0) {
|
if (optsError < 0) {
|
||||||
|
calloc.free(out);
|
||||||
|
calloc.free(opts);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +110,10 @@ String format({
|
||||||
|
|
||||||
final error = libgit2.git_describe_format(out, describeResultPointer, opts);
|
final error = libgit2.git_describe_format(out, describeResultPointer, opts);
|
||||||
|
|
||||||
|
calloc.free(opts);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
final result = out.ref.ptr.cast<Utf8>().toDartString();
|
final result = out.ref.ptr.cast<Utf8>().toDartString();
|
||||||
|
|
|
@ -150,6 +150,7 @@ Pointer<git_diff> parse(String content) {
|
||||||
calloc.free(contentC);
|
calloc.free(contentC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -173,8 +174,16 @@ void findSimilar({
|
||||||
required int renameLimit,
|
required int renameLimit,
|
||||||
}) {
|
}) {
|
||||||
final opts = calloc<git_diff_find_options>();
|
final opts = calloc<git_diff_find_options>();
|
||||||
final optsError =
|
final optsError = libgit2.git_diff_find_options_init(
|
||||||
libgit2.git_diff_find_options_init(opts, GIT_DIFF_FIND_OPTIONS_VERSION);
|
opts,
|
||||||
|
GIT_DIFF_FIND_OPTIONS_VERSION,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (optsError < 0) {
|
||||||
|
calloc.free(opts);
|
||||||
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
|
}
|
||||||
|
|
||||||
opts.ref.flags = flags;
|
opts.ref.flags = flags;
|
||||||
opts.ref.rename_threshold = renameThreshold;
|
opts.ref.rename_threshold = renameThreshold;
|
||||||
opts.ref.copy_threshold = copyThreshold;
|
opts.ref.copy_threshold = copyThreshold;
|
||||||
|
@ -182,17 +191,13 @@ void findSimilar({
|
||||||
opts.ref.break_rewrite_threshold = breakRewriteThreshold;
|
opts.ref.break_rewrite_threshold = breakRewriteThreshold;
|
||||||
opts.ref.rename_limit = renameLimit;
|
opts.ref.rename_limit = renameLimit;
|
||||||
|
|
||||||
if (optsError < 0) {
|
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
|
||||||
}
|
|
||||||
|
|
||||||
final error = libgit2.git_diff_find_similar(diffPointer, opts);
|
final error = libgit2.git_diff_find_similar(diffPointer, opts);
|
||||||
|
|
||||||
|
calloc.free(opts);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
}
|
}
|
||||||
|
|
||||||
calloc.free(opts);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Calculate the patch ID for the given patch.
|
/// Calculate the patch ID for the given patch.
|
||||||
|
@ -210,6 +215,7 @@ Pointer<git_oid> patchId(Pointer<git_diff> diff) {
|
||||||
final error = libgit2.git_diff_patchid(out, diff, nullptr);
|
final error = libgit2.git_diff_patchid(out, diff, nullptr);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out;
|
return out;
|
||||||
|
@ -239,8 +245,7 @@ Pointer<git_diff_delta> getDeltaByIndex({
|
||||||
/// value into these letters for your own purposes. [GitDelta.untracked] will return
|
/// value into these letters for your own purposes. [GitDelta.untracked] will return
|
||||||
/// a space (i.e. ' ').
|
/// a space (i.e. ' ').
|
||||||
String statusChar(int status) {
|
String statusChar(int status) {
|
||||||
final result = libgit2.git_diff_status_char(status);
|
return String.fromCharCode(libgit2.git_diff_status_char(status));
|
||||||
return String.fromCharCode(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Accumulate diff statistics for all patches.
|
/// Accumulate diff statistics for all patches.
|
||||||
|
@ -251,6 +256,7 @@ Pointer<git_diff_stats> stats(Pointer<git_diff> diff) {
|
||||||
final error = libgit2.git_diff_get_stats(out, diff);
|
final error = libgit2.git_diff_get_stats(out, diff);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -281,6 +287,7 @@ String statsPrint({
|
||||||
final error = libgit2.git_diff_stats_to_buf(out, statsPointer, format, width);
|
final error = libgit2.git_diff_stats_to_buf(out, statsPointer, format, width);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
final result = out.ref.ptr.cast<Utf8>().toDartString();
|
final result = out.ref.ptr.cast<Utf8>().toDartString();
|
||||||
|
|
|
@ -49,5 +49,8 @@ List<int> aheadBehind({
|
||||||
upstreamPointer,
|
upstreamPointer,
|
||||||
);
|
);
|
||||||
|
|
||||||
return [ahead.value, behind.value];
|
final result = [ahead.value, behind.value];
|
||||||
|
calloc.free(ahead);
|
||||||
|
calloc.free(behind);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,7 @@ Pointer<git_oid> writeTree(Pointer<git_index> index) {
|
||||||
final error = libgit2.git_index_write_tree(out, index);
|
final error = libgit2.git_index_write_tree(out, index);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out;
|
return out;
|
||||||
|
@ -79,6 +80,7 @@ Pointer<git_oid> writeTreeTo({
|
||||||
final error = libgit2.git_index_write_tree_to(out, indexPointer, repoPointer);
|
final error = libgit2.git_index_write_tree_to(out, indexPointer, repoPointer);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out;
|
return out;
|
||||||
|
@ -210,9 +212,9 @@ void addAll({
|
||||||
required List<String> pathspec,
|
required List<String> pathspec,
|
||||||
}) {
|
}) {
|
||||||
var pathspecC = calloc<git_strarray>();
|
var pathspecC = calloc<git_strarray>();
|
||||||
final List<Pointer<Int8>> pathPointers =
|
final pathPointers =
|
||||||
pathspec.map((e) => e.toNativeUtf8().cast<Int8>()).toList();
|
pathspec.map((e) => e.toNativeUtf8().cast<Int8>()).toList();
|
||||||
final Pointer<Pointer<Int8>> strArray = calloc(pathspec.length);
|
final strArray = calloc<Pointer<Int8>>(pathspec.length);
|
||||||
|
|
||||||
for (var i = 0; i < pathspec.length; i++) {
|
for (var i = 0; i < pathspec.length; i++) {
|
||||||
strArray[i] = pathPointers[i];
|
strArray[i] = pathPointers[i];
|
||||||
|
@ -277,9 +279,9 @@ void removeAll({
|
||||||
required List<String> pathspec,
|
required List<String> pathspec,
|
||||||
}) {
|
}) {
|
||||||
final pathspecC = calloc<git_strarray>();
|
final pathspecC = calloc<git_strarray>();
|
||||||
final List<Pointer<Int8>> pathPointers =
|
final pathPointers =
|
||||||
pathspec.map((e) => e.toNativeUtf8().cast<Int8>()).toList();
|
pathspec.map((e) => e.toNativeUtf8().cast<Int8>()).toList();
|
||||||
final Pointer<Pointer<Int8>> strArray = calloc(pathspec.length);
|
final strArray = calloc<Pointer<Int8>>(pathspec.length);
|
||||||
|
|
||||||
for (var i = 0; i < pathspec.length; i++) {
|
for (var i = 0; i < pathspec.length; i++) {
|
||||||
strArray[i] = pathPointers[i];
|
strArray[i] = pathPointers[i];
|
||||||
|
@ -318,10 +320,13 @@ List<Map<String, Pointer<git_index_entry>>> conflictList(
|
||||||
Pointer<git_index> index,
|
Pointer<git_index> index,
|
||||||
) {
|
) {
|
||||||
final iterator = calloc<Pointer<git_index_conflict_iterator>>();
|
final iterator = calloc<Pointer<git_index_conflict_iterator>>();
|
||||||
final iteratorError =
|
final iteratorError = libgit2.git_index_conflict_iterator_new(
|
||||||
libgit2.git_index_conflict_iterator_new(iterator, index);
|
iterator,
|
||||||
|
index,
|
||||||
|
);
|
||||||
|
|
||||||
if (iteratorError < 0) {
|
if (iteratorError < 0) {
|
||||||
|
calloc.free(iterator);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ Pointer<git_mailmap> init() {
|
||||||
final error = libgit2.git_mailmap_new(out);
|
final error = libgit2.git_mailmap_new(out);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -33,6 +34,7 @@ Pointer<git_mailmap> fromBuffer(String buffer) {
|
||||||
calloc.free(bufferC);
|
calloc.free(bufferC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -55,6 +57,7 @@ Pointer<git_mailmap> fromRepository(Pointer<git_repository> repo) {
|
||||||
final error = libgit2.git_mailmap_from_repository(out, repo);
|
final error = libgit2.git_mailmap_from_repository(out, repo);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -114,6 +117,7 @@ Pointer<git_signature> resolveSignature({
|
||||||
);
|
);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
|
|
@ -16,6 +16,7 @@ Pointer<git_oid> mergeBase({
|
||||||
final error = libgit2.git_merge_base(out, repoPointer, aPointer, bPointer);
|
final error = libgit2.git_merge_base(out, repoPointer, aPointer, bPointer);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out;
|
return out;
|
||||||
|
@ -45,6 +46,8 @@ List<int> analysis({
|
||||||
var result = <int>[];
|
var result = <int>[];
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(analysisOut);
|
||||||
|
calloc.free(preferenceOut);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
result.add(analysisOut.value);
|
result.add(analysisOut.value);
|
||||||
|
@ -67,10 +70,28 @@ void merge({
|
||||||
required int theirHeadsLen,
|
required int theirHeadsLen,
|
||||||
}) {
|
}) {
|
||||||
final mergeOpts = calloc<git_merge_options>();
|
final mergeOpts = calloc<git_merge_options>();
|
||||||
libgit2.git_merge_options_init(mergeOpts, GIT_MERGE_OPTIONS_VERSION);
|
final mergeError = libgit2.git_merge_options_init(
|
||||||
|
mergeOpts,
|
||||||
|
GIT_MERGE_OPTIONS_VERSION,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (mergeError < 0) {
|
||||||
|
calloc.free(mergeOpts);
|
||||||
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
|
}
|
||||||
|
|
||||||
final checkoutOpts = calloc<git_checkout_options>();
|
final checkoutOpts = calloc<git_checkout_options>();
|
||||||
libgit2.git_checkout_options_init(checkoutOpts, GIT_CHECKOUT_OPTIONS_VERSION);
|
final checkoutError = libgit2.git_checkout_options_init(
|
||||||
|
checkoutOpts,
|
||||||
|
GIT_CHECKOUT_OPTIONS_VERSION,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (checkoutError < 0) {
|
||||||
|
calloc.free(mergeOpts);
|
||||||
|
calloc.free(checkoutOpts);
|
||||||
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
|
}
|
||||||
|
|
||||||
checkoutOpts.ref.checkout_strategy =
|
checkoutOpts.ref.checkout_strategy =
|
||||||
git_checkout_strategy_t.GIT_CHECKOUT_SAFE |
|
git_checkout_strategy_t.GIT_CHECKOUT_SAFE |
|
||||||
git_checkout_strategy_t.GIT_CHECKOUT_RECREATE_MISSING;
|
git_checkout_strategy_t.GIT_CHECKOUT_RECREATE_MISSING;
|
||||||
|
@ -83,6 +104,9 @@ void merge({
|
||||||
checkoutOpts,
|
checkoutOpts,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
calloc.free(mergeOpts);
|
||||||
|
calloc.free(checkoutOpts);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
}
|
}
|
||||||
|
@ -110,6 +134,7 @@ String mergeFileFromIndex({
|
||||||
);
|
);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
final result = out.ref.ptr.cast<Utf8>().toDartString(length: out.ref.len);
|
final result = out.ref.ptr.cast<Utf8>().toDartString(length: out.ref.len);
|
||||||
|
@ -152,6 +177,7 @@ Pointer<git_index> mergeCommits({
|
||||||
calloc.free(opts);
|
calloc.free(opts);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -194,6 +220,7 @@ Pointer<git_index> mergeTrees({
|
||||||
calloc.free(opts);
|
calloc.free(opts);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -207,13 +234,24 @@ void cherryPick({
|
||||||
required Pointer<git_repository> repoPointer,
|
required Pointer<git_repository> repoPointer,
|
||||||
required Pointer<git_commit> commitPointer,
|
required Pointer<git_commit> commitPointer,
|
||||||
}) {
|
}) {
|
||||||
final opts = calloc<git_cherrypick_options>(sizeOf<git_cherrypick_options>());
|
final opts = calloc<git_cherrypick_options>();
|
||||||
libgit2.git_cherrypick_options_init(opts, GIT_CHERRYPICK_OPTIONS_VERSION);
|
final optsError = libgit2.git_cherrypick_options_init(
|
||||||
|
opts,
|
||||||
|
GIT_CHERRYPICK_OPTIONS_VERSION,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (optsError < 0) {
|
||||||
|
calloc.free(opts);
|
||||||
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
|
}
|
||||||
|
|
||||||
opts.ref.checkout_opts.checkout_strategy =
|
opts.ref.checkout_opts.checkout_strategy =
|
||||||
git_checkout_strategy_t.GIT_CHECKOUT_SAFE;
|
git_checkout_strategy_t.GIT_CHECKOUT_SAFE;
|
||||||
|
|
||||||
final error = libgit2.git_cherrypick(repoPointer, commitPointer, opts);
|
final error = libgit2.git_cherrypick(repoPointer, commitPointer, opts);
|
||||||
|
|
||||||
|
calloc.free(opts);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
}
|
}
|
||||||
|
@ -231,6 +269,7 @@ Pointer<git_merge_options> _initMergeOptions({
|
||||||
);
|
);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(opts);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ List<Map<String, Pointer>> list(Pointer<git_repository> repo) {
|
||||||
final iteratorError = libgit2.git_note_iterator_new(iterator, repo, notesRef);
|
final iteratorError = libgit2.git_note_iterator_new(iterator, repo, notesRef);
|
||||||
|
|
||||||
if (iteratorError < 0) {
|
if (iteratorError < 0) {
|
||||||
|
calloc.free(iterator);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +33,9 @@ List<Map<String, Pointer>> list(Pointer<git_repository> repo) {
|
||||||
calloc.free(noteId);
|
calloc.free(noteId);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
|
calloc.free(annotatedId);
|
||||||
|
calloc.free(iterator);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
result.add({'note': out.value, 'annotatedId': annotatedId});
|
result.add({'note': out.value, 'annotatedId': annotatedId});
|
||||||
|
@ -64,6 +68,7 @@ Pointer<git_note> lookup({
|
||||||
calloc.free(notesRefC);
|
calloc.free(notesRefC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -101,6 +106,7 @@ Pointer<git_oid> create({
|
||||||
calloc.free(noteC);
|
calloc.free(noteC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out;
|
return out;
|
||||||
|
|
|
@ -26,6 +26,7 @@ Pointer<git_object> lookup({
|
||||||
final error = libgit2.git_object_lookup(out, repoPointer, oidPointer, type);
|
final error = libgit2.git_object_lookup(out, repoPointer, oidPointer, type);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
|
|
@ -17,6 +17,7 @@ Pointer<git_odb> create() {
|
||||||
final error = libgit2.git_odb_new(out);
|
final error = libgit2.git_odb_new(out);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -65,6 +66,7 @@ Pointer<git_oid> existsPrefix({
|
||||||
);
|
);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out;
|
return out;
|
||||||
|
@ -76,8 +78,7 @@ bool exists({
|
||||||
required Pointer<git_odb> odbPointer,
|
required Pointer<git_odb> odbPointer,
|
||||||
required Pointer<git_oid> oidPointer,
|
required Pointer<git_oid> oidPointer,
|
||||||
}) {
|
}) {
|
||||||
final result = libgit2.git_odb_exists(odbPointer, oidPointer);
|
return libgit2.git_odb_exists(odbPointer, oidPointer) == 1 ? true : false;
|
||||||
return result == 1 ? true : false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// List of objects in the database.
|
/// List of objects in the database.
|
||||||
|
@ -100,11 +101,10 @@ int _forEachCb(
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
List<Oid> objects(Pointer<git_odb> odb) {
|
List<Oid> objects(Pointer<git_odb> odb) {
|
||||||
const except = -1;
|
const except = -1;
|
||||||
final payload = calloc<Pointer<git_oid>>();
|
|
||||||
final cb =
|
final cb =
|
||||||
Pointer.fromFunction<Int32 Function(Pointer<git_oid>, Pointer<Void>)>(
|
Pointer.fromFunction<Int32 Function(Pointer<git_oid>, Pointer<Void>)>(
|
||||||
_forEachCb, except);
|
_forEachCb, except);
|
||||||
final error = libgit2.git_odb_foreach(odb, cb, payload.cast());
|
final error = libgit2.git_odb_foreach(odb, cb, nullptr);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
_objects.clear();
|
_objects.clear();
|
||||||
|
@ -133,6 +133,7 @@ Pointer<git_odb_object> read({
|
||||||
final error = libgit2.git_odb_read(out, odbPointer, oidPointer);
|
final error = libgit2.git_odb_read(out, odbPointer, oidPointer);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -155,9 +156,7 @@ int objectType(Pointer<git_odb_object> object) {
|
||||||
///
|
///
|
||||||
/// This is the uncompressed, raw data as read from the ODB, without the leading header.
|
/// This is the uncompressed, raw data as read from the ODB, without the leading header.
|
||||||
String objectData(Pointer<git_odb_object> object) {
|
String objectData(Pointer<git_odb_object> object) {
|
||||||
final out = libgit2.git_odb_object_data(object);
|
return libgit2.git_odb_object_data(object).cast<Utf8>().toDartString();
|
||||||
|
|
||||||
return out.cast<Utf8>().toDartString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the size of an ODB object.
|
/// Return the size of an ODB object.
|
||||||
|
@ -192,6 +191,7 @@ Pointer<git_oid> write({
|
||||||
);
|
);
|
||||||
|
|
||||||
if (streamError < 0) {
|
if (streamError < 0) {
|
||||||
|
libgit2.git_odb_stream_free(stream.value);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,6 +203,7 @@ Pointer<git_oid> write({
|
||||||
);
|
);
|
||||||
|
|
||||||
if (writeError < 0) {
|
if (writeError < 0) {
|
||||||
|
calloc.free(buffer);
|
||||||
libgit2.git_odb_stream_free(stream.value);
|
libgit2.git_odb_stream_free(stream.value);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
}
|
}
|
||||||
|
@ -217,6 +218,7 @@ Pointer<git_oid> write({
|
||||||
libgit2.git_odb_stream_free(stream.value);
|
libgit2.git_odb_stream_free(stream.value);
|
||||||
|
|
||||||
if (finalizeError < 0) {
|
if (finalizeError < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out;
|
return out;
|
||||||
|
@ -237,6 +239,7 @@ Pointer<git_odb_backend> getBackend({
|
||||||
final error = libgit2.git_odb_get_backend(out, odbPointer, position);
|
final error = libgit2.git_odb_get_backend(out, odbPointer, position);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
|
|
@ -13,9 +13,11 @@ Pointer<git_oid> fromStrN(String hex) {
|
||||||
final out = calloc<git_oid>();
|
final out = calloc<git_oid>();
|
||||||
final str = hex.toNativeUtf8().cast<Int8>();
|
final str = hex.toNativeUtf8().cast<Int8>();
|
||||||
final error = libgit2.git_oid_fromstrn(out, str, hex.length);
|
final error = libgit2.git_oid_fromstrn(out, str, hex.length);
|
||||||
|
|
||||||
calloc.free(str);
|
calloc.free(str);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out;
|
return out;
|
||||||
|
@ -29,9 +31,11 @@ Pointer<git_oid> fromSHA(String hex) {
|
||||||
final out = calloc<git_oid>();
|
final out = calloc<git_oid>();
|
||||||
final str = hex.toNativeUtf8().cast<Int8>();
|
final str = hex.toNativeUtf8().cast<Int8>();
|
||||||
final error = libgit2.git_oid_fromstr(out, str);
|
final error = libgit2.git_oid_fromstr(out, str);
|
||||||
|
|
||||||
calloc.free(str);
|
calloc.free(str);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out;
|
return out;
|
||||||
|
@ -52,6 +56,7 @@ Pointer<git_oid> fromRaw(Array<Uint8> raw) {
|
||||||
calloc.free(rawC);
|
calloc.free(rawC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out;
|
return out;
|
||||||
|
@ -64,13 +69,13 @@ Pointer<git_oid> fromRaw(Array<Uint8> raw) {
|
||||||
String toSHA(Pointer<git_oid> id) {
|
String toSHA(Pointer<git_oid> id) {
|
||||||
final out = calloc<Int8>(40);
|
final out = calloc<Int8>(40);
|
||||||
final error = libgit2.git_oid_fmt(out, id);
|
final error = libgit2.git_oid_fmt(out, id);
|
||||||
final result = out.cast<Utf8>().toDartString(length: 40);
|
|
||||||
|
|
||||||
calloc.free(out);
|
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
|
final result = out.cast<Utf8>().toDartString(length: 40);
|
||||||
|
calloc.free(out);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,6 +98,7 @@ Pointer<git_oid> copy(Pointer<git_oid> src) {
|
||||||
final error = libgit2.git_oid_cpy(out, src);
|
final error = libgit2.git_oid_cpy(out, src);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out;
|
return out;
|
||||||
|
|
|
@ -12,6 +12,7 @@ Pointer<git_packbuilder> init(Pointer<git_repository> repo) {
|
||||||
final error = libgit2.git_packbuilder_new(out, repo);
|
final error = libgit2.git_packbuilder_new(out, repo);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
|
|
@ -43,13 +43,12 @@ Map<String, dynamic> fromBuffers({
|
||||||
opts,
|
opts,
|
||||||
);
|
);
|
||||||
|
|
||||||
final result = <String, dynamic>{};
|
|
||||||
|
|
||||||
calloc.free(oldAsPathC);
|
calloc.free(oldAsPathC);
|
||||||
calloc.free(newAsPathC);
|
calloc.free(newAsPathC);
|
||||||
calloc.free(opts);
|
calloc.free(opts);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
calloc.free(oldBufferC);
|
calloc.free(oldBufferC);
|
||||||
calloc.free(newBufferC);
|
calloc.free(newBufferC);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
|
@ -57,10 +56,7 @@ Map<String, dynamic> fromBuffers({
|
||||||
// Returning map with pointers to patch and buffers because patch object does not
|
// Returning map with pointers to patch and buffers because patch object does not
|
||||||
// have refenrece to underlying buffers or blobs. So if the buffer or blob is freed/removed
|
// have refenrece to underlying buffers or blobs. So if the buffer or blob is freed/removed
|
||||||
// the patch text becomes corrupted.
|
// the patch text becomes corrupted.
|
||||||
result['patch'] = out.value;
|
return {'patch': out.value, 'a': oldBufferC, 'b': newBufferC};
|
||||||
result['a'] = oldBufferC;
|
|
||||||
result['b'] = newBufferC;
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,22 +93,18 @@ Map<String, dynamic> fromBlobs({
|
||||||
opts,
|
opts,
|
||||||
);
|
);
|
||||||
|
|
||||||
final result = <String, dynamic>{};
|
|
||||||
|
|
||||||
calloc.free(oldAsPathC);
|
calloc.free(oldAsPathC);
|
||||||
calloc.free(newAsPathC);
|
calloc.free(newAsPathC);
|
||||||
calloc.free(opts);
|
calloc.free(opts);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
// Returning map with pointers to patch and blobs because patch object does not
|
// Returning map with pointers to patch and blobs because patch object does not
|
||||||
// have reference to underlying blobs. So if the blob is freed/removed the patch
|
// have reference to underlying blobs. So if the blob is freed/removed the patch
|
||||||
// text becomes corrupted.
|
// text becomes corrupted.
|
||||||
result['patch'] = out.value;
|
return {'patch': out.value, 'a': oldBlobPointer, 'b': newBlobPointer};
|
||||||
result['a'] = oldBlobPointer;
|
|
||||||
result['b'] = newBlobPointer;
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,23 +144,19 @@ Map<String, dynamic> fromBlobAndBuffer({
|
||||||
opts,
|
opts,
|
||||||
);
|
);
|
||||||
|
|
||||||
final result = <String, dynamic>{};
|
|
||||||
|
|
||||||
calloc.free(oldAsPathC);
|
calloc.free(oldAsPathC);
|
||||||
calloc.free(bufferAsPathC);
|
calloc.free(bufferAsPathC);
|
||||||
calloc.free(opts);
|
calloc.free(opts);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
calloc.free(bufferC);
|
calloc.free(bufferC);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
// Returning map with pointers to patch and buffers because patch object does not
|
// Returning map with pointers to patch and buffers because patch object does not
|
||||||
// have reference to underlying buffers or blobs. So if the buffer or blob is freed/removed
|
// have reference to underlying buffers or blobs. So if the buffer or blob is freed/removed
|
||||||
// the patch text becomes corrupted.
|
// the patch text becomes corrupted.
|
||||||
result['patch'] = out.value;
|
return {'patch': out.value, 'a': oldBlobPointer, 'b': bufferC};
|
||||||
result['a'] = oldBlobPointer;
|
|
||||||
result['b'] = bufferC;
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,6 +175,7 @@ Pointer<git_patch> fromDiff({
|
||||||
final error = libgit2.git_patch_from_diff(out, diffPointer, index);
|
final error = libgit2.git_patch_from_diff(out, diffPointer, index);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -217,14 +206,15 @@ Map<String, dynamic> hunk({
|
||||||
patchPointer,
|
patchPointer,
|
||||||
hunkIndex,
|
hunkIndex,
|
||||||
);
|
);
|
||||||
final result = <String, dynamic>{};
|
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
|
calloc.free(linesInHunk);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
result['hunk'] = out.value;
|
final linesN = linesInHunk.value;
|
||||||
result['linesN'] = linesInHunk.value;
|
calloc.free(linesInHunk);
|
||||||
return result;
|
return {'hunk': out.value, 'linesN': linesN};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,6 +235,7 @@ Pointer<git_diff_line> lines({
|
||||||
);
|
);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -259,6 +250,7 @@ String text(Pointer<git_patch> patch) {
|
||||||
final error = libgit2.git_patch_to_buf(out, patch);
|
final error = libgit2.git_patch_to_buf(out, patch);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
final result = out.ref.ptr.cast<Utf8>().toDartString();
|
final result = out.ref.ptr.cast<Utf8>().toDartString();
|
||||||
|
@ -302,15 +294,19 @@ Pointer<git_diff_options> _diffOptionsInit({
|
||||||
required int interhunkLines,
|
required int interhunkLines,
|
||||||
}) {
|
}) {
|
||||||
final opts = calloc<git_diff_options>();
|
final opts = calloc<git_diff_options>();
|
||||||
final optsError =
|
final optsError = libgit2.git_diff_options_init(
|
||||||
libgit2.git_diff_options_init(opts, GIT_DIFF_OPTIONS_VERSION);
|
opts,
|
||||||
|
GIT_DIFF_OPTIONS_VERSION,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (optsError < 0) {
|
||||||
|
calloc.free(opts);
|
||||||
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
|
}
|
||||||
|
|
||||||
opts.ref.flags = flags;
|
opts.ref.flags = flags;
|
||||||
opts.ref.context_lines = contextLines;
|
opts.ref.context_lines = contextLines;
|
||||||
opts.ref.interhunk_lines = interhunkLines;
|
opts.ref.interhunk_lines = interhunkLines;
|
||||||
|
|
||||||
if (optsError < 0) {
|
return opts;
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
|
||||||
} else {
|
|
||||||
return opts;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,8 @@ Pointer<git_rebase> init({
|
||||||
);
|
);
|
||||||
|
|
||||||
if (optsError < 0) {
|
if (optsError < 0) {
|
||||||
|
calloc.free(out);
|
||||||
|
calloc.free(opts);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +45,10 @@ Pointer<git_rebase> init({
|
||||||
opts,
|
opts,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
calloc.free(opts);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -63,13 +68,14 @@ int operationsCount(Pointer<git_rebase> rebase) {
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Pointer<git_rebase_operation> next(Pointer<git_rebase> rebase) {
|
Pointer<git_rebase_operation> next(Pointer<git_rebase> rebase) {
|
||||||
final operation = calloc<Pointer<git_rebase_operation>>();
|
final out = calloc<Pointer<git_rebase_operation>>();
|
||||||
final error = libgit2.git_rebase_next(operation, rebase);
|
final error = libgit2.git_rebase_next(out, rebase);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return operation.value;
|
return out.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,11 +89,11 @@ void commit({
|
||||||
required Pointer<git_signature> committerPointer,
|
required Pointer<git_signature> committerPointer,
|
||||||
required String? message,
|
required String? message,
|
||||||
}) {
|
}) {
|
||||||
final id = calloc<git_oid>();
|
final out = calloc<git_oid>();
|
||||||
final messageC = message?.toNativeUtf8().cast<Int8>() ?? nullptr;
|
final messageC = message?.toNativeUtf8().cast<Int8>() ?? nullptr;
|
||||||
|
|
||||||
final error = libgit2.git_rebase_commit(
|
final error = libgit2.git_rebase_commit(
|
||||||
id,
|
out,
|
||||||
rebasePointer,
|
rebasePointer,
|
||||||
authorPointer ?? nullptr,
|
authorPointer ?? nullptr,
|
||||||
committerPointer,
|
committerPointer,
|
||||||
|
@ -95,6 +101,7 @@ void commit({
|
||||||
messageC,
|
messageC,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
calloc.free(out);
|
||||||
calloc.free(messageC);
|
calloc.free(messageC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
|
|
@ -41,6 +41,7 @@ Pointer<git_reference> resolve(Pointer<git_reference> ref) {
|
||||||
final error = libgit2.git_reference_resolve(out, ref);
|
final error = libgit2.git_reference_resolve(out, ref);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -65,6 +66,7 @@ Pointer<git_reference> lookup({
|
||||||
calloc.free(nameC);
|
calloc.free(nameC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -88,6 +90,7 @@ Pointer<git_reference> lookupDWIM({
|
||||||
calloc.free(nameC);
|
calloc.free(nameC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -96,10 +99,7 @@ Pointer<git_reference> lookupDWIM({
|
||||||
|
|
||||||
/// Get the full name of a reference.
|
/// Get the full name of a reference.
|
||||||
String name(Pointer<git_reference> ref) {
|
String name(Pointer<git_reference> ref) {
|
||||||
var result = calloc<Int8>();
|
return libgit2.git_reference_name(ref).cast<Utf8>().toDartString();
|
||||||
result = libgit2.git_reference_name(ref);
|
|
||||||
|
|
||||||
return result.cast<Utf8>().toDartString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the reference's short name.
|
/// Get the reference's short name.
|
||||||
|
@ -107,8 +107,7 @@ String name(Pointer<git_reference> ref) {
|
||||||
/// This will transform the reference name into a name "human-readable" version.
|
/// This will transform the reference name into a name "human-readable" version.
|
||||||
/// If no shortname is appropriate, it will return the full name.
|
/// If no shortname is appropriate, it will return the full name.
|
||||||
String shorthand(Pointer<git_reference> ref) {
|
String shorthand(Pointer<git_reference> ref) {
|
||||||
final result = libgit2.git_reference_shorthand(ref);
|
return libgit2.git_reference_shorthand(ref).cast<Utf8>().toDartString();
|
||||||
return result.cast<Utf8>().toDartString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Rename an existing reference.
|
/// Rename an existing reference.
|
||||||
|
@ -146,6 +145,7 @@ Pointer<git_reference> rename({
|
||||||
calloc.free(logMessageC);
|
calloc.free(logMessageC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -195,26 +195,22 @@ bool hasLog({
|
||||||
|
|
||||||
/// Check if a reference is a local branch.
|
/// Check if a reference is a local branch.
|
||||||
bool isBranch(Pointer<git_reference> ref) {
|
bool isBranch(Pointer<git_reference> ref) {
|
||||||
final result = libgit2.git_reference_is_branch(ref);
|
return libgit2.git_reference_is_branch(ref) == 1 ? true : false;
|
||||||
return result == 1 ? true : false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if a reference is a note.
|
/// Check if a reference is a note.
|
||||||
bool isNote(Pointer<git_reference> ref) {
|
bool isNote(Pointer<git_reference> ref) {
|
||||||
final result = libgit2.git_reference_is_note(ref);
|
return libgit2.git_reference_is_note(ref) == 1 ? true : false;
|
||||||
return result == 1 ? true : false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if a reference is a remote tracking branch.
|
/// Check if a reference is a remote tracking branch.
|
||||||
bool isRemote(Pointer<git_reference> ref) {
|
bool isRemote(Pointer<git_reference> ref) {
|
||||||
final result = libgit2.git_reference_is_remote(ref);
|
return libgit2.git_reference_is_remote(ref) == 1 ? true : false;
|
||||||
return result == 1 ? true : false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if a reference is a tag.
|
/// Check if a reference is a tag.
|
||||||
bool isTag(Pointer<git_reference> ref) {
|
bool isTag(Pointer<git_reference> ref) {
|
||||||
final result = libgit2.git_reference_is_tag(ref);
|
return libgit2.git_reference_is_tag(ref) == 1 ? true : false;
|
||||||
return result == 1 ? true : false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new direct reference.
|
/// Create a new direct reference.
|
||||||
|
@ -263,6 +259,7 @@ Pointer<git_reference> createDirect({
|
||||||
calloc.free(logMessageC);
|
calloc.free(logMessageC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw (LibGit2Error(libgit2.git_error_last()));
|
throw (LibGit2Error(libgit2.git_error_last()));
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -317,6 +314,7 @@ Pointer<git_reference> createSymbolic({
|
||||||
calloc.free(logMessageC);
|
calloc.free(logMessageC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw (LibGit2Error(libgit2.git_error_last()));
|
throw (LibGit2Error(libgit2.git_error_last()));
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -365,6 +363,7 @@ Pointer<git_reference> setTarget({
|
||||||
calloc.free(logMessageC);
|
calloc.free(logMessageC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -401,6 +400,7 @@ Pointer<git_reference> setTargetSymbolic({
|
||||||
calloc.free(logMessageC);
|
calloc.free(logMessageC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -412,8 +412,9 @@ bool compare({
|
||||||
required Pointer<git_reference> ref1Pointer,
|
required Pointer<git_reference> ref1Pointer,
|
||||||
required Pointer<git_reference> ref2Pointer,
|
required Pointer<git_reference> ref2Pointer,
|
||||||
}) {
|
}) {
|
||||||
final result = libgit2.git_reference_cmp(ref1Pointer, ref2Pointer);
|
return libgit2.git_reference_cmp(ref1Pointer, ref2Pointer) == 0
|
||||||
return result == 0 ? true : false;
|
? true
|
||||||
|
: false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Recursively peel reference until object of the specified type is found.
|
/// Recursively peel reference until object of the specified type is found.
|
||||||
|
@ -432,6 +433,7 @@ Pointer<git_object> peel({
|
||||||
final error = libgit2.git_reference_peel(out, refPointer, type);
|
final error = libgit2.git_reference_peel(out, refPointer, type);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
|
|
@ -23,6 +23,7 @@ Pointer<git_reflog> read({
|
||||||
calloc.free(nameC);
|
calloc.free(nameC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -46,8 +47,7 @@ Pointer<git_reflog_entry> getByIndex({
|
||||||
|
|
||||||
/// Get the log message.
|
/// Get the log message.
|
||||||
String entryMessage(Pointer<git_reflog_entry> entry) {
|
String entryMessage(Pointer<git_reflog_entry> entry) {
|
||||||
final result = libgit2.git_reflog_entry_message(entry);
|
return libgit2.git_reflog_entry_message(entry).cast<Utf8>().toDartString();
|
||||||
return result.cast<Utf8>().toDartString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the committer of this entry.
|
/// Get the committer of this entry.
|
||||||
|
|
|
@ -68,6 +68,7 @@ String transform({
|
||||||
calloc.free(nameC);
|
calloc.free(nameC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
final result = out.ref.ptr.cast<Utf8>().toDartString();
|
final result = out.ref.ptr.cast<Utf8>().toDartString();
|
||||||
|
@ -90,6 +91,7 @@ String rTransform({
|
||||||
calloc.free(nameC);
|
calloc.free(nameC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
final result = out.ref.ptr.cast<Utf8>().toDartString();
|
final result = out.ref.ptr.cast<Utf8>().toDartString();
|
||||||
|
|
|
@ -15,6 +15,7 @@ List<String> list(Pointer<git_repository> repo) {
|
||||||
final error = libgit2.git_remote_list(out, repo);
|
final error = libgit2.git_remote_list(out, repo);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
var result = <String>[];
|
var result = <String>[];
|
||||||
|
@ -42,6 +43,7 @@ Pointer<git_remote> lookup({
|
||||||
calloc.free(nameC);
|
calloc.free(nameC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -65,6 +67,7 @@ Pointer<git_remote> create({
|
||||||
calloc.free(urlC);
|
calloc.free(urlC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -97,6 +100,7 @@ Pointer<git_remote> createWithFetchSpec({
|
||||||
calloc.free(fetchC);
|
calloc.free(fetchC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -148,6 +152,7 @@ List<String> rename({
|
||||||
calloc.free(newNameC);
|
calloc.free(newNameC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
var result = <String>[];
|
var result = <String>[];
|
||||||
|
@ -374,11 +379,13 @@ List<Map<String, dynamic>> lsRemotes(Pointer<git_remote> remote) {
|
||||||
final size = calloc<Uint64>();
|
final size = calloc<Uint64>();
|
||||||
final error = libgit2.git_remote_ls(out, size, remote);
|
final error = libgit2.git_remote_ls(out, size, remote);
|
||||||
|
|
||||||
var result = <Map<String, dynamic>>[];
|
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
|
calloc.free(size);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
|
var result = <Map<String, dynamic>>[];
|
||||||
|
|
||||||
for (var i = 0; i < size.value; i++) {
|
for (var i = 0; i < size.value; i++) {
|
||||||
var remote = <String, dynamic>{};
|
var remote = <String, dynamic>{};
|
||||||
Oid? loid;
|
Oid? loid;
|
||||||
|
@ -401,6 +408,9 @@ List<Map<String, dynamic>> lsRemotes(Pointer<git_remote> remote) {
|
||||||
result.add(remote);
|
result.add(remote);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
calloc.free(out);
|
||||||
|
calloc.free(size);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -441,6 +451,14 @@ void fetch({
|
||||||
);
|
);
|
||||||
|
|
||||||
if (optsError < 0) {
|
if (optsError < 0) {
|
||||||
|
for (final p in refspecsPointers) {
|
||||||
|
calloc.free(p);
|
||||||
|
}
|
||||||
|
calloc.free(refspecsC);
|
||||||
|
calloc.free(strArray);
|
||||||
|
calloc.free(proxyOptions);
|
||||||
|
calloc.free(reflogMessageC);
|
||||||
|
calloc.free(opts);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -501,6 +519,13 @@ void push({
|
||||||
libgit2.git_push_options_init(opts, GIT_PUSH_OPTIONS_VERSION);
|
libgit2.git_push_options_init(opts, GIT_PUSH_OPTIONS_VERSION);
|
||||||
|
|
||||||
if (optsError < 0) {
|
if (optsError < 0) {
|
||||||
|
for (final p in refspecsPointers) {
|
||||||
|
calloc.free(p);
|
||||||
|
}
|
||||||
|
calloc.free(strArray);
|
||||||
|
calloc.free(refspecsC);
|
||||||
|
calloc.free(proxyOptions);
|
||||||
|
calloc.free(opts);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -555,6 +580,7 @@ void prune({
|
||||||
);
|
);
|
||||||
|
|
||||||
if (callbacksError < 0) {
|
if (callbacksError < 0) {
|
||||||
|
calloc.free(callbacksOptions);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -586,6 +612,7 @@ Pointer<git_proxy_options> _proxyOptionsInit(String? proxyOption) {
|
||||||
libgit2.git_proxy_options_init(proxyOptions, GIT_PROXY_OPTIONS_VERSION);
|
libgit2.git_proxy_options_init(proxyOptions, GIT_PROXY_OPTIONS_VERSION);
|
||||||
|
|
||||||
if (proxyOptionsError < 0) {
|
if (proxyOptionsError < 0) {
|
||||||
|
calloc.free(proxyOptions);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ Pointer<git_repository> open(String path) {
|
||||||
calloc.free(pathC);
|
calloc.free(pathC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -40,6 +41,7 @@ Pointer<git_repository> openBare(String barePath) {
|
||||||
calloc.free(barePathC);
|
calloc.free(barePathC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -72,11 +74,15 @@ String discover({
|
||||||
calloc.free(ceilingDirsC);
|
calloc.free(ceilingDirsC);
|
||||||
|
|
||||||
if (error == git_error_code.GIT_ENOTFOUND) {
|
if (error == git_error_code.GIT_ENOTFOUND) {
|
||||||
|
calloc.free(out);
|
||||||
return '';
|
return '';
|
||||||
} else if (error < 0) {
|
} else if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.ref.ptr.cast<Utf8>().toDartString();
|
final result = out.ref.ptr.cast<Utf8>().toDartString();
|
||||||
|
calloc.free(out);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,6 +113,14 @@ Pointer<git_repository> init({
|
||||||
);
|
);
|
||||||
|
|
||||||
if (optsError < 0) {
|
if (optsError < 0) {
|
||||||
|
calloc.free(out);
|
||||||
|
calloc.free(pathC);
|
||||||
|
calloc.free(workdirPathC);
|
||||||
|
calloc.free(descriptionC);
|
||||||
|
calloc.free(templatePathC);
|
||||||
|
calloc.free(initialHeadC);
|
||||||
|
calloc.free(originUrlC);
|
||||||
|
calloc.free(opts);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,6 +143,7 @@ Pointer<git_repository> init({
|
||||||
calloc.free(opts);
|
calloc.free(opts);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -158,6 +173,11 @@ Pointer<git_repository> clone({
|
||||||
libgit2.git_clone_options_init(cloneOptions, GIT_CLONE_OPTIONS_VERSION);
|
libgit2.git_clone_options_init(cloneOptions, GIT_CLONE_OPTIONS_VERSION);
|
||||||
|
|
||||||
if (cloneOptionsError < 0) {
|
if (cloneOptionsError < 0) {
|
||||||
|
calloc.free(out);
|
||||||
|
calloc.free(urlC);
|
||||||
|
calloc.free(localPathC);
|
||||||
|
calloc.free(checkoutBranchC);
|
||||||
|
calloc.free(cloneOptions);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,6 +186,12 @@ Pointer<git_repository> clone({
|
||||||
libgit2.git_fetch_options_init(fetchOptions, GIT_FETCH_OPTIONS_VERSION);
|
libgit2.git_fetch_options_init(fetchOptions, GIT_FETCH_OPTIONS_VERSION);
|
||||||
|
|
||||||
if (fetchOptionsError < 0) {
|
if (fetchOptionsError < 0) {
|
||||||
|
calloc.free(out);
|
||||||
|
calloc.free(urlC);
|
||||||
|
calloc.free(localPathC);
|
||||||
|
calloc.free(checkoutBranchC);
|
||||||
|
calloc.free(cloneOptions);
|
||||||
|
calloc.free(fetchOptions);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,6 +230,7 @@ Pointer<git_repository> clone({
|
||||||
RemoteCallbacks.reset();
|
RemoteCallbacks.reset();
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -213,8 +240,7 @@ Pointer<git_repository> clone({
|
||||||
/// Returns the path to the `.git` folder for normal repositories or the
|
/// Returns the path to the `.git` folder for normal repositories or the
|
||||||
/// repository itself for bare repositories.
|
/// repository itself for bare repositories.
|
||||||
String path(Pointer<git_repository> repo) {
|
String path(Pointer<git_repository> repo) {
|
||||||
final result = libgit2.git_repository_path(repo);
|
return libgit2.git_repository_path(repo).cast<Utf8>().toDartString();
|
||||||
return result.cast<Utf8>().toDartString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the path of the shared common directory for this repository.
|
/// Get the path of the shared common directory for this repository.
|
||||||
|
@ -223,8 +249,7 @@ String path(Pointer<git_repository> repo) {
|
||||||
/// If the repository is a worktree, it is the parent repo's `.git` folder.
|
/// If the repository is a worktree, it is the parent repo's `.git` folder.
|
||||||
/// Otherwise, it is the `.git` folder.
|
/// Otherwise, it is the `.git` folder.
|
||||||
String commonDir(Pointer<git_repository> repo) {
|
String commonDir(Pointer<git_repository> repo) {
|
||||||
final result = libgit2.git_repository_commondir(repo);
|
return libgit2.git_repository_commondir(repo).cast<Utf8>().toDartString();
|
||||||
return result.cast<Utf8>().toDartString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the currently active namespace for this repository.
|
/// Get the currently active namespace for this repository.
|
||||||
|
@ -264,8 +289,7 @@ void setNamespace({
|
||||||
|
|
||||||
/// Check if a repository is bare or not.
|
/// Check if a repository is bare or not.
|
||||||
bool isBare(Pointer<git_repository> repo) {
|
bool isBare(Pointer<git_repository> repo) {
|
||||||
final result = libgit2.git_repository_is_bare(repo);
|
return libgit2.git_repository_is_bare(repo) == 1 ? true : false;
|
||||||
return result == 1 ? true : false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if a repository is empty.
|
/// Check if a repository is empty.
|
||||||
|
@ -295,6 +319,7 @@ Pointer<git_reference> head(Pointer<git_repository> repo) {
|
||||||
final error = libgit2.git_repository_head(out, repo);
|
final error = libgit2.git_repository_head(out, repo);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -383,6 +408,7 @@ Pointer<git_config> config(Pointer<git_repository> repo) {
|
||||||
final error = libgit2.git_repository_config(out, repo);
|
final error = libgit2.git_repository_config(out, repo);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -402,6 +428,7 @@ Pointer<git_config> configSnapshot(Pointer<git_repository> repo) {
|
||||||
final error = libgit2.git_repository_config_snapshot(out, repo);
|
final error = libgit2.git_repository_config_snapshot(out, repo);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -421,6 +448,7 @@ Pointer<git_index> index(Pointer<git_repository> repo) {
|
||||||
final error = libgit2.git_repository_index(out, repo);
|
final error = libgit2.git_repository_index(out, repo);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -429,14 +457,12 @@ Pointer<git_index> index(Pointer<git_repository> repo) {
|
||||||
|
|
||||||
/// Determine if the repository was a shallow clone.
|
/// Determine if the repository was a shallow clone.
|
||||||
bool isShallow(Pointer<git_repository> repo) {
|
bool isShallow(Pointer<git_repository> repo) {
|
||||||
final result = libgit2.git_repository_is_shallow(repo);
|
return libgit2.git_repository_is_shallow(repo) == 1 ? true : false;
|
||||||
return result == 1 ? true : false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if a repository is a linked work tree.
|
/// Check if a repository is a linked work tree.
|
||||||
bool isWorktree(Pointer<git_repository> repo) {
|
bool isWorktree(Pointer<git_repository> repo) {
|
||||||
final result = libgit2.git_repository_is_worktree(repo);
|
return libgit2.git_repository_is_worktree(repo) == 1 ? true : false;
|
||||||
return result == 1 ? true : false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieve git's prepared message.
|
/// Retrieve git's prepared message.
|
||||||
|
@ -455,9 +481,12 @@ String message(Pointer<git_repository> repo) {
|
||||||
final error = libgit2.git_repository_message(out, repo);
|
final error = libgit2.git_repository_message(out, repo);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.ref.ptr.cast<Utf8>().toDartString();
|
final result = out.ref.ptr.cast<Utf8>().toDartString();
|
||||||
|
calloc.free(out);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -479,6 +508,7 @@ Pointer<git_odb> odb(Pointer<git_repository> repo) {
|
||||||
final error = libgit2.git_repository_odb(out, repo);
|
final error = libgit2.git_repository_odb(out, repo);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -499,6 +529,7 @@ Pointer<git_refdb> refdb(Pointer<git_repository> repo) {
|
||||||
final error = libgit2.git_repository_refdb(out, repo);
|
final error = libgit2.git_repository_refdb(out, repo);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -646,6 +677,7 @@ Pointer<git_repository> wrapODB(Pointer<git_odb> odb) {
|
||||||
final error = libgit2.git_repository_wrap_odb(out, odb);
|
final error = libgit2.git_repository_wrap_odb(out, odb);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
|
|
@ -22,6 +22,7 @@ Pointer<git_revspec> revParse({
|
||||||
calloc.free(specC);
|
calloc.free(specC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out;
|
return out;
|
||||||
|
@ -47,6 +48,7 @@ Pointer<git_object> revParseSingle({
|
||||||
calloc.free(specC);
|
calloc.free(specC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -72,7 +74,6 @@ List revParseExt({
|
||||||
final objectOut = calloc<Pointer<git_object>>();
|
final objectOut = calloc<Pointer<git_object>>();
|
||||||
final referenceOut = calloc<Pointer<git_reference>>();
|
final referenceOut = calloc<Pointer<git_reference>>();
|
||||||
final specC = spec.toNativeUtf8().cast<Int8>();
|
final specC = spec.toNativeUtf8().cast<Int8>();
|
||||||
var result = [];
|
|
||||||
|
|
||||||
final error = libgit2.git_revparse_ext(
|
final error = libgit2.git_revparse_ext(
|
||||||
objectOut,
|
objectOut,
|
||||||
|
@ -84,8 +85,11 @@ List revParseExt({
|
||||||
calloc.free(specC);
|
calloc.free(specC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(objectOut);
|
||||||
|
calloc.free(referenceOut);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
|
var result = [];
|
||||||
result.add(objectOut.value);
|
result.add(objectOut.value);
|
||||||
if (referenceOut.value != nullptr) {
|
if (referenceOut.value != nullptr) {
|
||||||
result.add(referenceOut.value);
|
result.add(referenceOut.value);
|
||||||
|
|
|
@ -22,6 +22,7 @@ Pointer<git_revwalk> create(Pointer<git_repository> repo) {
|
||||||
final error = libgit2.git_revwalk_new(out, repo);
|
final error = libgit2.git_revwalk_new(out, repo);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
|
|
@ -25,6 +25,7 @@ Pointer<git_signature> create({
|
||||||
calloc.free(emailC);
|
calloc.free(emailC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -44,6 +45,7 @@ Pointer<git_signature> now({required String name, required String email}) {
|
||||||
calloc.free(emailC);
|
calloc.free(emailC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -61,6 +63,7 @@ Pointer<git_signature> defaultSignature(Pointer<git_repository> repo) {
|
||||||
final error = libgit2.git_signature_default(out, repo);
|
final error = libgit2.git_signature_default(out, repo);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
|
|
@ -26,7 +26,10 @@ Pointer<git_oid> stash({
|
||||||
flags,
|
flags,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
calloc.free(messageC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out;
|
return out;
|
||||||
|
@ -44,12 +47,14 @@ void apply({
|
||||||
String? directory,
|
String? directory,
|
||||||
List<String>? paths,
|
List<String>? paths,
|
||||||
}) {
|
}) {
|
||||||
final options =
|
final options = calloc<git_stash_apply_options>();
|
||||||
calloc<git_stash_apply_options>(sizeOf<git_stash_apply_options>());
|
|
||||||
final optionsError = libgit2.git_stash_apply_options_init(
|
final optionsError = libgit2.git_stash_apply_options_init(
|
||||||
options, GIT_STASH_APPLY_OPTIONS_VERSION);
|
options,
|
||||||
|
GIT_STASH_APPLY_OPTIONS_VERSION,
|
||||||
|
);
|
||||||
|
|
||||||
if (optionsError < 0) {
|
if (optionsError < 0) {
|
||||||
|
calloc.free(options);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,16 +72,16 @@ void apply({
|
||||||
|
|
||||||
final error = libgit2.git_stash_apply(repoPointer, index, options);
|
final error = libgit2.git_stash_apply(repoPointer, index, options);
|
||||||
|
|
||||||
if (error < 0) {
|
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
|
||||||
}
|
|
||||||
|
|
||||||
for (final p in pathPointers) {
|
for (final p in pathPointers) {
|
||||||
calloc.free(p);
|
calloc.free(p);
|
||||||
}
|
}
|
||||||
calloc.free(strArray);
|
calloc.free(strArray);
|
||||||
calloc.free(optsC);
|
calloc.free(optsC);
|
||||||
calloc.free(options);
|
calloc.free(options);
|
||||||
|
|
||||||
|
if (error < 0) {
|
||||||
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Remove a single stashed state from the stash list.
|
/// Remove a single stashed state from the stash list.
|
||||||
|
@ -97,12 +102,14 @@ void pop({
|
||||||
String? directory,
|
String? directory,
|
||||||
List<String>? paths,
|
List<String>? paths,
|
||||||
}) {
|
}) {
|
||||||
final options =
|
final options = calloc<git_stash_apply_options>();
|
||||||
calloc<git_stash_apply_options>(sizeOf<git_stash_apply_options>());
|
|
||||||
final optionsError = libgit2.git_stash_apply_options_init(
|
final optionsError = libgit2.git_stash_apply_options_init(
|
||||||
options, GIT_STASH_APPLY_OPTIONS_VERSION);
|
options,
|
||||||
|
GIT_STASH_APPLY_OPTIONS_VERSION,
|
||||||
|
);
|
||||||
|
|
||||||
if (optionsError < 0) {
|
if (optionsError < 0) {
|
||||||
|
calloc.free(options);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,16 +127,16 @@ void pop({
|
||||||
|
|
||||||
final error = libgit2.git_stash_pop(repoPointer, index, options);
|
final error = libgit2.git_stash_pop(repoPointer, index, options);
|
||||||
|
|
||||||
if (error < 0) {
|
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
|
||||||
}
|
|
||||||
|
|
||||||
for (final p in pathPointers) {
|
for (final p in pathPointers) {
|
||||||
calloc.free(p);
|
calloc.free(p);
|
||||||
}
|
}
|
||||||
calloc.free(strArray);
|
calloc.free(strArray);
|
||||||
calloc.free(optsC);
|
calloc.free(optsC);
|
||||||
calloc.free(options);
|
calloc.free(options);
|
||||||
|
|
||||||
|
if (error < 0) {
|
||||||
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// List of stashed states.
|
/// List of stashed states.
|
||||||
|
|
|
@ -13,6 +13,7 @@ Pointer<git_status_list> listNew(Pointer<git_repository> repo) {
|
||||||
final error = libgit2.git_status_list_new(out, repo, nullptr);
|
final error = libgit2.git_status_list_new(out, repo, nullptr);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -68,6 +69,7 @@ int file({required Pointer<git_repository> repoPointer, required String path}) {
|
||||||
calloc.free(pathC);
|
calloc.free(pathC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
final result = out.value;
|
final result = out.value;
|
||||||
|
|
|
@ -62,6 +62,7 @@ Pointer<git_submodule> lookup({
|
||||||
calloc.free(nameC);
|
calloc.free(nameC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -113,6 +114,7 @@ void update({
|
||||||
);
|
);
|
||||||
|
|
||||||
if (optionsError < 0) {
|
if (optionsError < 0) {
|
||||||
|
calloc.free(options);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,6 +146,7 @@ Pointer<git_repository> open(Pointer<git_submodule> submodule) {
|
||||||
final error = libgit2.git_submodule_open(out, submodule);
|
final error = libgit2.git_submodule_open(out, submodule);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -180,6 +183,7 @@ Pointer<git_submodule> addSetup({
|
||||||
calloc.free(pathC);
|
calloc.free(pathC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -201,6 +205,8 @@ void clone({
|
||||||
);
|
);
|
||||||
|
|
||||||
if (optionsError < 0) {
|
if (optionsError < 0) {
|
||||||
|
calloc.free(out);
|
||||||
|
calloc.free(options);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,9 +260,12 @@ int status({
|
||||||
calloc.free(nameC);
|
calloc.free(nameC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
final result = out.value;
|
||||||
|
calloc.free(out);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,8 +305,7 @@ void reload({
|
||||||
|
|
||||||
/// Get the name of submodule.
|
/// Get the name of submodule.
|
||||||
String name(Pointer<git_submodule> submodule) {
|
String name(Pointer<git_submodule> submodule) {
|
||||||
final result = libgit2.git_submodule_name(submodule);
|
return libgit2.git_submodule_name(submodule).cast<Utf8>().toDartString();
|
||||||
return result.cast<Utf8>().toDartString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the path to the submodule.
|
/// Get the path to the submodule.
|
||||||
|
@ -305,14 +313,12 @@ String name(Pointer<git_submodule> submodule) {
|
||||||
/// The path is almost always the same as the submodule name, but the two
|
/// The path is almost always the same as the submodule name, but the two
|
||||||
/// are actually not required to match.
|
/// are actually not required to match.
|
||||||
String path(Pointer<git_submodule> submodule) {
|
String path(Pointer<git_submodule> submodule) {
|
||||||
final result = libgit2.git_submodule_path(submodule);
|
return libgit2.git_submodule_path(submodule).cast<Utf8>().toDartString();
|
||||||
return result.cast<Utf8>().toDartString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the URL for the submodule.
|
/// Get the URL for the submodule.
|
||||||
String url(Pointer<git_submodule> submodule) {
|
String url(Pointer<git_submodule> submodule) {
|
||||||
final result = libgit2.git_submodule_url(submodule);
|
return libgit2.git_submodule_url(submodule).cast<Utf8>().toDartString();
|
||||||
return result.cast<Utf8>().toDartString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the URL for the submodule in the configuration.
|
/// Set the URL for the submodule in the configuration.
|
||||||
|
|
|
@ -14,6 +14,7 @@ List<String> list(Pointer<git_repository> repo) {
|
||||||
var result = <String>[];
|
var result = <String>[];
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
for (var i = 0; i < out.ref.count; i++) {
|
for (var i = 0; i < out.ref.count; i++) {
|
||||||
|
@ -35,6 +36,7 @@ Pointer<git_tag> lookup({
|
||||||
final error = libgit2.git_tag_lookup(out, repoPointer, oidPointer);
|
final error = libgit2.git_tag_lookup(out, repoPointer, oidPointer);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -51,6 +53,7 @@ Pointer<git_object> target(Pointer<git_tag> tag) {
|
||||||
final error = libgit2.git_tag_target(out, tag);
|
final error = libgit2.git_tag_target(out, tag);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -113,6 +116,7 @@ Pointer<git_oid> create({
|
||||||
calloc.free(messageC);
|
calloc.free(messageC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out;
|
return out;
|
||||||
|
|
|
@ -18,6 +18,7 @@ Pointer<git_tree> lookup({
|
||||||
final error = libgit2.git_tree_lookup(out, repoPointer, oidPointer);
|
final error = libgit2.git_tree_lookup(out, repoPointer, oidPointer);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -86,6 +87,7 @@ Pointer<git_tree_entry> getByPath({
|
||||||
calloc.free(pathC);
|
calloc.free(pathC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
|
|
@ -24,6 +24,7 @@ Pointer<git_treebuilder> create({
|
||||||
final error = libgit2.git_treebuilder_new(out, repoPointer, sourcePointer);
|
final error = libgit2.git_treebuilder_new(out, repoPointer, sourcePointer);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -38,6 +39,7 @@ Pointer<git_oid> write(Pointer<git_treebuilder> bld) {
|
||||||
final error = libgit2.git_treebuilder_write(out, bld);
|
final error = libgit2.git_treebuilder_write(out, bld);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out;
|
return out;
|
||||||
|
|
|
@ -28,6 +28,10 @@ Pointer<git_worktree> create({
|
||||||
);
|
);
|
||||||
|
|
||||||
if (optsError < 0) {
|
if (optsError < 0) {
|
||||||
|
calloc.free(out);
|
||||||
|
calloc.free(nameC);
|
||||||
|
calloc.free(pathC);
|
||||||
|
calloc.free(opts);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,6 +47,7 @@ Pointer<git_worktree> create({
|
||||||
calloc.free(opts);
|
calloc.free(opts);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -63,6 +68,7 @@ Pointer<git_worktree> lookup({
|
||||||
calloc.free(nameC);
|
calloc.free(nameC);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
|
@ -88,12 +94,12 @@ void prune(Pointer<git_worktree> wt) {
|
||||||
List<String> list(Pointer<git_repository> repo) {
|
List<String> list(Pointer<git_repository> repo) {
|
||||||
final out = calloc<git_strarray>();
|
final out = calloc<git_strarray>();
|
||||||
final error = libgit2.git_worktree_list(out, repo);
|
final error = libgit2.git_worktree_list(out, repo);
|
||||||
final result = <String>[];
|
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
calloc.free(out);
|
calloc.free(out);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
|
final result = <String>[];
|
||||||
for (var i = 0; i < out.ref.count; i++) {
|
for (var i = 0; i < out.ref.count; i++) {
|
||||||
result.add(out.ref.strings[i].cast<Utf8>().toDartString());
|
result.add(out.ref.strings[i].cast<Utf8>().toDartString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import 'package:ffi/ffi.dart';
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
import 'bindings/libgit2_bindings.dart';
|
import 'bindings/libgit2_bindings.dart';
|
||||||
import 'bindings/blame.dart' as bindings;
|
import 'bindings/blame.dart' as bindings;
|
||||||
import 'util.dart';
|
|
||||||
|
|
||||||
class Blame with IterableMixin<BlameHunk> {
|
class Blame with IterableMixin<BlameHunk> {
|
||||||
/// Initializes a new instance of the [Blame] class from
|
/// Initializes a new instance of the [Blame] class from
|
||||||
|
@ -44,14 +43,10 @@ class Blame with IterableMixin<BlameHunk> {
|
||||||
int? minLine,
|
int? minLine,
|
||||||
int? maxLine,
|
int? maxLine,
|
||||||
}) {
|
}) {
|
||||||
libgit2.git_libgit2_init();
|
|
||||||
|
|
||||||
final int flagsInt = flags.fold(0, (acc, e) => acc | e.value);
|
|
||||||
|
|
||||||
_blamePointer = bindings.file(
|
_blamePointer = bindings.file(
|
||||||
repoPointer: repo.pointer,
|
repoPointer: repo.pointer,
|
||||||
path: path,
|
path: path,
|
||||||
flags: flagsInt,
|
flags: flags.fold(0, (acc, e) => acc | e.value),
|
||||||
minMatchCharacters: minMatchCharacters,
|
minMatchCharacters: minMatchCharacters,
|
||||||
newestCommit: newestCommit,
|
newestCommit: newestCommit,
|
||||||
oldestCommit: oldestCommit,
|
oldestCommit: oldestCommit,
|
||||||
|
|
|
@ -87,14 +87,12 @@ class Blob {
|
||||||
int contextLines = 3,
|
int contextLines = 3,
|
||||||
int interhunkLines = 0,
|
int interhunkLines = 0,
|
||||||
}) {
|
}) {
|
||||||
final int flagsInt = flags.fold(0, (acc, e) => acc | e.value);
|
|
||||||
|
|
||||||
final result = patch_bindings.fromBlobs(
|
final result = patch_bindings.fromBlobs(
|
||||||
oldBlobPointer: _blobPointer,
|
oldBlobPointer: _blobPointer,
|
||||||
oldAsPath: oldAsPath,
|
oldAsPath: oldAsPath,
|
||||||
newBlobPointer: newBlob?.pointer,
|
newBlobPointer: newBlob?.pointer,
|
||||||
newAsPath: newAsPath,
|
newAsPath: newAsPath,
|
||||||
flags: flagsInt,
|
flags: flags.fold(0, (acc, e) => acc | e.value),
|
||||||
contextLines: contextLines,
|
contextLines: contextLines,
|
||||||
interhunkLines: interhunkLines,
|
interhunkLines: interhunkLines,
|
||||||
);
|
);
|
||||||
|
@ -115,14 +113,12 @@ class Blob {
|
||||||
int contextLines = 3,
|
int contextLines = 3,
|
||||||
int interhunkLines = 0,
|
int interhunkLines = 0,
|
||||||
}) {
|
}) {
|
||||||
final int flagsInt = flags.fold(0, (acc, e) => acc | e.value);
|
|
||||||
|
|
||||||
final result = patch_bindings.fromBlobAndBuffer(
|
final result = patch_bindings.fromBlobAndBuffer(
|
||||||
oldBlobPointer: _blobPointer,
|
oldBlobPointer: _blobPointer,
|
||||||
oldAsPath: oldAsPath,
|
oldAsPath: oldAsPath,
|
||||||
buffer: buffer,
|
buffer: buffer,
|
||||||
bufferAsPath: bufferAsPath,
|
bufferAsPath: bufferAsPath,
|
||||||
flags: flagsInt,
|
flags: flags.fold(0, (acc, e) => acc | e.value),
|
||||||
contextLines: contextLines,
|
contextLines: contextLines,
|
||||||
interhunkLines: interhunkLines,
|
interhunkLines: interhunkLines,
|
||||||
);
|
);
|
||||||
|
|
|
@ -52,15 +52,14 @@ class Branch {
|
||||||
name: name,
|
name: name,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
late final GitBranch type;
|
|
||||||
ref.isBranch ? type = GitBranch.local : GitBranch.remote;
|
|
||||||
ref.free();
|
|
||||||
|
|
||||||
_branchPointer = bindings.lookup(
|
_branchPointer = bindings.lookup(
|
||||||
repoPointer: repo.pointer,
|
repoPointer: repo.pointer,
|
||||||
branchName: name,
|
branchName: name,
|
||||||
branchType: type.value,
|
branchType: ref.isBranch ? GitBranch.local.value : GitBranch.remote.value,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
ref.free();
|
||||||
}
|
}
|
||||||
|
|
||||||
late final Pointer<git_reference> _branchPointer;
|
late final Pointer<git_reference> _branchPointer;
|
||||||
|
@ -93,6 +92,7 @@ class Branch {
|
||||||
static void delete({required Repository repo, required String name}) {
|
static void delete({required Repository repo, required String name}) {
|
||||||
final branch = Branch.lookup(repo: repo, name: name);
|
final branch = Branch.lookup(repo: repo, name: name);
|
||||||
bindings.delete(branch.pointer);
|
bindings.delete(branch.pointer);
|
||||||
|
branch.free();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Renames an existing local branch reference.
|
/// Renames an existing local branch reference.
|
||||||
|
|
|
@ -45,8 +45,6 @@ class Commit {
|
||||||
String? updateRef,
|
String? updateRef,
|
||||||
String? messageEncoding,
|
String? messageEncoding,
|
||||||
}) {
|
}) {
|
||||||
final parentsPointers = parents.map((parent) => parent.pointer).toList();
|
|
||||||
|
|
||||||
return Oid(bindings.create(
|
return Oid(bindings.create(
|
||||||
repoPointer: repo.pointer,
|
repoPointer: repo.pointer,
|
||||||
updateRef: updateRef,
|
updateRef: updateRef,
|
||||||
|
@ -56,7 +54,7 @@ class Commit {
|
||||||
message: message,
|
message: message,
|
||||||
treePointer: tree.pointer,
|
treePointer: tree.pointer,
|
||||||
parentCount: parents.length,
|
parentCount: parents.length,
|
||||||
parents: parentsPointers,
|
parents: parents.map((e) => e.pointer).toList(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,9 +99,10 @@ class Commit {
|
||||||
|
|
||||||
/// Get the tree pointed to by a commit.
|
/// Get the tree pointed to by a commit.
|
||||||
Tree get tree {
|
Tree get tree {
|
||||||
final repo = bindings.owner(_commitPointer);
|
return Tree(tree_bindings.lookup(
|
||||||
final oid = bindings.tree(_commitPointer);
|
repoPointer: bindings.owner(_commitPointer),
|
||||||
return Tree(tree_bindings.lookup(repoPointer: repo, oidPointer: oid));
|
oidPointer: bindings.tree(_commitPointer),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Releases memory allocated for commit object.
|
/// Releases memory allocated for commit object.
|
||||||
|
|
|
@ -96,11 +96,9 @@ class Diff {
|
||||||
int breakRewriteThreshold = 60,
|
int breakRewriteThreshold = 60,
|
||||||
int renameLimit = 200,
|
int renameLimit = 200,
|
||||||
}) {
|
}) {
|
||||||
final int flagsInt = flags.fold(0, (acc, e) => acc | e.value);
|
|
||||||
|
|
||||||
bindings.findSimilar(
|
bindings.findSimilar(
|
||||||
diffPointer: _diffPointer,
|
diffPointer: _diffPointer,
|
||||||
flags: flagsInt,
|
flags: flags.fold(0, (acc, e) => acc | e.value),
|
||||||
renameThreshold: renameThreshold,
|
renameThreshold: renameThreshold,
|
||||||
copyThreshold: copyThreshold,
|
copyThreshold: copyThreshold,
|
||||||
renameFromRewriteThreshold: renameFromRewriteThreshold,
|
renameFromRewriteThreshold: renameFromRewriteThreshold,
|
||||||
|
@ -229,11 +227,9 @@ class DiffStats {
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
String print({required Set<GitDiffStats> format, required int width}) {
|
String print({required Set<GitDiffStats> format, required int width}) {
|
||||||
final int formatInt = format.fold(0, (acc, e) => acc | e.value);
|
|
||||||
|
|
||||||
return bindings.statsPrint(
|
return bindings.statsPrint(
|
||||||
statsPointer: _diffStatsPointer,
|
statsPointer: _diffStatsPointer,
|
||||||
format: formatInt,
|
format: format.fold(0, (acc, e) => acc | e.value),
|
||||||
width: width,
|
width: width,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,13 +189,10 @@ class Index with IterableMixin<IndexEntry> {
|
||||||
int contextLines = 3,
|
int contextLines = 3,
|
||||||
int interhunkLines = 0,
|
int interhunkLines = 0,
|
||||||
}) {
|
}) {
|
||||||
final repo = bindings.owner(_indexPointer);
|
|
||||||
final int flagsInt = flags.fold(0, (acc, e) => acc | e.value);
|
|
||||||
|
|
||||||
return Diff(diff_bindings.indexToWorkdir(
|
return Diff(diff_bindings.indexToWorkdir(
|
||||||
repoPointer: repo,
|
repoPointer: bindings.owner(_indexPointer),
|
||||||
indexPointer: _indexPointer,
|
indexPointer: _indexPointer,
|
||||||
flags: flagsInt,
|
flags: flags.fold(0, (acc, e) => acc | e.value),
|
||||||
contextLines: contextLines,
|
contextLines: contextLines,
|
||||||
interhunkLines: interhunkLines,
|
interhunkLines: interhunkLines,
|
||||||
));
|
));
|
||||||
|
@ -210,14 +207,11 @@ class Index with IterableMixin<IndexEntry> {
|
||||||
int contextLines = 3,
|
int contextLines = 3,
|
||||||
int interhunkLines = 0,
|
int interhunkLines = 0,
|
||||||
}) {
|
}) {
|
||||||
final repo = bindings.owner(_indexPointer);
|
|
||||||
final int flagsInt = flags.fold(0, (acc, e) => acc | e.value);
|
|
||||||
|
|
||||||
return Diff(diff_bindings.treeToIndex(
|
return Diff(diff_bindings.treeToIndex(
|
||||||
repoPointer: repo,
|
repoPointer: bindings.owner(_indexPointer),
|
||||||
treePointer: tree.pointer,
|
treePointer: tree.pointer,
|
||||||
indexPointer: _indexPointer,
|
indexPointer: _indexPointer,
|
||||||
flags: flagsInt,
|
flags: flags.fold(0, (acc, e) => acc | e.value),
|
||||||
contextLines: contextLines,
|
contextLines: contextLines,
|
||||||
interhunkLines: interhunkLines,
|
interhunkLines: interhunkLines,
|
||||||
));
|
));
|
||||||
|
@ -255,8 +249,9 @@ class IndexEntry {
|
||||||
|
|
||||||
/// Returns the UNIX file attributes of a index entry.
|
/// Returns the UNIX file attributes of a index entry.
|
||||||
GitFilemode get mode {
|
GitFilemode get mode {
|
||||||
final modeInt = _indexEntryPointer.ref.mode;
|
return GitFilemode.values.singleWhere(
|
||||||
return GitFilemode.values.singleWhere((mode) => modeInt == mode.value);
|
(mode) => _indexEntryPointer.ref.mode == mode.value,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the UNIX file attributes of a index entry.
|
/// Sets the UNIX file attributes of a index entry.
|
||||||
|
|
|
@ -241,8 +241,10 @@ class Reference {
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
bool get hasLog {
|
bool get hasLog {
|
||||||
final owner = bindings.owner(_refPointer);
|
return bindings.hasLog(
|
||||||
return bindings.hasLog(repoPointer: owner, name: name);
|
repoPointer: bindings.owner(_refPointer),
|
||||||
|
name: name,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a [RefLog] object.
|
/// Returns a [RefLog] object.
|
||||||
|
|
|
@ -9,9 +9,10 @@ class RefLog with IterableMixin<RefLogEntry> {
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
RefLog(Reference ref) {
|
RefLog(Reference ref) {
|
||||||
final repo = ref.owner;
|
_reflogPointer = bindings.read(
|
||||||
final name = ref.name;
|
repoPointer: ref.owner.pointer,
|
||||||
_reflogPointer = bindings.read(repoPointer: repo.pointer, name: name);
|
name: ref.name,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Pointer to memory address for allocated reflog object.
|
/// Pointer to memory address for allocated reflog object.
|
||||||
|
|
|
@ -207,13 +207,10 @@ class Repository {
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void setHead(String target) {
|
void setHead(String target) {
|
||||||
late final Oid oid;
|
|
||||||
|
|
||||||
if (isValidShaHex(target)) {
|
if (isValidShaHex(target)) {
|
||||||
oid = Oid.fromSHA(repo: this, sha: target);
|
|
||||||
bindings.setHeadDetached(
|
bindings.setHeadDetached(
|
||||||
repoPointer: _repoPointer,
|
repoPointer: _repoPointer,
|
||||||
commitishPointer: oid.pointer,
|
commitishPointer: this[target].pointer,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
bindings.setHead(repoPointer: _repoPointer, refname: target);
|
bindings.setHead(repoPointer: _repoPointer, refname: target);
|
||||||
|
@ -450,11 +447,10 @@ class Repository {
|
||||||
required String sha,
|
required String sha,
|
||||||
Set<GitSort> sorting = const {GitSort.none},
|
Set<GitSort> sorting = const {GitSort.none},
|
||||||
}) {
|
}) {
|
||||||
final oid = Oid.fromSHA(repo: this, sha: sha);
|
|
||||||
final walker = RevWalk(this);
|
final walker = RevWalk(this);
|
||||||
|
|
||||||
walker.sorting(sorting);
|
walker.sorting(sorting);
|
||||||
walker.push(oid);
|
walker.push(this[sha]);
|
||||||
final result = walker.walk();
|
final result = walker.walk();
|
||||||
|
|
||||||
walker.free();
|
walker.free();
|
||||||
|
@ -759,12 +755,10 @@ class Repository {
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Oid mergeBase({required String a, required String b}) {
|
Oid mergeBase({required String a, required String b}) {
|
||||||
final oidA = Oid.fromSHA(repo: this, sha: a);
|
|
||||||
final oidB = Oid.fromSHA(repo: this, sha: b);
|
|
||||||
return Oid(merge_bindings.mergeBase(
|
return Oid(merge_bindings.mergeBase(
|
||||||
repoPointer: _repoPointer,
|
repoPointer: _repoPointer,
|
||||||
aPointer: oidA.pointer,
|
aPointer: this[a].pointer,
|
||||||
bPointer: oidB.pointer,
|
bPointer: this[b].pointer,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -994,10 +988,9 @@ class Repository {
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void reset({required String target, required GitReset resetType}) {
|
void reset({required String target, required GitReset resetType}) {
|
||||||
final oid = Oid.fromSHA(repo: this, sha: target);
|
|
||||||
final object = object_bindings.lookup(
|
final object = object_bindings.lookup(
|
||||||
repoPointer: _repoPointer,
|
repoPointer: _repoPointer,
|
||||||
oidPointer: oid.pointer,
|
oidPointer: this[target].pointer,
|
||||||
type: GitObject.any.value,
|
type: GitObject.any.value,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1375,13 +1368,10 @@ class Repository {
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
bool descendantOf({required String commitSHA, required String ancestorSHA}) {
|
bool descendantOf({required String commitSHA, required String ancestorSHA}) {
|
||||||
final commit = Oid.fromSHA(repo: this, sha: commitSHA);
|
|
||||||
final ancestor = Oid.fromSHA(repo: this, sha: ancestorSHA);
|
|
||||||
|
|
||||||
return graph_bindings.descendantOf(
|
return graph_bindings.descendantOf(
|
||||||
repoPointer: _repoPointer,
|
repoPointer: _repoPointer,
|
||||||
commitPointer: commit.pointer,
|
commitPointer: this[commitSHA].pointer,
|
||||||
ancestorPointer: ancestor.pointer,
|
ancestorPointer: this[ancestorSHA].pointer,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1394,13 +1384,10 @@ class Repository {
|
||||||
required String localSHA,
|
required String localSHA,
|
||||||
required String upstreamSHA,
|
required String upstreamSHA,
|
||||||
}) {
|
}) {
|
||||||
final local = Oid.fromSHA(repo: this, sha: localSHA);
|
|
||||||
final upstream = Oid.fromSHA(repo: this, sha: upstreamSHA);
|
|
||||||
|
|
||||||
return graph_bindings.aheadBehind(
|
return graph_bindings.aheadBehind(
|
||||||
repoPointer: _repoPointer,
|
repoPointer: _repoPointer,
|
||||||
localPointer: local.pointer,
|
localPointer: this[localSHA].pointer,
|
||||||
upstreamPointer: upstream.pointer,
|
upstreamPointer: this[upstreamSHA].pointer,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,10 +17,8 @@ class RevWalk {
|
||||||
///
|
///
|
||||||
/// Default sorting is reverse chronological order (default in git).
|
/// Default sorting is reverse chronological order (default in git).
|
||||||
List<Commit> walk() {
|
List<Commit> walk() {
|
||||||
final repoPointer = bindings.repository(_revWalkPointer);
|
|
||||||
|
|
||||||
final pointers = bindings.walk(
|
final pointers = bindings.walk(
|
||||||
repoPointer: repoPointer,
|
repoPointer: bindings.repository(_revWalkPointer),
|
||||||
walkerPointer: _revWalkPointer,
|
walkerPointer: _revWalkPointer,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -140,10 +140,8 @@ class Submodule {
|
||||||
Set<GitSubmoduleStatus> status({
|
Set<GitSubmoduleStatus> status({
|
||||||
GitSubmoduleIgnore ignore = GitSubmoduleIgnore.unspecified,
|
GitSubmoduleIgnore ignore = GitSubmoduleIgnore.unspecified,
|
||||||
}) {
|
}) {
|
||||||
final repo = bindings.owner(_submodulePointer);
|
|
||||||
|
|
||||||
final resultInt = bindings.status(
|
final resultInt = bindings.status(
|
||||||
repoPointer: repo,
|
repoPointer: bindings.owner(_submodulePointer),
|
||||||
name: name,
|
name: name,
|
||||||
ignore: ignore.value,
|
ignore: ignore.value,
|
||||||
);
|
);
|
||||||
|
@ -192,8 +190,11 @@ class Submodule {
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
set url(String url) {
|
set url(String url) {
|
||||||
final repo = bindings.owner(_submodulePointer);
|
bindings.setUrl(
|
||||||
bindings.setUrl(repoPointer: repo, name: name, url: url);
|
repoPointer: bindings.owner(_submodulePointer),
|
||||||
|
name: name,
|
||||||
|
url: url,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the branch for the submodule.
|
/// Returns the branch for the submodule.
|
||||||
|
@ -206,8 +207,11 @@ class Submodule {
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
set branch(String branch) {
|
set branch(String branch) {
|
||||||
final repo = bindings.owner(_submodulePointer);
|
bindings.setBranch(
|
||||||
bindings.setBranch(repoPointer: repo, name: name, branch: branch);
|
repoPointer: bindings.owner(_submodulePointer),
|
||||||
|
name: name,
|
||||||
|
branch: branch,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the [Oid] for the submodule in the current HEAD tree or
|
/// Returns the [Oid] for the submodule in the current HEAD tree or
|
||||||
|
@ -266,8 +270,11 @@ class Submodule {
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
set updateRule(GitSubmoduleUpdate rule) {
|
set updateRule(GitSubmoduleUpdate rule) {
|
||||||
final repo = bindings.owner(_submodulePointer);
|
bindings.setUpdateRule(
|
||||||
bindings.setUpdateRule(repoPointer: repo, name: name, update: rule.value);
|
repoPointer: bindings.owner(_submodulePointer),
|
||||||
|
name: name,
|
||||||
|
update: rule.value,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Releases memory allocated for submodule object.
|
/// Releases memory allocated for submodule object.
|
||||||
|
|
|
@ -52,6 +52,7 @@ class Tag {
|
||||||
oidPointer: target.pointer,
|
oidPointer: target.pointer,
|
||||||
type: targetType.value,
|
type: targetType.value,
|
||||||
);
|
);
|
||||||
|
|
||||||
final result = bindings.create(
|
final result = bindings.create(
|
||||||
repoPointer: repo.pointer,
|
repoPointer: repo.pointer,
|
||||||
tagName: tagName,
|
tagName: tagName,
|
||||||
|
@ -62,6 +63,7 @@ class Tag {
|
||||||
);
|
);
|
||||||
|
|
||||||
object_bindings.free(object);
|
object_bindings.free(object);
|
||||||
|
|
||||||
return Oid(result);
|
return Oid(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue