chore: upgrade dependencies (#58)

This commit is contained in:
Aleksey Kulikov 2022-05-23 13:50:15 +03:00 committed by GitHub
parent faddaa52e2
commit 3900ec92cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
48 changed files with 3453 additions and 3174 deletions

View file

@ -19,7 +19,7 @@ jobs:
- uses: actions/checkout@v3.0.1 - uses: actions/checkout@v3.0.1
- uses: subosito/flutter-action@v2 - uses: subosito/flutter-action@v2
with: with:
channel: master channel: stable
- name: Install dependencies - name: Install dependencies
run: flutter pub get run: flutter pub get
@ -47,7 +47,7 @@ jobs:
- uses: actions/checkout@v3.0.1 - uses: actions/checkout@v3.0.1
- uses: subosito/flutter-action@v2 - uses: subosito/flutter-action@v2
with: with:
channel: master channel: stable
- name: Install dependencies - name: Install dependencies
run: flutter pub get run: flutter pub get

View file

@ -7,6 +7,7 @@ analyzer:
exclude: exclude:
- lib/src/bindings/libgit2_bindings.dart - lib/src/bindings/libgit2_bindings.dart
- lib/src/bindings/libgit2_opts_bindings.dart
linter: linter:
rules: rules:

View file

@ -1,7 +1,6 @@
import 'dart:io'; import 'dart:io';
import 'package:args/command_runner.dart'; import 'package:args/command_runner.dart';
import 'package:cli_util/cli_logging.dart' show Ansi, Logger;
import 'package:libgit2dart/libgit2dart.dart'; import 'package:libgit2dart/libgit2dart.dart';
import 'package:libgit2dart/src/libgit2.dart'; import 'package:libgit2dart/src/libgit2.dart';
import 'package:libgit2dart/src/util.dart'; import 'package:libgit2dart/src/util.dart';
@ -11,16 +10,13 @@ import 'package:pub_cache/pub_cache.dart';
/// Copies prebuilt libgit2 library from package in '.pub_cache' into correct /// Copies prebuilt libgit2 library from package in '.pub_cache' into correct
/// directory for [platform]. /// directory for [platform].
Future<void> copyLibrary(String platform) async { Future<void> copyLibrary(String platform) async {
final logger = Logger.standard();
final ansi = Ansi(Ansi.terminalSupportsAnsi);
if (File(path.join(Directory.current.path, libDir, platform, getLibName())) if (File(path.join(Directory.current.path, libDir, platform, getLibName()))
.existsSync()) { .existsSync()) {
if (libgit2Version == Libgit2.version) { if (libgit2Version == Libgit2.version) {
logger.stdout('${ansi.green}libgit2 for $platform is already available.'); stdout.writeln('libgit2 for $platform is already available.');
} else { } else {
logger.stdout( stdout.writeln(
'${ansi.red}libgit2 for $platform is outdated.\n' 'libgit2 for $platform is outdated.\n'
'Please run following commands: \n' 'Please run following commands: \n'
'dart run libgit2dart:setup clean\n' 'dart run libgit2dart:setup clean\n'
'dart run libgit2dart:setup\n\n', 'dart run libgit2dart:setup\n\n',
@ -32,17 +28,14 @@ Future<void> copyLibrary(String platform) async {
pubCache.getLatestVersion('libgit2dart')!.resolve()!.location; pubCache.getLatestVersion('libgit2dart')!.resolve()!.location;
final libName = getLibName(); final libName = getLibName();
logger.stdout('Copying libgit2 for $platform'); stdout.writeln('Copying libgit2 for $platform');
final destination = path.join(libDir, platform); final destination = path.join(libDir, platform);
Directory(destination).createSync(recursive: true); Directory(destination).createSync(recursive: true);
File(path.join(pubCacheDir.path, platform, libName)).copySync( File(path.join(pubCacheDir.path, platform, libName)).copySync(
path.join(destination, libName), path.join(destination, libName),
); );
logger.stdout( stdout.writeln('Done! libgit2 for $platform is now available!');
'${ansi.green}Done! libgit2 for $platform is now available!'
'${ansi.none}',
);
} }
} }
@ -55,8 +48,7 @@ class CleanCommand extends Command<void> {
@override @override
void run() { void run() {
final logger = Logger.standard(); stdout.writeln('Cleaning...');
logger.stdout('Cleaning...');
Directory(libDir).deleteSync(recursive: true); Directory(libDir).deleteSync(recursive: true);
} }
} }

View file

@ -1,2 +1,2 @@
#!/bin/bash #!/bin/bash
dart test --coverage="coverage" --test-randomize-ordering-seed random && format_coverage --lcov --check-ignore --in=coverage --out=coverage/lcov.info --packages=.packages --report-on=lib && genhtml coverage/lcov.info -o coverage/ && dart pub global run flutter_coverage_badge dart test --coverage=coverage --test-randomize-ordering-seed random && dart pub global run coverage:format_coverage --lcov --check-ignore --in=coverage --out=coverage/lcov.info --report-on=lib && genhtml coverage/lcov.info -o coverage/ && dart pub global run flutter_coverage_badge

View file

@ -76,7 +76,7 @@ Pointer<git_annotated_commit> fromRevSpec({
required String revspec, required String revspec,
}) { }) {
final out = calloc<Pointer<git_annotated_commit>>(); final out = calloc<Pointer<git_annotated_commit>>();
final revspecC = revspec.toNativeUtf8().cast<Int8>(); final revspecC = revspec.toNativeUtf8().cast<Char>();
final error = libgit2.git_annotated_commit_from_revspec( final error = libgit2.git_annotated_commit_from_revspec(
out, out,
repoPointer, repoPointer,
@ -106,8 +106,8 @@ Pointer<git_annotated_commit> fromFetchHead({
required Pointer<git_oid> oid, required Pointer<git_oid> oid,
}) { }) {
final out = calloc<Pointer<git_annotated_commit>>(); final out = calloc<Pointer<git_annotated_commit>>();
final branchNameC = branchName.toNativeUtf8().cast<Int8>(); final branchNameC = branchName.toNativeUtf8().cast<Char>();
final remoteUrlC = remoteUrl.toNativeUtf8().cast<Int8>(); final remoteUrlC = remoteUrl.toNativeUtf8().cast<Char>();
final error = libgit2.git_annotated_commit_from_fetchhead( final error = libgit2.git_annotated_commit_from_fetchhead(
out, out,
repoPointer, repoPointer,

View file

@ -14,9 +14,9 @@ Object? getAttribute({
required String path, required String path,
required String name, required String name,
}) { }) {
final out = calloc<Pointer<Int8>>(); final out = calloc<Pointer<Char>>();
final pathC = path.toNativeUtf8().cast<Int8>(); final pathC = path.toNativeUtf8().cast<Char>();
final nameC = name.toNativeUtf8().cast<Int8>(); final nameC = name.toNativeUtf8().cast<Char>();
libgit2.git_attr_get(out, repoPointer, flags, pathC, nameC); libgit2.git_attr_get(out, repoPointer, flags, pathC, nameC);
final result = out.value; final result = out.value;

View file

@ -20,7 +20,7 @@ Pointer<git_blame> file({
int? maxLine, int? maxLine,
}) { }) {
final out = calloc<Pointer<git_blame>>(); final out = calloc<Pointer<git_blame>>();
final pathC = path.toNativeUtf8().cast<Int8>(); final pathC = path.toNativeUtf8().cast<Char>();
final options = calloc<git_blame_options>(); final options = calloc<git_blame_options>();
libgit2.git_blame_options_init(options, GIT_BLAME_OPTIONS_VERSION); libgit2.git_blame_options_init(options, GIT_BLAME_OPTIONS_VERSION);
@ -77,7 +77,7 @@ Pointer<git_blame> buffer({
required String buffer, required String buffer,
}) { }) {
final out = calloc<Pointer<git_blame>>(); final out = calloc<Pointer<git_blame>>();
final bufferC = buffer.toNativeUtf8().cast<Int8>(); final bufferC = buffer.toNativeUtf8().cast<Char>();
final error = libgit2.git_blame_buffer( final error = libgit2.git_blame_buffer(
out, out,
reference, reference,

View file

@ -84,7 +84,7 @@ Pointer<git_oid> createFromWorkdir({
required String relativePath, required String relativePath,
}) { }) {
final out = calloc<git_oid>(); final out = calloc<git_oid>();
final relativePathC = relativePath.toNativeUtf8().cast<Int8>(); final relativePathC = relativePath.toNativeUtf8().cast<Char>();
final error = libgit2.git_blob_create_from_workdir( final error = libgit2.git_blob_create_from_workdir(
out, out,
repoPointer, repoPointer,
@ -110,7 +110,7 @@ Pointer<git_oid> createFromDisk({
required String path, required String path,
}) { }) {
final out = calloc<git_oid>(); final out = calloc<git_oid>();
final pathC = path.toNativeUtf8().cast<Int8>(); final pathC = path.toNativeUtf8().cast<Char>();
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); calloc.free(pathC);
@ -150,7 +150,7 @@ String filterContent({
git_oid? attributesCommit, git_oid? attributesCommit,
}) { }) {
final out = calloc<git_buf>(); final out = calloc<git_buf>();
final asPathC = asPath.toNativeUtf8().cast<Int8>(); final asPathC = asPath.toNativeUtf8().cast<Char>();
final opts = calloc<git_blob_filter_options>(); final opts = calloc<git_blob_filter_options>();
libgit2.git_blob_filter_options_init(opts, GIT_BLOB_FILTER_OPTIONS_VERSION); libgit2.git_blob_filter_options_init(opts, GIT_BLOB_FILTER_OPTIONS_VERSION);
opts.ref.flags = flags; opts.ref.flags = flags;

View file

@ -60,7 +60,7 @@ Pointer<git_reference> lookup({
required int branchType, required int branchType,
}) { }) {
final out = calloc<Pointer<git_reference>>(); final out = calloc<Pointer<git_reference>>();
final branchNameC = branchName.toNativeUtf8().cast<Int8>(); final branchNameC = branchName.toNativeUtf8().cast<Char>();
final error = libgit2.git_branch_lookup( final error = libgit2.git_branch_lookup(
out, out,
repoPointer, repoPointer,
@ -97,7 +97,7 @@ Pointer<git_reference> create({
required bool force, required bool force,
}) { }) {
final out = calloc<Pointer<git_reference>>(); final out = calloc<Pointer<git_reference>>();
final branchNameC = branchName.toNativeUtf8().cast<Int8>(); final branchNameC = branchName.toNativeUtf8().cast<Char>();
final forceC = force ? 1 : 0; final forceC = force ? 1 : 0;
final error = libgit2.git_branch_create( final error = libgit2.git_branch_create(
out, out,
@ -147,7 +147,7 @@ void rename({
required bool force, required bool force,
}) { }) {
final out = calloc<Pointer<git_reference>>(); final out = calloc<Pointer<git_reference>>();
final newBranchNameC = newBranchName.toNativeUtf8().cast<Int8>(); final newBranchNameC = newBranchName.toNativeUtf8().cast<Char>();
final forceC = force ? 1 : 0; final forceC = force ? 1 : 0;
final error = libgit2.git_branch_move( final error = libgit2.git_branch_move(
out, out,
@ -202,7 +202,7 @@ bool isCheckedOut(Pointer<git_reference> branch) {
/// ///
/// Throws a [LibGit2Error] if error occured. /// Throws a [LibGit2Error] if error occured.
String name(Pointer<git_reference> ref) { String name(Pointer<git_reference> ref) {
final out = calloc<Pointer<Int8>>(); final out = calloc<Pointer<Char>>();
final error = libgit2.git_branch_name(out, ref); final error = libgit2.git_branch_name(out, ref);
final result = out.value; final result = out.value;
@ -229,7 +229,7 @@ String remoteName({
required String branchName, required String branchName,
}) { }) {
final out = calloc<git_buf>(); final out = calloc<git_buf>();
final branchNameC = branchName.toNativeUtf8().cast<Int8>(); final branchNameC = branchName.toNativeUtf8().cast<Char>();
final error = libgit2.git_branch_remote_name(out, repoPointer, branchNameC); final error = libgit2.git_branch_remote_name(out, repoPointer, branchNameC);
final result = out.ref.ptr.cast<Utf8>().toDartString(length: out.ref.size); final result = out.ref.ptr.cast<Utf8>().toDartString(length: out.ref.size);
@ -281,7 +281,7 @@ void setUpstream({
required Pointer<git_reference> branchPointer, required Pointer<git_reference> branchPointer,
required String? branchName, required String? branchName,
}) { }) {
final branchNameC = branchName?.toNativeUtf8().cast<Int8>() ?? nullptr; final branchNameC = branchName?.toNativeUtf8().cast<Char>() ?? nullptr;
final error = libgit2.git_branch_set_upstream(branchPointer, branchNameC); final error = libgit2.git_branch_set_upstream(branchPointer, branchNameC);
calloc.free(branchNameC); calloc.free(branchNameC);
@ -303,7 +303,7 @@ String upstreamName({
required String branchName, required String branchName,
}) { }) {
final out = calloc<git_buf>(); final out = calloc<git_buf>();
final branchNameC = branchName.toNativeUtf8().cast<Int8>(); final branchNameC = branchName.toNativeUtf8().cast<Char>();
final error = libgit2.git_branch_upstream_name(out, repoPointer, branchNameC); final error = libgit2.git_branch_upstream_name(out, repoPointer, branchNameC);
final result = out.ref.ptr.cast<Utf8>().toDartString(length: out.ref.size); final result = out.ref.ptr.cast<Utf8>().toDartString(length: out.ref.size);
@ -330,7 +330,7 @@ String upstreamRemote({
required String branchName, required String branchName,
}) { }) {
final out = calloc<git_buf>(); final out = calloc<git_buf>();
final branchNameC = branchName.toNativeUtf8().cast<Int8>(); final branchNameC = branchName.toNativeUtf8().cast<Char>();
final error = libgit2.git_branch_upstream_remote( final error = libgit2.git_branch_upstream_remote(
out, out,
repoPointer, repoPointer,
@ -361,7 +361,7 @@ String upstreamMerge({
required String branchName, required String branchName,
}) { }) {
final out = calloc<git_buf>(); final out = calloc<git_buf>();
final branchNameC = branchName.toNativeUtf8().cast<Int8>(); final branchNameC = branchName.toNativeUtf8().cast<Char>();
final error = libgit2.git_branch_upstream_merge( final error = libgit2.git_branch_upstream_merge(
out, out,
repoPointer, repoPointer,

View file

@ -127,13 +127,13 @@ List<Object> initOptions({
optsC.ref.checkout_strategy = strategy; optsC.ref.checkout_strategy = strategy;
if (directory != null) { if (directory != null) {
optsC.ref.target_directory = directory.toNativeUtf8().cast<Int8>(); optsC.ref.target_directory = directory.toNativeUtf8().cast<Char>();
} }
var pathPointers = <Pointer<Int8>>[]; var pathPointers = <Pointer<Char>>[];
Pointer<Pointer<Int8>> strArray = nullptr; Pointer<Pointer<Char>> strArray = nullptr;
if (paths != null) { if (paths != null) {
pathPointers = paths.map((e) => e.toNativeUtf8().cast<Int8>()).toList(); pathPointers = paths.map((e) => e.toNativeUtf8().cast<Char>()).toList();
strArray = calloc(paths.length); strArray = calloc(paths.length);
for (var i = 0; i < paths.length; i++) { for (var i = 0; i < paths.length; i++) {
strArray[i] = pathPointers[i]; strArray[i] = pathPointers[i];

View file

@ -45,10 +45,10 @@ Pointer<git_oid> create({
required List<Pointer<git_commit>> parents, required List<Pointer<git_commit>> parents,
}) { }) {
final out = calloc<git_oid>(); final out = calloc<git_oid>();
final updateRefC = updateRef.toNativeUtf8().cast<Int8>(); final updateRefC = updateRef.toNativeUtf8().cast<Char>();
final messageEncodingC = final messageEncodingC =
messageEncoding?.toNativeUtf8().cast<Int8>() ?? nullptr; messageEncoding?.toNativeUtf8().cast<Char>() ?? nullptr;
final messageC = message.toNativeUtf8().cast<Int8>(); final messageC = message.toNativeUtf8().cast<Char>();
final parentsC = calloc<Pointer<git_commit>>(parentCount); final parentsC = calloc<Pointer<git_commit>>(parentCount);
if (parents.isNotEmpty) { if (parents.isNotEmpty) {
@ -103,10 +103,10 @@ String createBuffer({
required List<Pointer<git_commit>> parents, required List<Pointer<git_commit>> parents,
}) { }) {
final out = calloc<git_buf>(); final out = calloc<git_buf>();
final updateRefC = updateRef.toNativeUtf8().cast<Int8>(); final updateRefC = updateRef.toNativeUtf8().cast<Char>();
final messageEncodingC = final messageEncodingC =
messageEncoding?.toNativeUtf8().cast<Int8>() ?? nullptr; messageEncoding?.toNativeUtf8().cast<Char>() ?? nullptr;
final messageC = message.toNativeUtf8().cast<Int8>(); final messageC = message.toNativeUtf8().cast<Char>();
final parentsC = calloc<Pointer<git_commit>>(parentCount); final parentsC = calloc<Pointer<git_commit>>(parentCount);
if (parents.isNotEmpty) { if (parents.isNotEmpty) {
@ -169,10 +169,10 @@ Pointer<git_oid> amend({
required Pointer<git_tree>? treePointer, required Pointer<git_tree>? treePointer,
}) { }) {
final out = calloc<git_oid>(); final out = calloc<git_oid>();
final updateRefC = updateRef?.toNativeUtf8().cast<Int8>() ?? nullptr; final updateRefC = updateRef?.toNativeUtf8().cast<Char>() ?? nullptr;
final messageEncodingC = final messageEncodingC =
messageEncoding?.toNativeUtf8().cast<Int8>() ?? nullptr; messageEncoding?.toNativeUtf8().cast<Char>() ?? nullptr;
final messageC = message?.toNativeUtf8().cast<Int8>() ?? nullptr; final messageC = message?.toNativeUtf8().cast<Char>() ?? nullptr;
final error = libgit2.git_commit_amend( final error = libgit2.git_commit_amend(
out, out,
@ -261,7 +261,7 @@ String headerField({
required String field, required String field,
}) { }) {
final out = calloc<git_buf>(); final out = calloc<git_buf>();
final fieldC = field.toNativeUtf8().cast<Int8>(); final fieldC = field.toNativeUtf8().cast<Char>();
final error = libgit2.git_commit_header_field(out, commitPointer, fieldC); final error = libgit2.git_commit_header_field(out, commitPointer, fieldC);
final result = out.ref.ptr.cast<Utf8>().toDartString(length: out.ref.size); final result = out.ref.ptr.cast<Utf8>().toDartString(length: out.ref.size);

View file

@ -11,7 +11,7 @@ import 'package:libgit2dart/src/util.dart';
/// config must be freed with [free]. /// config must be freed with [free].
Pointer<git_config> open(String path) { Pointer<git_config> open(String path) {
final out = calloc<Pointer<git_config>>(); final out = calloc<Pointer<git_config>>();
final pathC = path.toNativeUtf8().cast<Int8>(); final pathC = path.toNativeUtf8().cast<Char>();
libgit2.git_config_open_ondisk(out, pathC); libgit2.git_config_open_ondisk(out, pathC);
calloc.free(pathC); calloc.free(pathC);
@ -145,7 +145,7 @@ Pointer<git_config_entry> getEntry({
required String variable, required String variable,
}) { }) {
final out = calloc<Pointer<git_config_entry>>(); final out = calloc<Pointer<git_config_entry>>();
final nameC = variable.toNativeUtf8().cast<Int8>(); final nameC = variable.toNativeUtf8().cast<Char>();
final error = libgit2.git_config_get_entry(out, configPointer, nameC); final error = libgit2.git_config_get_entry(out, configPointer, nameC);
final result = out.value; final result = out.value;
@ -167,7 +167,7 @@ void setBool({
required String variable, required String variable,
required bool value, required bool value,
}) { }) {
final nameC = variable.toNativeUtf8().cast<Int8>(); final nameC = variable.toNativeUtf8().cast<Char>();
final valueC = value ? 1 : 0; final valueC = value ? 1 : 0;
libgit2.git_config_set_bool(configPointer, nameC, valueC); libgit2.git_config_set_bool(configPointer, nameC, valueC);
calloc.free(nameC); calloc.free(nameC);
@ -180,7 +180,7 @@ void setInt({
required String variable, required String variable,
required int value, required int value,
}) { }) {
final nameC = variable.toNativeUtf8().cast<Int8>(); final nameC = variable.toNativeUtf8().cast<Char>();
libgit2.git_config_set_int64(configPointer, nameC, value); libgit2.git_config_set_int64(configPointer, nameC, value);
calloc.free(nameC); calloc.free(nameC);
} }
@ -192,8 +192,8 @@ void setString({
required String variable, required String variable,
required String value, required String value,
}) { }) {
final nameC = variable.toNativeUtf8().cast<Int8>(); final nameC = variable.toNativeUtf8().cast<Char>();
final valueC = value.toNativeUtf8().cast<Int8>(); final valueC = value.toNativeUtf8().cast<Char>();
libgit2.git_config_set_string(configPointer, nameC, valueC); libgit2.git_config_set_string(configPointer, nameC, valueC);
calloc.free(nameC); calloc.free(nameC);
calloc.free(valueC); calloc.free(valueC);
@ -220,7 +220,7 @@ void delete({
required Pointer<git_config> configPointer, required Pointer<git_config> configPointer,
required String variable, required String variable,
}) { }) {
final nameC = variable.toNativeUtf8().cast<Int8>(); final nameC = variable.toNativeUtf8().cast<Char>();
final error = libgit2.git_config_delete_entry(configPointer, nameC); final error = libgit2.git_config_delete_entry(configPointer, nameC);
calloc.free(nameC); calloc.free(nameC);
@ -243,8 +243,8 @@ List<String> multivarValues({
required String variable, required String variable,
String? regexp, String? regexp,
}) { }) {
final nameC = variable.toNativeUtf8().cast<Int8>(); final nameC = variable.toNativeUtf8().cast<Char>();
final regexpC = regexp?.toNativeUtf8().cast<Int8>() ?? nullptr; final regexpC = regexp?.toNativeUtf8().cast<Char>() ?? nullptr;
final iterator = calloc<Pointer<git_config_iterator>>(); final iterator = calloc<Pointer<git_config_iterator>>();
final entry = calloc<Pointer<git_config_entry>>(); final entry = calloc<Pointer<git_config_entry>>();
@ -286,9 +286,9 @@ void setMultivar({
required String regexp, required String regexp,
required String value, required String value,
}) { }) {
final nameC = variable.toNativeUtf8().cast<Int8>(); final nameC = variable.toNativeUtf8().cast<Char>();
final regexpC = regexp.toNativeUtf8().cast<Int8>(); final regexpC = regexp.toNativeUtf8().cast<Char>();
final valueC = value.toNativeUtf8().cast<Int8>(); final valueC = value.toNativeUtf8().cast<Char>();
libgit2.git_config_set_multivar(configPointer, nameC, regexpC, valueC); libgit2.git_config_set_multivar(configPointer, nameC, regexpC, valueC);
@ -306,8 +306,8 @@ void deleteMultivar({
required String variable, required String variable,
required String regexp, required String regexp,
}) { }) {
final nameC = variable.toNativeUtf8().cast<Int8>(); final nameC = variable.toNativeUtf8().cast<Char>();
final regexpC = regexp.toNativeUtf8().cast<Int8>(); final regexpC = regexp.toNativeUtf8().cast<Char>();
libgit2.git_config_delete_multivar(configPointer, nameC, regexpC); libgit2.git_config_delete_multivar(configPointer, nameC, regexpC);

View file

@ -10,8 +10,8 @@ Pointer<git_credential> userPass({
required String password, required String password,
}) { }) {
final out = calloc<Pointer<git_credential>>(); final out = calloc<Pointer<git_credential>>();
final usernameC = username.toNativeUtf8().cast<Int8>(); final usernameC = username.toNativeUtf8().cast<Char>();
final passwordC = password.toNativeUtf8().cast<Int8>(); final passwordC = password.toNativeUtf8().cast<Char>();
libgit2.git_credential_userpass_plaintext_new(out, usernameC, passwordC); libgit2.git_credential_userpass_plaintext_new(out, usernameC, passwordC);
@ -32,10 +32,10 @@ Pointer<git_credential> sshKey({
required String passPhrase, required String passPhrase,
}) { }) {
final out = calloc<Pointer<git_credential>>(); final out = calloc<Pointer<git_credential>>();
final usernameC = username.toNativeUtf8().cast<Int8>(); final usernameC = username.toNativeUtf8().cast<Char>();
final publicKeyC = publicKey.toNativeUtf8().cast<Int8>(); final publicKeyC = publicKey.toNativeUtf8().cast<Char>();
final privateKeyC = privateKey.toNativeUtf8().cast<Int8>(); final privateKeyC = privateKey.toNativeUtf8().cast<Char>();
final passPhraseC = passPhrase.toNativeUtf8().cast<Int8>(); final passPhraseC = passPhrase.toNativeUtf8().cast<Char>();
libgit2.git_credential_ssh_key_new( libgit2.git_credential_ssh_key_new(
out, out,
@ -59,7 +59,7 @@ Pointer<git_credential> sshKey({
/// Create a new ssh key credential object used for querying an ssh-agent. /// Create a new ssh key credential object used for querying an ssh-agent.
Pointer<git_credential> sshKeyFromAgent(String username) { Pointer<git_credential> sshKeyFromAgent(String username) {
final out = calloc<Pointer<git_credential>>(); final out = calloc<Pointer<git_credential>>();
final usernameC = username.toNativeUtf8().cast<Int8>(); final usernameC = username.toNativeUtf8().cast<Char>();
libgit2.git_credential_ssh_key_from_agent(out, usernameC); libgit2.git_credential_ssh_key_from_agent(out, usernameC);
@ -79,10 +79,10 @@ Pointer<git_credential> sshKeyFromMemory({
required String passPhrase, required String passPhrase,
}) { }) {
final out = calloc<Pointer<git_credential>>(); final out = calloc<Pointer<git_credential>>();
final usernameC = username.toNativeUtf8().cast<Int8>(); final usernameC = username.toNativeUtf8().cast<Char>();
final publicKeyC = publicKey.toNativeUtf8().cast<Int8>(); final publicKeyC = publicKey.toNativeUtf8().cast<Char>();
final privateKeyC = privateKey.toNativeUtf8().cast<Int8>(); final privateKeyC = privateKey.toNativeUtf8().cast<Char>();
final passPhraseC = passPhrase.toNativeUtf8().cast<Int8>(); final passPhraseC = passPhrase.toNativeUtf8().cast<Char>();
libgit2.git_credential_ssh_key_memory_new( libgit2.git_credential_ssh_key_memory_new(
out, out,

View file

@ -100,7 +100,7 @@ String format({
opts.ref.always_use_long_format = alwaysUseLongFormat ? 1 : 0; opts.ref.always_use_long_format = alwaysUseLongFormat ? 1 : 0;
} }
if (dirtySuffix != null) { if (dirtySuffix != null) {
opts.ref.dirty_suffix = dirtySuffix.toNativeUtf8().cast<Int8>(); opts.ref.dirty_suffix = dirtySuffix.toNativeUtf8().cast<Char>();
} }
libgit2.git_describe_format(out, describeResultPointer, opts); libgit2.git_describe_format(out, describeResultPointer, opts);
@ -140,7 +140,7 @@ Pointer<git_describe_options> _initOpts({
opts.ref.describe_strategy = describeStrategy; opts.ref.describe_strategy = describeStrategy;
} }
if (pattern != null) { if (pattern != null) {
opts.ref.pattern = pattern.toNativeUtf8().cast<Int8>(); opts.ref.pattern = pattern.toNativeUtf8().cast<Char>();
} }
if (onlyFollowFirstParent != null) { if (onlyFollowFirstParent != null) {
opts.ref.only_follow_first_parent = onlyFollowFirstParent ? 1 : 0; opts.ref.only_follow_first_parent = onlyFollowFirstParent ? 1 : 0;

View file

@ -253,7 +253,7 @@ void merge({
/// other types of patch files. /// other types of patch files.
Pointer<git_diff> parse(String content) { Pointer<git_diff> parse(String content) {
final out = calloc<Pointer<git_diff>>(); final out = calloc<Pointer<git_diff>>();
final contentC = content.toNativeUtf8().cast<Int8>(); final contentC = content.toNativeUtf8().cast<Char>();
libgit2.git_diff_from_buffer(out, contentC, content.length); libgit2.git_diff_from_buffer(out, contentC, content.length);
final result = out.value; final result = out.value;

View file

@ -33,8 +33,8 @@ List<int> aheadBehind({
required Pointer<git_oid> localPointer, required Pointer<git_oid> localPointer,
required Pointer<git_oid> upstreamPointer, required Pointer<git_oid> upstreamPointer,
}) { }) {
final ahead = calloc<Uint64>(); final ahead = calloc<Size>();
final behind = calloc<Uint64>(); final behind = calloc<Size>();
libgit2.git_graph_ahead_behind( libgit2.git_graph_ahead_behind(
ahead, ahead,

View file

@ -125,7 +125,7 @@ Pointer<git_oid> writeTreeTo({
/// Find the first position of any entries which point to given path in the Git /// Find the first position of any entries which point to given path in the Git
/// index. /// index.
bool find({required Pointer<git_index> indexPointer, required String path}) { bool find({required Pointer<git_index> indexPointer, required String path}) {
final pathC = path.toNativeUtf8().cast<Int8>(); final pathC = path.toNativeUtf8().cast<Char>();
final result = libgit2.git_index_find(nullptr, indexPointer, pathC); final result = libgit2.git_index_find(nullptr, indexPointer, pathC);
calloc.free(pathC); calloc.free(pathC);
@ -164,7 +164,7 @@ Pointer<git_index_entry> getByPath({
required String path, required String path,
required int stage, required int stage,
}) { }) {
final pathC = path.toNativeUtf8().cast<Int8>(); final pathC = path.toNativeUtf8().cast<Char>();
final result = libgit2.git_index_get_bypath(indexPointer, pathC, stage); final result = libgit2.git_index_get_bypath(indexPointer, pathC, stage);
calloc.free(pathC); calloc.free(pathC);
@ -231,7 +231,7 @@ void addByPath({
required Pointer<git_index> indexPointer, required Pointer<git_index> indexPointer,
required String path, required String path,
}) { }) {
final pathC = path.toNativeUtf8().cast<Int8>(); final pathC = path.toNativeUtf8().cast<Char>();
final error = libgit2.git_index_add_bypath(indexPointer, pathC); final error = libgit2.git_index_add_bypath(indexPointer, pathC);
calloc.free(pathC); calloc.free(pathC);
@ -294,8 +294,8 @@ void addAll({
}) { }) {
final pathspecC = calloc<git_strarray>(); final pathspecC = calloc<git_strarray>();
final pathPointers = final pathPointers =
pathspec.map((e) => e.toNativeUtf8().cast<Int8>()).toList(); pathspec.map((e) => e.toNativeUtf8().cast<Char>()).toList();
final strArray = calloc<Pointer<Int8>>(pathspec.length); final strArray = calloc<Pointer<Char>>(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];
@ -339,8 +339,8 @@ void updateAll({
}) { }) {
final pathspecC = calloc<git_strarray>(); final pathspecC = calloc<git_strarray>();
final pathPointers = final pathPointers =
pathspec.map((e) => e.toNativeUtf8().cast<Int8>()).toList(); pathspec.map((e) => e.toNativeUtf8().cast<Char>()).toList();
final strArray = calloc<Pointer<Int8>>(pathspec.length); final strArray = calloc<Pointer<Char>>(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];
@ -379,7 +379,7 @@ void remove({
required String path, required String path,
required int stage, required int stage,
}) { }) {
final pathC = path.toNativeUtf8().cast<Int8>(); final pathC = path.toNativeUtf8().cast<Char>();
final error = libgit2.git_index_remove(indexPointer, pathC, stage); final error = libgit2.git_index_remove(indexPointer, pathC, stage);
calloc.free(pathC); calloc.free(pathC);
@ -395,7 +395,7 @@ void removeDirectory({
required String dir, required String dir,
required int stage, required int stage,
}) { }) {
final dirC = dir.toNativeUtf8().cast<Int8>(); final dirC = dir.toNativeUtf8().cast<Char>();
libgit2.git_index_remove_directory(indexPointer, dirC, stage); libgit2.git_index_remove_directory(indexPointer, dirC, stage);
calloc.free(dirC); calloc.free(dirC);
} }
@ -407,8 +407,8 @@ void removeAll({
}) { }) {
final pathspecC = calloc<git_strarray>(); final pathspecC = calloc<git_strarray>();
final pathPointers = final pathPointers =
pathspec.map((e) => e.toNativeUtf8().cast<Int8>()).toList(); pathspec.map((e) => e.toNativeUtf8().cast<Char>()).toList();
final strArray = calloc<Pointer<Int8>>(pathspec.length); final strArray = calloc<Pointer<Char>>(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];
@ -511,7 +511,7 @@ void conflictRemove({
required Pointer<git_index> indexPointer, required Pointer<git_index> indexPointer,
required String path, required String path,
}) { }) {
final pathC = path.toNativeUtf8().cast<Int8>(); final pathC = path.toNativeUtf8().cast<Char>();
final error = libgit2.git_index_conflict_remove(indexPointer, pathC); final error = libgit2.git_index_conflict_remove(indexPointer, pathC);
calloc.free(pathC); calloc.free(pathC);

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,294 @@
// coverage:ignore-file
import 'dart:ffi' as ffi;
/// Bindings to libgit2 global options
class Libgit2Opts {
/// Holds the symbol lookup function.
final ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName)
_lookup;
/// The symbols are looked up in [dynamicLibrary].
Libgit2Opts(ffi.DynamicLibrary dynamicLibrary)
: _lookup = dynamicLibrary.lookup;
/// Set or query a library global option
///
/// Available options:
///
/// * opts(GIT_OPT_GET_MWINDOW_SIZE, size_t *):
///
/// > Get the maximum mmap window size
///
/// * opts(GIT_OPT_SET_MWINDOW_SIZE, size_t):
///
/// > Set the maximum mmap window size
///
/// * opts(GIT_OPT_GET_MWINDOW_MAPPED_LIMIT, size_t *):
///
/// > Get the maximum memory that will be mapped in total by the library
///
/// * opts(GIT_OPT_SET_MWINDOW_MAPPED_LIMIT, size_t):
///
/// > Set the maximum amount of memory that can be mapped at any time
/// > by the library
///
/// * opts(GIT_OPT_GET_MWINDOW_FILE_LIMIT, size_t *):
///
/// > Get the maximum number of files that will be mapped at any time by the
/// > library
///
/// * opts(GIT_OPT_SET_MWINDOW_FILE_LIMIT, size_t):
///
/// > Set the maximum number of files that can be mapped at any time
/// > by the library. The default (0) is unlimited.
///
/// * opts(GIT_OPT_GET_SEARCH_PATH, int level, git_buf *buf)
///
/// > Get the search path for a given level of config data. "level" must
/// > be one of `GIT_CONFIG_LEVEL_SYSTEM`, `GIT_CONFIG_LEVEL_GLOBAL`,
/// > `GIT_CONFIG_LEVEL_XDG`, or `GIT_CONFIG_LEVEL_PROGRAMDATA`.
/// > The search path is written to the `out` buffer.
///
/// * opts(GIT_OPT_SET_SEARCH_PATH, int level, const char *path)
///
/// > Set the search path for a level of config data. The search path
/// > applied to shared attributes and ignore files, too.
/// >
/// > - `path` lists directories delimited by GIT_PATH_LIST_SEPARATOR.
/// > Pass NULL to reset to the default (generally based on environment
/// > variables). Use magic path `$PATH` to include the old value
/// > of the path (if you want to prepend or append, for instance).
/// >
/// > - `level` must be `GIT_CONFIG_LEVEL_SYSTEM`,
/// > `GIT_CONFIG_LEVEL_GLOBAL`, `GIT_CONFIG_LEVEL_XDG`, or
/// > `GIT_CONFIG_LEVEL_PROGRAMDATA`.
///
/// * opts(GIT_OPT_SET_CACHE_OBJECT_LIMIT, git_object_t type, size_t size)
///
/// > Set the maximum data size for the given type of object to be
/// > considered eligible for caching in memory. Setting to value to
/// > zero means that that type of object will not be cached.
/// > Defaults to 0 for GIT_OBJECT_BLOB (i.e. won't cache blobs) and 4k
/// > for GIT_OBJECT_COMMIT, GIT_OBJECT_TREE, and GIT_OBJECT_TAG.
///
/// * opts(GIT_OPT_SET_CACHE_MAX_SIZE, ssize_t max_storage_bytes)
///
/// > Set the maximum total data size that will be cached in memory
/// > across all repositories before libgit2 starts evicting objects
/// > from the cache. This is a soft limit, in that the library might
/// > briefly exceed it, but will start aggressively evicting objects
/// > from cache when that happens. The default cache size is 256MB.
///
/// * opts(GIT_OPT_ENABLE_CACHING, int enabled)
///
/// > Enable or disable caching completely.
/// >
/// > Because caches are repository-specific, disabling the cache
/// > cannot immediately clear all cached objects, but each cache will
/// > be cleared on the next attempt to update anything in it.
///
/// * opts(GIT_OPT_GET_CACHED_MEMORY, ssize_t *current, ssize_t *allowed)
///
/// > Get the current bytes in cache and the maximum that would be
/// > allowed in the cache.
///
/// * opts(GIT_OPT_GET_TEMPLATE_PATH, git_buf *out)
///
/// > Get the default template path.
/// > The path is written to the `out` buffer.
///
/// * opts(GIT_OPT_SET_TEMPLATE_PATH, const char *path)
///
/// > Set the default template path.
/// >
/// > - `path` directory of template.
///
/// * opts(GIT_OPT_SET_SSL_CERT_LOCATIONS, const char *file, const char *path)
///
/// > Set the SSL certificate-authority locations.
/// >
/// > - `file` is the location of a file containing several
/// > certificates concatenated together.
/// > - `path` is the location of a directory holding several
/// > certificates, one per file.
/// >
/// > Either parameter may be `NULL`, but not both.
///
/// * opts(GIT_OPT_SET_USER_AGENT, const char *user_agent)
///
/// > Set the value of the User-Agent header. This value will be
/// > appended to "git/1.0", for compatibility with other git clients.
/// >
/// > - `user_agent` is the value that will be delivered as the
/// > User-Agent header on HTTP requests.
///
/// * opts(GIT_OPT_SET_WINDOWS_SHAREMODE, unsigned long value)
///
/// > Set the share mode used when opening files on Windows.
/// > For more information, see the documentation for CreateFile.
/// > The default is: FILE_SHARE_READ | FILE_SHARE_WRITE. This is
/// > ignored and unused on non-Windows platforms.
///
/// * opts(GIT_OPT_GET_WINDOWS_SHAREMODE, unsigned long *value)
///
/// > Get the share mode used when opening files on Windows.
///
/// * opts(GIT_OPT_ENABLE_STRICT_OBJECT_CREATION, int enabled)
///
/// > Enable strict input validation when creating new objects
/// > to ensure that all inputs to the new objects are valid. For
/// > example, when this is enabled, the parent(s) and tree inputs
/// > will be validated when creating a new commit. This defaults
/// > to enabled.
///
/// * opts(GIT_OPT_ENABLE_STRICT_SYMBOLIC_REF_CREATION, int enabled)
///
/// > Validate the target of a symbolic ref when creating it. For
/// > example, `foobar` is not a valid ref, therefore `foobar` is
/// > not a valid target for a symbolic ref by default, whereas
/// > `refs/heads/foobar` is. Disabling this bypasses validation
/// > so that an arbitrary strings such as `foobar` can be used
/// > for a symbolic ref target. This defaults to enabled.
///
/// * opts(GIT_OPT_SET_SSL_CIPHERS, const char *ciphers)
///
/// > Set the SSL ciphers use for HTTPS connections.
/// >
/// > - `ciphers` is the list of ciphers that are eanbled.
///
/// * opts(GIT_OPT_GET_USER_AGENT, git_buf *out)
///
/// > Get the value of the User-Agent header.
/// > The User-Agent is written to the `out` buffer.
///
/// * opts(GIT_OPT_ENABLE_OFS_DELTA, int enabled)
///
/// > Enable or disable the use of "offset deltas" when creating packfiles,
/// > and the negotiation of them when talking to a remote server.
/// > Offset deltas store a delta base location as an offset into the
/// > packfile from the current location, which provides a shorter encoding
/// > and thus smaller resultant packfiles.
/// > Packfiles containing offset deltas can still be read.
/// > This defaults to enabled.
///
/// * opts(GIT_OPT_ENABLE_FSYNC_GITDIR, int enabled)
///
/// > Enable synchronized writes of files in the gitdir using `fsync`
/// > (or the platform equivalent) to ensure that new object data
/// > is written to permanent storage, not simply cached. This
/// > defaults to disabled.
///
/// opts(GIT_OPT_ENABLE_STRICT_HASH_VERIFICATION, int enabled)
///
/// > Enable strict verification of object hashsums when reading
/// > objects from disk. This may impact performance due to an
/// > additional checksum calculation on each object. This defaults
/// > to enabled.
///
/// opts(GIT_OPT_SET_ALLOCATOR, git_allocator *allocator)
///
/// > Set the memory allocator to a different memory allocator. This
/// > allocator will then be used to make all memory allocations for
/// > libgit2 operations. If the given `allocator` is NULL, then the
/// > system default will be restored.
///
/// opts(GIT_OPT_ENABLE_UNSAVED_INDEX_SAFETY, int enabled)
///
/// > Ensure that there are no unsaved changes in the index before
/// > beginning any operation that reloads the index from disk (eg,
/// > checkout). If there are unsaved changes, the instruction will
/// > fail. (Using the FORCE flag to checkout will still overwrite
/// > these changes.)
///
/// opts(GIT_OPT_GET_PACK_MAX_OBJECTS, size_t *out)
///
/// > Get the maximum number of objects libgit2 will allow in a pack
/// > file when downloading a pack file from a remote. This can be
/// > used to limit maximum memory usage when fetching from an untrusted
/// > remote.
///
/// opts(GIT_OPT_SET_PACK_MAX_OBJECTS, size_t objects)
///
/// > Set the maximum number of objects libgit2 will allow in a pack
/// > file when downloading a pack file from a remote.
///
/// opts(GIT_OPT_DISABLE_PACK_KEEP_FILE_CHECKS, int enabled)
/// > This will cause .keep file existence checks to be skipped when
/// > accessing packfiles, which can help performance with remote filesystems.
///
/// opts(GIT_OPT_ENABLE_HTTP_EXPECT_CONTINUE, int enabled)
/// > When connecting to a server using NTLM or Negotiate
/// > authentication, use expect/continue when POSTing data.
/// > This option is not available on Windows.
///
/// opts(GIT_OPT_SET_ODB_PACKED_PRIORITY, int priority)
/// > Override the default priority of the packed ODB backend which
/// > is added when default backends are assigned to a repository
///
/// opts(GIT_OPT_SET_ODB_LOOSE_PRIORITY, int priority)
/// > Override the default priority of the loose ODB backend which
/// > is added when default backends are assigned to a repository
///
/// opts(GIT_OPT_GET_EXTENSIONS, git_strarray *out)
/// > Returns the list of git extensions that are supported. This
/// > is the list of built-in extensions supported by libgit2 and
/// > custom extensions that have been added with
/// > `GIT_OPT_SET_EXTENSIONS`. Extensions that have been negated
/// > will not be returned. The returned list should be released
/// > with `git_strarray_dispose`.
///
/// opts(GIT_OPT_SET_EXTENSIONS, const char **extensions, size_t len)
/// > Set that the given git extensions are supported by the caller.
/// > Extensions supported by libgit2 may be negated by prefixing
/// > them with a `!`. For example: setting extensions to
/// > { "!noop", "newext" } indicates that the caller does not want
/// > to support repositories with the `noop` extension but does want
/// > to support repositories with the `newext` extension.
///
/// opts(GIT_OPT_GET_OWNER_VALIDATION, int *enabled)
/// > Gets the owner validation setting for repository
/// > directories.
///
/// opts(GIT_OPT_SET_OWNER_VALIDATION, int enabled)
/// > Set that repository directories should be owned by the current
/// > user. The default is to validate ownership.
///
/// @param option Option key
/// @param ... value to set the option
/// @return 0 on success, <0 on failure
int git_libgit2_opts(
int option,
ffi.Pointer<ffi.Char> out,
) {
return _git_libgit2_opts(
option,
out,
);
}
late final _git_libgit2_optsPtr = _lookup<
ffi.NativeFunction<ffi.Int Function(ffi.Int, ffi.Pointer<ffi.Char>)>>(
'git_libgit2_opts');
late final _git_libgit2_opts = _git_libgit2_optsPtr
.asFunction<int Function(int, ffi.Pointer<ffi.Char>)>();
/// Set a library global option.
///
/// Look at [git_libgit2_opts]
int git_libgit2_opts_set(
int option,
int value,
) {
return _git_libgit2_opts_set(
option,
value,
);
}
late final _git_libgit2_opts_setPtr =
_lookup<ffi.NativeFunction<ffi.Int Function(ffi.Int, ffi.Int)>>(
'git_libgit2_opts');
late final _git_libgit2_opts_set =
_git_libgit2_opts_setPtr.asFunction<int Function(int, int)>();
}

View file

@ -25,7 +25,7 @@ Pointer<git_mailmap> init() {
/// returned mailmap must be freed with [free]. /// returned mailmap must be freed with [free].
Pointer<git_mailmap> fromBuffer(String buffer) { Pointer<git_mailmap> fromBuffer(String buffer) {
final out = calloc<Pointer<git_mailmap>>(); final out = calloc<Pointer<git_mailmap>>();
final bufferC = buffer.toNativeUtf8().cast<Int8>(); final bufferC = buffer.toNativeUtf8().cast<Char>();
libgit2.git_mailmap_from_buffer(out, bufferC, buffer.length); libgit2.git_mailmap_from_buffer(out, bufferC, buffer.length);
@ -70,10 +70,10 @@ List<String> resolve({
required String name, required String name,
required String email, required String email,
}) { }) {
final outRealName = calloc<Pointer<Int8>>(); final outRealName = calloc<Pointer<Char>>();
final outRealEmail = calloc<Pointer<Int8>>(); final outRealEmail = calloc<Pointer<Char>>();
final nameC = name.toNativeUtf8().cast<Int8>(); final nameC = name.toNativeUtf8().cast<Char>();
final emailC = email.toNativeUtf8().cast<Int8>(); final emailC = email.toNativeUtf8().cast<Char>();
libgit2.git_mailmap_resolve( libgit2.git_mailmap_resolve(
outRealName, outRealName,
outRealEmail, outRealEmail,
@ -119,10 +119,10 @@ void addEntry({
String? replaceName, String? replaceName,
required String replaceEmail, required String replaceEmail,
}) { }) {
final realNameC = realName?.toNativeUtf8().cast<Int8>() ?? nullptr; final realNameC = realName?.toNativeUtf8().cast<Char>() ?? nullptr;
final realEmailC = realEmail?.toNativeUtf8().cast<Int8>() ?? nullptr; final realEmailC = realEmail?.toNativeUtf8().cast<Char>() ?? nullptr;
final replaceNameC = replaceName?.toNativeUtf8().cast<Int8>() ?? nullptr; final replaceNameC = replaceName?.toNativeUtf8().cast<Char>() ?? nullptr;
final replaceEmailC = replaceEmail.toNativeUtf8().cast<Int8>(); final replaceEmailC = replaceEmail.toNativeUtf8().cast<Char>();
libgit2.git_mailmap_add_entry( libgit2.git_mailmap_add_entry(
mailmapPointer, mailmapPointer,

View file

@ -183,11 +183,11 @@ String mergeFile({
libgit2.git_merge_file_input_init(ancestorC, GIT_MERGE_FILE_INPUT_VERSION); libgit2.git_merge_file_input_init(ancestorC, GIT_MERGE_FILE_INPUT_VERSION);
libgit2.git_merge_file_input_init(oursC, GIT_MERGE_FILE_INPUT_VERSION); libgit2.git_merge_file_input_init(oursC, GIT_MERGE_FILE_INPUT_VERSION);
libgit2.git_merge_file_input_init(theirsC, GIT_MERGE_FILE_INPUT_VERSION); libgit2.git_merge_file_input_init(theirsC, GIT_MERGE_FILE_INPUT_VERSION);
ancestorC.ref.ptr = ancestor.toNativeUtf8().cast<Int8>(); ancestorC.ref.ptr = ancestor.toNativeUtf8().cast<Char>();
ancestorC.ref.size = ancestor.length; ancestorC.ref.size = ancestor.length;
oursC.ref.ptr = ours.toNativeUtf8().cast<Int8>(); oursC.ref.ptr = ours.toNativeUtf8().cast<Char>();
oursC.ref.size = ours.length; oursC.ref.size = ours.length;
theirsC.ref.ptr = theirs.toNativeUtf8().cast<Int8>(); theirsC.ref.ptr = theirs.toNativeUtf8().cast<Char>();
theirsC.ref.size = theirs.length; theirsC.ref.size = theirs.length;
final opts = calloc<git_merge_file_options>(); final opts = calloc<git_merge_file_options>();
@ -195,13 +195,13 @@ String mergeFile({
opts.ref.favor = favor; opts.ref.favor = favor;
opts.ref.flags = flags; opts.ref.flags = flags;
if (ancestorLabel.isNotEmpty) { if (ancestorLabel.isNotEmpty) {
opts.ref.ancestor_label = ancestorLabel.toNativeUtf8().cast<Int8>(); opts.ref.ancestor_label = ancestorLabel.toNativeUtf8().cast<Char>();
} }
if (oursLabel.isNotEmpty) { if (oursLabel.isNotEmpty) {
opts.ref.our_label = oursLabel.toNativeUtf8().cast<Int8>(); opts.ref.our_label = oursLabel.toNativeUtf8().cast<Char>();
} }
if (theirsLabel.isNotEmpty) { if (theirsLabel.isNotEmpty) {
opts.ref.their_label = theirsLabel.toNativeUtf8().cast<Int8>(); opts.ref.their_label = theirsLabel.toNativeUtf8().cast<Char>();
} }
libgit2.git_merge_file(out, ancestorC, oursC, theirsC, opts); libgit2.git_merge_file(out, ancestorC, oursC, theirsC, opts);

View file

@ -10,7 +10,7 @@ import 'package:libgit2dart/src/util.dart';
/// ///
/// Throws a [LibGit2Error] if error occured. /// Throws a [LibGit2Error] if error occured.
List<Map<String, Pointer>> list(Pointer<git_repository> repo) { List<Map<String, Pointer>> list(Pointer<git_repository> repo) {
final notesRef = 'refs/notes/commits'.toNativeUtf8().cast<Int8>(); final notesRef = 'refs/notes/commits'.toNativeUtf8().cast<Char>();
final iterator = calloc<Pointer<git_iterator>>(); final iterator = calloc<Pointer<git_iterator>>();
final iteratorError = libgit2.git_note_iterator_new(iterator, repo, notesRef); final iteratorError = libgit2.git_note_iterator_new(iterator, repo, notesRef);
@ -57,7 +57,7 @@ Pointer<git_note> lookup({
String notesRef = 'refs/notes/commits', String notesRef = 'refs/notes/commits',
}) { }) {
final out = calloc<Pointer<git_note>>(); final out = calloc<Pointer<git_note>>();
final notesRefC = notesRef.toNativeUtf8().cast<Int8>(); final notesRefC = notesRef.toNativeUtf8().cast<Char>();
final error = libgit2.git_note_read(out, repoPointer, notesRefC, oidPointer); final error = libgit2.git_note_read(out, repoPointer, notesRefC, oidPointer);
final result = out.value; final result = out.value;
@ -85,8 +85,8 @@ Pointer<git_oid> create({
bool force = false, bool force = false,
}) { }) {
final out = calloc<git_oid>(); final out = calloc<git_oid>();
final notesRefC = notesRef.toNativeUtf8().cast<Int8>(); final notesRefC = notesRef.toNativeUtf8().cast<Char>();
final noteC = note.toNativeUtf8().cast<Int8>(); final noteC = note.toNativeUtf8().cast<Char>();
final forceC = force ? 1 : 0; final forceC = force ? 1 : 0;
final error = libgit2.git_note_create( final error = libgit2.git_note_create(
out, out,
@ -120,7 +120,7 @@ void delete({
required Pointer<git_signature> committerPointer, required Pointer<git_signature> committerPointer,
required Pointer<git_oid> oidPointer, required Pointer<git_oid> oidPointer,
}) { }) {
final notesRefC = notesRef.toNativeUtf8().cast<Int8>(); final notesRefC = notesRef.toNativeUtf8().cast<Char>();
final error = libgit2.git_note_remove( final error = libgit2.git_note_remove(
repoPointer, repoPointer,

View file

@ -36,7 +36,7 @@ void addDiskAlternate({
required Pointer<git_odb> odbPointer, required Pointer<git_odb> odbPointer,
required String path, required String path,
}) { }) {
final pathC = path.toNativeUtf8().cast<Int8>(); final pathC = path.toNativeUtf8().cast<Char>();
libgit2.git_odb_add_disk_alternate(odbPointer, pathC); libgit2.git_odb_add_disk_alternate(odbPointer, pathC);
calloc.free(pathC); calloc.free(pathC);
} }
@ -94,7 +94,7 @@ int _forEachCb(
List<Oid> objects(Pointer<git_odb> odb) { List<Oid> objects(Pointer<git_odb> odb) {
const except = -1; const except = -1;
final cb = final cb =
Pointer.fromFunction<Int32 Function(Pointer<git_oid>, Pointer<Void>)>( Pointer.fromFunction<Int Function(Pointer<git_oid>, Pointer<Void>)>(
_forEachCb, _forEachCb,
except, except,
); );
@ -184,7 +184,7 @@ Pointer<git_oid> write({
throw LibGit2Error(libgit2.git_error_last()); throw LibGit2Error(libgit2.git_error_last());
} }
final bufferC = data.toNativeUtf8().cast<Int8>(); final bufferC = data.toNativeUtf8().cast<Char>();
libgit2.git_odb_stream_write(stream.value, bufferC, data.length); libgit2.git_odb_stream_write(stream.value, bufferC, data.length);
final out = calloc<git_oid>(); final out = calloc<git_oid>();

View file

@ -7,7 +7,7 @@ import 'package:libgit2dart/src/util.dart';
/// Parse N characters of a hex formatted object id into a git_oid. /// Parse N characters of a hex formatted object id into a git_oid.
Pointer<git_oid> fromStrN(String hex) { Pointer<git_oid> fromStrN(String hex) {
final out = calloc<git_oid>(); final out = calloc<git_oid>();
final hexC = hex.toNativeUtf8().cast<Int8>(); final hexC = hex.toNativeUtf8().cast<Char>();
libgit2.git_oid_fromstrn(out, hexC, hex.length); libgit2.git_oid_fromstrn(out, hexC, hex.length);
calloc.free(hexC); calloc.free(hexC);
@ -18,7 +18,7 @@ Pointer<git_oid> fromStrN(String hex) {
/// Parse a hex formatted object id into a git_oid. /// Parse a hex formatted object id into a git_oid.
Pointer<git_oid> fromSHA(String hex) { Pointer<git_oid> fromSHA(String hex) {
final out = calloc<git_oid>(); final out = calloc<git_oid>();
final hexC = hex.toNativeUtf8().cast<Int8>(); final hexC = hex.toNativeUtf8().cast<Char>();
libgit2.git_oid_fromstr(out, hexC); libgit2.git_oid_fromstr(out, hexC);
calloc.free(hexC); calloc.free(hexC);
@ -27,9 +27,9 @@ Pointer<git_oid> fromSHA(String hex) {
} }
/// Copy an already raw oid into a git_oid structure. /// Copy an already raw oid into a git_oid structure.
Pointer<git_oid> fromRaw(Array<Uint8> raw) { Pointer<git_oid> fromRaw(Array<UnsignedChar> raw) {
final out = calloc<git_oid>(); final out = calloc<git_oid>();
final rawC = calloc<Uint8>(20); final rawC = calloc<UnsignedChar>(20);
for (var i = 0; i < 20; i++) { for (var i = 0; i < 20; i++) {
rawC[i] = raw[i]; rawC[i] = raw[i];
@ -44,7 +44,7 @@ Pointer<git_oid> fromRaw(Array<Uint8> raw) {
/// Format a git_oid into a hex string. /// Format a git_oid into a hex string.
String toSHA(Pointer<git_oid> id) { String toSHA(Pointer<git_oid> id) {
final out = calloc<Int8>(40); final out = calloc<Char>(40);
libgit2.git_oid_fmt(out, id); libgit2.git_oid_fmt(out, id);
final result = out.cast<Utf8>().toDartString(length: 40); final result = out.cast<Utf8>().toDartString(length: 40);

View file

@ -121,7 +121,7 @@ void write({
required Pointer<git_packbuilder> packbuilderPointer, required Pointer<git_packbuilder> packbuilderPointer,
String? path, String? path,
}) { }) {
final pathC = path?.toNativeUtf8().cast<Int8>() ?? nullptr; final pathC = path?.toNativeUtf8().cast<Char>() ?? nullptr;
final error = libgit2.git_packbuilder_write( final error = libgit2.git_packbuilder_write(
packbuilderPointer, packbuilderPointer,
pathC, pathC,

View file

@ -17,11 +17,11 @@ Pointer<git_patch> fromBuffers({
required int interhunkLines, required int interhunkLines,
}) { }) {
final out = calloc<Pointer<git_patch>>(); final out = calloc<Pointer<git_patch>>();
final oldBufferC = oldBuffer?.toNativeUtf8().cast<Int8>() ?? nullptr; final oldBufferC = oldBuffer?.toNativeUtf8().cast<Char>() ?? nullptr;
final oldAsPathC = oldAsPath?.toNativeUtf8().cast<Int8>() ?? nullptr; final oldAsPathC = oldAsPath?.toNativeUtf8().cast<Char>() ?? nullptr;
final oldLen = oldBuffer?.length ?? 0; final oldLen = oldBuffer?.length ?? 0;
final newBufferC = newBuffer?.toNativeUtf8().cast<Int8>() ?? nullptr; final newBufferC = newBuffer?.toNativeUtf8().cast<Char>() ?? nullptr;
final newAsPathC = oldAsPath?.toNativeUtf8().cast<Int8>() ?? nullptr; final newAsPathC = oldAsPath?.toNativeUtf8().cast<Char>() ?? nullptr;
final newLen = newBuffer?.length ?? 0; final newLen = newBuffer?.length ?? 0;
final opts = _diffOptionsInit( final opts = _diffOptionsInit(
flags: flags, flags: flags,
@ -65,8 +65,8 @@ Pointer<git_patch> fromBlobs({
required int interhunkLines, required int interhunkLines,
}) { }) {
final out = calloc<Pointer<git_patch>>(); final out = calloc<Pointer<git_patch>>();
final oldAsPathC = oldAsPath?.toNativeUtf8().cast<Int8>() ?? nullptr; final oldAsPathC = oldAsPath?.toNativeUtf8().cast<Char>() ?? nullptr;
final newAsPathC = oldAsPath?.toNativeUtf8().cast<Int8>() ?? nullptr; final newAsPathC = oldAsPath?.toNativeUtf8().cast<Char>() ?? nullptr;
final opts = _diffOptionsInit( final opts = _diffOptionsInit(
flags: flags, flags: flags,
contextLines: contextLines, contextLines: contextLines,
@ -104,9 +104,9 @@ Pointer<git_patch> fromBlobAndBuffer({
required int interhunkLines, required int interhunkLines,
}) { }) {
final out = calloc<Pointer<git_patch>>(); final out = calloc<Pointer<git_patch>>();
final oldAsPathC = oldAsPath?.toNativeUtf8().cast<Int8>() ?? nullptr; final oldAsPathC = oldAsPath?.toNativeUtf8().cast<Char>() ?? nullptr;
final bufferC = buffer?.toNativeUtf8().cast<Int8>() ?? nullptr; final bufferC = buffer?.toNativeUtf8().cast<Char>() ?? nullptr;
final bufferAsPathC = oldAsPath?.toNativeUtf8().cast<Int8>() ?? nullptr; final bufferAsPathC = oldAsPath?.toNativeUtf8().cast<Char>() ?? nullptr;
final bufferLen = buffer?.length ?? 0; final bufferLen = buffer?.length ?? 0;
final opts = _diffOptionsInit( final opts = _diffOptionsInit(
flags: flags, flags: flags,
@ -189,9 +189,9 @@ Map<String, Object> hunk({
/// Get line counts of each type in a patch. /// Get line counts of each type in a patch.
Map<String, int> lineStats(Pointer<git_patch> patch) { Map<String, int> lineStats(Pointer<git_patch> patch) {
final context = calloc<Uint64>(); final context = calloc<Size>();
final insertions = calloc<Uint64>(); final insertions = calloc<Size>();
final deletions = calloc<Uint64>(); final deletions = calloc<Size>();
libgit2.git_patch_line_stats( libgit2.git_patch_line_stats(
context, context,
insertions, insertions,

View file

@ -128,7 +128,7 @@ void commit({
required String? message, required String? message,
}) { }) {
final out = calloc<git_oid>(); final out = calloc<git_oid>();
final messageC = message?.toNativeUtf8().cast<Int8>() ?? nullptr; final messageC = message?.toNativeUtf8().cast<Char>() ?? nullptr;
final error = libgit2.git_rebase_commit( final error = libgit2.git_rebase_commit(
out, out,

View file

@ -55,7 +55,7 @@ Pointer<git_reference> lookup({
required String name, required String name,
}) { }) {
final out = calloc<Pointer<git_reference>>(); final out = calloc<Pointer<git_reference>>();
final nameC = name.toNativeUtf8().cast<Int8>(); final nameC = name.toNativeUtf8().cast<Char>();
final error = libgit2.git_reference_lookup(out, repoPointer, nameC); final error = libgit2.git_reference_lookup(out, repoPointer, nameC);
final result = out.value; final result = out.value;
@ -104,9 +104,9 @@ Pointer<git_reference> rename({
String? logMessage, String? logMessage,
}) { }) {
final out = calloc<Pointer<git_reference>>(); final out = calloc<Pointer<git_reference>>();
final newNameC = newName.toNativeUtf8().cast<Int8>(); final newNameC = newName.toNativeUtf8().cast<Char>();
final forceC = force == true ? 1 : 0; final forceC = force == true ? 1 : 0;
final logMessageC = logMessage?.toNativeUtf8().cast<Int8>() ?? nullptr; final logMessageC = logMessage?.toNativeUtf8().cast<Char>() ?? nullptr;
final error = libgit2.git_reference_rename( final error = libgit2.git_reference_rename(
out, out,
refPointer, refPointer,
@ -156,7 +156,7 @@ bool hasLog({
required Pointer<git_repository> repoPointer, required Pointer<git_repository> repoPointer,
required String name, required String name,
}) { }) {
final nameC = name.toNativeUtf8().cast<Int8>(); final nameC = name.toNativeUtf8().cast<Char>();
final result = libgit2.git_reference_has_log(repoPointer, nameC); final result = libgit2.git_reference_has_log(repoPointer, nameC);
calloc.free(nameC); calloc.free(nameC);
@ -173,7 +173,7 @@ void ensureLog({
required Pointer<git_repository> repoPointer, required Pointer<git_repository> repoPointer,
required String refName, required String refName,
}) { }) {
final refNameC = refName.toNativeUtf8().cast<Int8>(); final refNameC = refName.toNativeUtf8().cast<Char>();
final error = libgit2.git_reference_ensure_log(repoPointer, refNameC); final error = libgit2.git_reference_ensure_log(repoPointer, refNameC);
calloc.free(refNameC); calloc.free(refNameC);
@ -237,9 +237,9 @@ Pointer<git_reference> createDirect({
String? logMessage, String? logMessage,
}) { }) {
final out = calloc<Pointer<git_reference>>(); final out = calloc<Pointer<git_reference>>();
final nameC = name.toNativeUtf8().cast<Int8>(); final nameC = name.toNativeUtf8().cast<Char>();
final forceC = force == true ? 1 : 0; final forceC = force == true ? 1 : 0;
final logMessageC = logMessage?.toNativeUtf8().cast<Int8>() ?? nullptr; final logMessageC = logMessage?.toNativeUtf8().cast<Char>() ?? nullptr;
final error = libgit2.git_reference_create( final error = libgit2.git_reference_create(
out, out,
repoPointer, repoPointer,
@ -295,10 +295,10 @@ Pointer<git_reference> createSymbolic({
String? logMessage, String? logMessage,
}) { }) {
final out = calloc<Pointer<git_reference>>(); final out = calloc<Pointer<git_reference>>();
final nameC = name.toNativeUtf8().cast<Int8>(); final nameC = name.toNativeUtf8().cast<Char>();
final targetC = target.toNativeUtf8().cast<Int8>(); final targetC = target.toNativeUtf8().cast<Char>();
final forceC = force == true ? 1 : 0; final forceC = force == true ? 1 : 0;
final logMessageC = logMessage?.toNativeUtf8().cast<Int8>() ?? nullptr; final logMessageC = logMessage?.toNativeUtf8().cast<Char>() ?? nullptr;
final error = libgit2.git_reference_symbolic_create( final error = libgit2.git_reference_symbolic_create(
out, out,
repoPointer, repoPointer,
@ -348,7 +348,7 @@ Pointer<git_reference> setTarget({
String? logMessage, String? logMessage,
}) { }) {
final out = calloc<Pointer<git_reference>>(); final out = calloc<Pointer<git_reference>>();
final logMessageC = logMessage?.toNativeUtf8().cast<Int8>() ?? nullptr; final logMessageC = logMessage?.toNativeUtf8().cast<Char>() ?? nullptr;
final error = libgit2.git_reference_set_target( final error = libgit2.git_reference_set_target(
out, out,
refPointer, refPointer,
@ -388,8 +388,8 @@ Pointer<git_reference> setTargetSymbolic({
String? logMessage, String? logMessage,
}) { }) {
final out = calloc<Pointer<git_reference>>(); final out = calloc<Pointer<git_reference>>();
final targetC = target.toNativeUtf8().cast<Int8>(); final targetC = target.toNativeUtf8().cast<Char>();
final logMessageC = logMessage?.toNativeUtf8().cast<Int8>() ?? nullptr; final logMessageC = logMessage?.toNativeUtf8().cast<Char>() ?? nullptr;
final error = libgit2.git_reference_symbolic_set_target( final error = libgit2.git_reference_symbolic_set_target(
out, out,
refPointer, refPointer,

View file

@ -15,7 +15,7 @@ Pointer<git_reflog> read({
required String name, required String name,
}) { }) {
final out = calloc<Pointer<git_reflog>>(); final out = calloc<Pointer<git_reflog>>();
final nameC = name.toNativeUtf8().cast<Int8>(); final nameC = name.toNativeUtf8().cast<Char>();
libgit2.git_reflog_read(out, repoPointer, nameC); libgit2.git_reflog_read(out, repoPointer, nameC);
final result = out.value; final result = out.value;
@ -43,7 +43,7 @@ void delete({
required Pointer<git_repository> repoPointer, required Pointer<git_repository> repoPointer,
required String name, required String name,
}) { }) {
final nameC = name.toNativeUtf8().cast<Int8>(); final nameC = name.toNativeUtf8().cast<Char>();
libgit2.git_reflog_delete(repoPointer, nameC); libgit2.git_reflog_delete(repoPointer, nameC);
calloc.free(nameC); calloc.free(nameC);
} }
@ -60,8 +60,8 @@ void rename({
required String oldName, required String oldName,
required String newName, required String newName,
}) { }) {
final oldNameC = oldName.toNativeUtf8().cast<Int8>(); final oldNameC = oldName.toNativeUtf8().cast<Char>();
final newNameC = newName.toNativeUtf8().cast<Int8>(); final newNameC = newName.toNativeUtf8().cast<Char>();
final error = libgit2.git_reflog_rename(repoPointer, oldNameC, newNameC); final error = libgit2.git_reflog_rename(repoPointer, oldNameC, newNameC);
calloc.free(oldNameC); calloc.free(oldNameC);
@ -82,7 +82,7 @@ void add({
required String message, required String message,
}) { }) {
final messageC = final messageC =
message.isEmpty ? nullptr : message.toNativeUtf8().cast<Int8>(); message.isEmpty ? nullptr : message.toNativeUtf8().cast<Char>();
final error = libgit2.git_reflog_append( final error = libgit2.git_reflog_append(
reflogPointer, reflogPointer,

View file

@ -34,7 +34,7 @@ bool matchesSource({
required Pointer<git_refspec> refspecPointer, required Pointer<git_refspec> refspecPointer,
required String refname, required String refname,
}) { }) {
final refnameC = refname.toNativeUtf8().cast<Int8>(); final refnameC = refname.toNativeUtf8().cast<Char>();
final result = libgit2.git_refspec_src_matches(refspecPointer, refnameC); final result = libgit2.git_refspec_src_matches(refspecPointer, refnameC);
calloc.free(refnameC); calloc.free(refnameC);
@ -47,7 +47,7 @@ bool matchesDestination({
required Pointer<git_refspec> refspecPointer, required Pointer<git_refspec> refspecPointer,
required String refname, required String refname,
}) { }) {
final refnameC = refname.toNativeUtf8().cast<Int8>(); final refnameC = refname.toNativeUtf8().cast<Char>();
final result = libgit2.git_refspec_dst_matches(refspecPointer, refnameC); final result = libgit2.git_refspec_dst_matches(refspecPointer, refnameC);
calloc.free(refnameC); calloc.free(refnameC);
@ -63,7 +63,7 @@ String transform({
required String name, required String name,
}) { }) {
final out = calloc<git_buf>(); final out = calloc<git_buf>();
final nameC = name.toNativeUtf8().cast<Int8>(); final nameC = name.toNativeUtf8().cast<Char>();
final error = libgit2.git_refspec_transform(out, refspecPointer, nameC); final error = libgit2.git_refspec_transform(out, refspecPointer, nameC);
final result = out.ref.ptr.cast<Utf8>().toDartString(length: out.ref.size); final result = out.ref.ptr.cast<Utf8>().toDartString(length: out.ref.size);
@ -88,7 +88,7 @@ String rTransform({
required String name, required String name,
}) { }) {
final out = calloc<git_buf>(); final out = calloc<git_buf>();
final nameC = name.toNativeUtf8().cast<Int8>(); final nameC = name.toNativeUtf8().cast<Char>();
final error = libgit2.git_refspec_rtransform(out, refspecPointer, nameC); final error = libgit2.git_refspec_rtransform(out, refspecPointer, nameC);
final result = out.ref.ptr.cast<Utf8>().toDartString(length: out.ref.size); final result = out.ref.ptr.cast<Utf8>().toDartString(length: out.ref.size);

View file

@ -34,7 +34,7 @@ Pointer<git_remote> lookup({
required String name, required String name,
}) { }) {
final out = calloc<Pointer<git_remote>>(); final out = calloc<Pointer<git_remote>>();
final nameC = name.toNativeUtf8().cast<Int8>(); final nameC = name.toNativeUtf8().cast<Char>();
final error = libgit2.git_remote_lookup(out, repoPointer, nameC); final error = libgit2.git_remote_lookup(out, repoPointer, nameC);
final result = out.value; final result = out.value;
@ -59,8 +59,8 @@ Pointer<git_remote> create({
required String url, required String url,
}) { }) {
final out = calloc<Pointer<git_remote>>(); final out = calloc<Pointer<git_remote>>();
final nameC = name.toNativeUtf8().cast<Int8>(); final nameC = name.toNativeUtf8().cast<Char>();
final urlC = url.toNativeUtf8().cast<Int8>(); final urlC = url.toNativeUtf8().cast<Char>();
final error = libgit2.git_remote_create(out, repoPointer, nameC, urlC); final error = libgit2.git_remote_create(out, repoPointer, nameC, urlC);
final result = out.value; final result = out.value;
@ -87,9 +87,9 @@ Pointer<git_remote> createWithFetchSpec({
required String fetch, required String fetch,
}) { }) {
final out = calloc<Pointer<git_remote>>(); final out = calloc<Pointer<git_remote>>();
final nameC = name.toNativeUtf8().cast<Int8>(); final nameC = name.toNativeUtf8().cast<Char>();
final urlC = url.toNativeUtf8().cast<Int8>(); final urlC = url.toNativeUtf8().cast<Char>();
final fetchC = fetch.toNativeUtf8().cast<Int8>(); final fetchC = fetch.toNativeUtf8().cast<Char>();
final error = libgit2.git_remote_create_with_fetchspec( final error = libgit2.git_remote_create_with_fetchspec(
out, out,
repoPointer, repoPointer,
@ -122,7 +122,7 @@ void delete({
required Pointer<git_repository> repoPointer, required Pointer<git_repository> repoPointer,
required String name, required String name,
}) { }) {
final nameC = name.toNativeUtf8().cast<Int8>(); final nameC = name.toNativeUtf8().cast<Char>();
final error = libgit2.git_remote_delete(repoPointer, nameC); final error = libgit2.git_remote_delete(repoPointer, nameC);
calloc.free(nameC); calloc.free(nameC);
@ -151,8 +151,8 @@ List<String> rename({
required String newName, required String newName,
}) { }) {
final out = calloc<git_strarray>(); final out = calloc<git_strarray>();
final nameC = name.toNativeUtf8().cast<Int8>(); final nameC = name.toNativeUtf8().cast<Char>();
final newNameC = newName.toNativeUtf8().cast<Int8>(); final newNameC = newName.toNativeUtf8().cast<Char>();
final error = libgit2.git_remote_rename(out, repoPointer, nameC, newNameC); final error = libgit2.git_remote_rename(out, repoPointer, nameC, newNameC);
calloc.free(nameC); calloc.free(nameC);
@ -182,8 +182,8 @@ void setUrl({
required String remote, required String remote,
required String url, required String url,
}) { }) {
final remoteC = remote.toNativeUtf8().cast<Int8>(); final remoteC = remote.toNativeUtf8().cast<Char>();
final urlC = url.toNativeUtf8().cast<Int8>(); final urlC = url.toNativeUtf8().cast<Char>();
final error = libgit2.git_remote_set_url(repoPointer, remoteC, urlC); final error = libgit2.git_remote_set_url(repoPointer, remoteC, urlC);
calloc.free(remoteC); calloc.free(remoteC);
@ -205,8 +205,8 @@ void setPushUrl({
required String remote, required String remote,
required String url, required String url,
}) { }) {
final remoteC = remote.toNativeUtf8().cast<Int8>(); final remoteC = remote.toNativeUtf8().cast<Char>();
final urlC = url.toNativeUtf8().cast<Int8>(); final urlC = url.toNativeUtf8().cast<Char>();
final error = libgit2.git_remote_set_pushurl(repoPointer, remoteC, urlC); final error = libgit2.git_remote_set_pushurl(repoPointer, remoteC, urlC);
calloc.free(remoteC); calloc.free(remoteC);
@ -285,8 +285,8 @@ void addFetch({
required String remote, required String remote,
required String refspec, required String refspec,
}) { }) {
final remoteC = remote.toNativeUtf8().cast<Int8>(); final remoteC = remote.toNativeUtf8().cast<Char>();
final refspecC = refspec.toNativeUtf8().cast<Int8>(); final refspecC = refspec.toNativeUtf8().cast<Char>();
final error = libgit2.git_remote_add_fetch(repoPointer, remoteC, refspecC); final error = libgit2.git_remote_add_fetch(repoPointer, remoteC, refspecC);
calloc.free(remoteC); calloc.free(remoteC);
@ -308,8 +308,8 @@ void addPush({
required String remote, required String remote,
required String refspec, required String refspec,
}) { }) {
final remoteC = remote.toNativeUtf8().cast<Int8>(); final remoteC = remote.toNativeUtf8().cast<Char>();
final refspecC = refspec.toNativeUtf8().cast<Int8>(); final refspecC = refspec.toNativeUtf8().cast<Char>();
final error = libgit2.git_remote_add_push(repoPointer, remoteC, refspecC); final error = libgit2.git_remote_add_push(repoPointer, remoteC, refspecC);
calloc.free(remoteC); calloc.free(remoteC);
@ -375,7 +375,7 @@ void connect({
/// Throws a [LibGit2Error] if error occured. /// Throws a [LibGit2Error] if error occured.
List<Map<String, Object?>> lsRemotes(Pointer<git_remote> remote) { List<Map<String, Object?>> lsRemotes(Pointer<git_remote> remote) {
final out = calloc<Pointer<Pointer<git_remote_head>>>(); final out = calloc<Pointer<Pointer<git_remote_head>>>();
final size = calloc<Uint64>(); final size = calloc<Size>();
libgit2.git_remote_ls(out, size, remote); libgit2.git_remote_ls(out, size, remote);
final result = <Map<String, Object?>>[]; final result = <Map<String, Object?>>[];
@ -420,8 +420,8 @@ void fetch({
}) { }) {
final refspecsC = calloc<git_strarray>(); final refspecsC = calloc<git_strarray>();
final refspecsPointers = final refspecsPointers =
refspecs.map((e) => e.toNativeUtf8().cast<Int8>()).toList(); refspecs.map((e) => e.toNativeUtf8().cast<Char>()).toList();
final strArray = calloc<Pointer<Int8>>(refspecs.length); final strArray = calloc<Pointer<Char>>(refspecs.length);
for (var i = 0; i < refspecs.length; i++) { for (var i = 0; i < refspecs.length; i++) {
strArray[i] = refspecsPointers[i]; strArray[i] = refspecsPointers[i];
@ -429,7 +429,7 @@ void fetch({
refspecsC.ref.count = refspecs.length; refspecsC.ref.count = refspecs.length;
refspecsC.ref.strings = strArray; refspecsC.ref.strings = strArray;
final reflogMessageC = reflogMessage?.toNativeUtf8().cast<Int8>() ?? nullptr; final reflogMessageC = reflogMessage?.toNativeUtf8().cast<Char>() ?? nullptr;
final proxyOptions = _proxyOptionsInit(proxyOption); final proxyOptions = _proxyOptionsInit(proxyOption);
@ -476,8 +476,8 @@ void push({
}) { }) {
final refspecsC = calloc<git_strarray>(); final refspecsC = calloc<git_strarray>();
final refspecsPointers = final refspecsPointers =
refspecs.map((e) => e.toNativeUtf8().cast<Int8>()).toList(); refspecs.map((e) => e.toNativeUtf8().cast<Char>()).toList();
final strArray = calloc<Pointer<Int8>>(refspecs.length); final strArray = calloc<Pointer<Char>>(refspecs.length);
for (var i = 0; i < refspecs.length; i++) { for (var i = 0; i < refspecs.length; i++) {
strArray[i] = refspecsPointers[i]; strArray[i] = refspecsPointers[i];
@ -566,7 +566,7 @@ Pointer<git_proxy_options> _proxyOptionsInit(String? proxyOption) {
proxyOptions.ref.type = git_proxy_t.GIT_PROXY_AUTO; proxyOptions.ref.type = git_proxy_t.GIT_PROXY_AUTO;
} else { } else {
proxyOptions.ref.type = git_proxy_t.GIT_PROXY_SPECIFIED; proxyOptions.ref.type = git_proxy_t.GIT_PROXY_SPECIFIED;
proxyOptions.ref.url = proxyOption.toNativeUtf8().cast<Int8>(); proxyOptions.ref.url = proxyOption.toNativeUtf8().cast<Char>();
} }
return proxyOptions; return proxyOptions;

View file

@ -29,7 +29,7 @@ class RemoteCallbacks {
/// Callback for messages received by the transport. /// Callback for messages received by the transport.
static int sidebandProgressCb( static int sidebandProgressCb(
Pointer<Int8> progressOutput, Pointer<Char> progressOutput,
int length, int length,
Pointer<Void> payload, Pointer<Void> payload,
) { ) {
@ -42,7 +42,7 @@ class RemoteCallbacks {
/// A callback that will be called for every reference. /// A callback that will be called for every reference.
static int updateTipsCb( static int updateTipsCb(
Pointer<Int8> refname, Pointer<Char> refname,
Pointer<git_oid> oldOid, Pointer<git_oid> oldOid,
Pointer<git_oid> newOid, Pointer<git_oid> newOid,
Pointer<Void> payload, Pointer<Void> payload,
@ -58,8 +58,8 @@ class RemoteCallbacks {
/// not empty, the update was rejected by the remote server /// not empty, the update was rejected by the remote server
/// and [message] contains the reason given. /// and [message] contains the reason given.
static int pushUpdateReferenceCb( static int pushUpdateReferenceCb(
Pointer<Int8> refname, Pointer<Char> refname,
Pointer<Int8> message, Pointer<Char> message,
Pointer<Void> payload, Pointer<Void> payload,
) { ) {
final messageResult = final messageResult =
@ -77,8 +77,8 @@ class RemoteCallbacks {
static int remoteCb( static int remoteCb(
Pointer<Pointer<git_remote>> remote, Pointer<Pointer<git_remote>> remote,
Pointer<git_repository> repo, Pointer<git_repository> repo,
Pointer<Int8> name, Pointer<Char> name,
Pointer<Int8> url, Pointer<Char> url,
Pointer<Void> payload, Pointer<Void> payload,
) { ) {
late final Pointer<git_remote> remotePointer; late final Pointer<git_remote> remotePointer;
@ -110,7 +110,7 @@ class RemoteCallbacks {
/// A callback used to create the new repository into which to clone. /// A callback used to create the new repository into which to clone.
static int repositoryCb( static int repositoryCb(
Pointer<Pointer<git_repository>> repo, Pointer<Pointer<git_repository>> repo,
Pointer<Int8> path, Pointer<Char> path,
int bare, int bare,
Pointer<Void> payload, Pointer<Void> payload,
) { ) {
@ -147,15 +147,15 @@ class RemoteCallbacks {
/// requires authentication in order to connect to it. /// requires authentication in order to connect to it.
static int credentialsCb( static int credentialsCb(
Pointer<Pointer<git_credential>> credPointer, Pointer<Pointer<git_credential>> credPointer,
Pointer<Int8> url, Pointer<Char> url,
Pointer<Int8> username, Pointer<Char> username,
int allowedTypes, int allowedTypes,
Pointer<Void> payload, Pointer<Void> payload,
) { ) {
if (payload.cast<Int8>().value == 2) { if (payload.cast<Char>().value == 2) {
libgit2.git_error_set_str( libgit2.git_error_set_str(
git_error_t.GIT_ERROR_INVALID, git_error_t.GIT_ERROR_INVALID,
'Incorrect credentials.'.toNativeUtf8().cast<Int8>(), 'Incorrect credentials.'.toNativeUtf8().cast<Char>(),
); );
throw LibGit2Error(libgit2.git_error_last()); throw LibGit2Error(libgit2.git_error_last());
} }
@ -165,7 +165,7 @@ class RemoteCallbacks {
if (allowedTypes & credentialType.value != credentialType.value) { if (allowedTypes & credentialType.value != credentialType.value) {
libgit2.git_error_set_str( libgit2.git_error_set_str(
git_error_t.GIT_ERROR_INVALID, git_error_t.GIT_ERROR_INVALID,
'Invalid credential type $credentialType'.toNativeUtf8().cast<Int8>(), 'Invalid credential type $credentialType'.toNativeUtf8().cast<Char>(),
); );
throw LibGit2Error(libgit2.git_error_last()); throw LibGit2Error(libgit2.git_error_last());
} }

View file

@ -17,7 +17,7 @@ import 'package:libgit2dart/src/util.dart';
/// Throws a [LibGit2Error] if error occured. /// Throws a [LibGit2Error] if error occured.
Pointer<git_repository> open(String path) { Pointer<git_repository> open(String path) {
final out = calloc<Pointer<git_repository>>(); final out = calloc<Pointer<git_repository>>();
final pathC = path.toNativeUtf8().cast<Int8>(); final pathC = path.toNativeUtf8().cast<Char>();
final error = libgit2.git_repository_open(out, pathC); final error = libgit2.git_repository_open(out, pathC);
final result = out.value; final result = out.value;
@ -44,8 +44,8 @@ String discover({
String? ceilingDirs, String? ceilingDirs,
}) { }) {
final out = calloc<git_buf>(); final out = calloc<git_buf>();
final startPathC = startPath.toNativeUtf8().cast<Int8>(); final startPathC = startPath.toNativeUtf8().cast<Char>();
final ceilingDirsC = ceilingDirs?.toNativeUtf8().cast<Int8>() ?? nullptr; final ceilingDirsC = ceilingDirs?.toNativeUtf8().cast<Char>() ?? nullptr;
libgit2.git_repository_discover(out, startPathC, 0, ceilingDirsC); libgit2.git_repository_discover(out, startPathC, 0, ceilingDirsC);
@ -75,12 +75,12 @@ Pointer<git_repository> init({
String? originUrl, String? originUrl,
}) { }) {
final out = calloc<Pointer<git_repository>>(); final out = calloc<Pointer<git_repository>>();
final pathC = path.toNativeUtf8().cast<Int8>(); final pathC = path.toNativeUtf8().cast<Char>();
final workdirPathC = workdirPath?.toNativeUtf8().cast<Int8>() ?? nullptr; final workdirPathC = workdirPath?.toNativeUtf8().cast<Char>() ?? nullptr;
final descriptionC = description?.toNativeUtf8().cast<Int8>() ?? nullptr; final descriptionC = description?.toNativeUtf8().cast<Char>() ?? nullptr;
final templatePathC = templatePath?.toNativeUtf8().cast<Int8>() ?? nullptr; final templatePathC = templatePath?.toNativeUtf8().cast<Char>() ?? nullptr;
final initialHeadC = initialHead?.toNativeUtf8().cast<Int8>() ?? nullptr; final initialHeadC = initialHead?.toNativeUtf8().cast<Char>() ?? nullptr;
final originUrlC = originUrl?.toNativeUtf8().cast<Int8>() ?? nullptr; final originUrlC = originUrl?.toNativeUtf8().cast<Char>() ?? nullptr;
final opts = calloc<git_repository_init_options>(); final opts = calloc<git_repository_init_options>();
libgit2.git_repository_init_options_init( libgit2.git_repository_init_options_init(
opts, opts,
@ -130,10 +130,10 @@ Pointer<git_repository> clone({
required Callbacks callbacks, required Callbacks callbacks,
}) { }) {
final out = calloc<Pointer<git_repository>>(); final out = calloc<Pointer<git_repository>>();
final urlC = url.toNativeUtf8().cast<Int8>(); final urlC = url.toNativeUtf8().cast<Char>();
final localPathC = localPath.toNativeUtf8().cast<Int8>(); final localPathC = localPath.toNativeUtf8().cast<Char>();
final checkoutBranchC = final checkoutBranchC =
checkoutBranch?.toNativeUtf8().cast<Int8>() ?? nullptr; checkoutBranch?.toNativeUtf8().cast<Char>() ?? nullptr;
final cloneOptions = calloc<git_clone_options>(); final cloneOptions = calloc<git_clone_options>();
libgit2.git_clone_options_init(cloneOptions, GIT_CLONE_OPTIONS_VERSION); libgit2.git_clone_options_init(cloneOptions, GIT_CLONE_OPTIONS_VERSION);
@ -224,7 +224,7 @@ void setNamespace({
required Pointer<git_repository> repoPointer, required Pointer<git_repository> repoPointer,
String? namespace, String? namespace,
}) { }) {
final namespaceC = namespace?.toNativeUtf8().cast<Int8>() ?? nullptr; final namespaceC = namespace?.toNativeUtf8().cast<Char>() ?? nullptr;
libgit2.git_repository_set_namespace(repoPointer, namespaceC); libgit2.git_repository_set_namespace(repoPointer, namespaceC);
calloc.free(namespaceC); calloc.free(namespaceC);
} }
@ -311,8 +311,8 @@ void setIdentity({
String? name, String? name,
String? email, String? email,
}) { }) {
final nameC = name?.toNativeUtf8().cast<Int8>() ?? nullptr; final nameC = name?.toNativeUtf8().cast<Char>() ?? nullptr;
final emailC = email?.toNativeUtf8().cast<Int8>() ?? nullptr; final emailC = email?.toNativeUtf8().cast<Char>() ?? nullptr;
libgit2.git_repository_set_ident(repoPointer, nameC, emailC); libgit2.git_repository_set_ident(repoPointer, nameC, emailC);
@ -324,8 +324,8 @@ void setIdentity({
/// ///
/// Returns list with name and email respectively. /// Returns list with name and email respectively.
List<String> identity(Pointer<git_repository> repo) { List<String> identity(Pointer<git_repository> repo) {
final name = calloc<Pointer<Int8>>(); final name = calloc<Pointer<Char>>();
final email = calloc<Pointer<Int8>>(); final email = calloc<Pointer<Char>>();
libgit2.git_repository_ident(name, email, repo); libgit2.git_repository_ident(name, email, repo);
final identity = <String>[]; final identity = <String>[];
@ -495,7 +495,7 @@ void setHead({
required Pointer<git_repository> repoPointer, required Pointer<git_repository> repoPointer,
required String refname, required String refname,
}) { }) {
final refnameC = refname.toNativeUtf8().cast<Int8>(); final refnameC = refname.toNativeUtf8().cast<Char>();
final error = libgit2.git_repository_set_head(repoPointer, refnameC); final error = libgit2.git_repository_set_head(repoPointer, refnameC);
calloc.free(refnameC); calloc.free(refnameC);
@ -546,7 +546,7 @@ void setWorkdir({
required String path, required String path,
required bool updateGitlink, required bool updateGitlink,
}) { }) {
final workdirC = path.toNativeUtf8().cast<Int8>(); final workdirC = path.toNativeUtf8().cast<Char>();
final updateGitlinkC = updateGitlink ? 1 : 0; final updateGitlinkC = updateGitlink ? 1 : 0;
final error = libgit2.git_repository_set_workdir( final error = libgit2.git_repository_set_workdir(
repoPointer, repoPointer,

View file

@ -41,8 +41,8 @@ void resetDefault({
}) { }) {
final pathspecC = calloc<git_strarray>(); final pathspecC = calloc<git_strarray>();
final pathPointers = final pathPointers =
pathspec.map((e) => e.toNativeUtf8().cast<Int8>()).toList(); pathspec.map((e) => e.toNativeUtf8().cast<Char>()).toList();
final strArray = calloc<Pointer<Int8>>(pathspec.length); final strArray = calloc<Pointer<Char>>(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];

View file

@ -16,7 +16,7 @@ Pointer<git_revspec> revParse({
required String spec, required String spec,
}) { }) {
final out = calloc<git_revspec>(); final out = calloc<git_revspec>();
final specC = spec.toNativeUtf8().cast<Int8>(); final specC = spec.toNativeUtf8().cast<Char>();
final error = libgit2.git_revparse(out, repoPointer, specC); final error = libgit2.git_revparse(out, repoPointer, specC);
@ -42,7 +42,7 @@ Pointer<git_object> revParseSingle({
required String spec, required String spec,
}) { }) {
final out = calloc<Pointer<git_object>>(); final out = calloc<Pointer<git_object>>();
final specC = spec.toNativeUtf8().cast<Int8>(); final specC = spec.toNativeUtf8().cast<Char>();
final error = libgit2.git_revparse_single(out, repoPointer, specC); final error = libgit2.git_revparse_single(out, repoPointer, specC);
@ -76,7 +76,7 @@ List<Pointer> 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<Char>();
final error = libgit2.git_revparse_ext( final error = libgit2.git_revparse_ext(
objectOut, objectOut,

View file

@ -81,7 +81,7 @@ void pushGlob({
required Pointer<git_revwalk> walkerPointer, required Pointer<git_revwalk> walkerPointer,
required String glob, required String glob,
}) { }) {
final globC = glob.toNativeUtf8().cast<Int8>(); final globC = glob.toNativeUtf8().cast<Char>();
libgit2.git_revwalk_push_glob(walkerPointer, globC); libgit2.git_revwalk_push_glob(walkerPointer, globC);
calloc.free(globC); calloc.free(globC);
} }
@ -99,7 +99,7 @@ void pushRef({
required Pointer<git_revwalk> walkerPointer, required Pointer<git_revwalk> walkerPointer,
required String refName, required String refName,
}) { }) {
final refNameC = refName.toNativeUtf8().cast<Int8>(); final refNameC = refName.toNativeUtf8().cast<Char>();
final error = libgit2.git_revwalk_push_ref(walkerPointer, refNameC); final error = libgit2.git_revwalk_push_ref(walkerPointer, refNameC);
calloc.free(refNameC); calloc.free(refNameC);
@ -119,7 +119,7 @@ void pushRange({
required Pointer<git_revwalk> walkerPointer, required Pointer<git_revwalk> walkerPointer,
required String range, required String range,
}) { }) {
final rangeC = range.toNativeUtf8().cast<Int8>(); final rangeC = range.toNativeUtf8().cast<Char>();
final error = libgit2.git_revwalk_push_range(walkerPointer, rangeC); final error = libgit2.git_revwalk_push_range(walkerPointer, rangeC);
calloc.free(rangeC); calloc.free(rangeC);
@ -199,7 +199,7 @@ void hideGlob({
required Pointer<git_revwalk> walkerPointer, required Pointer<git_revwalk> walkerPointer,
required String glob, required String glob,
}) { }) {
final globC = glob.toNativeUtf8().cast<Int8>(); final globC = glob.toNativeUtf8().cast<Char>();
libgit2.git_revwalk_hide_glob(walkerPointer, globC); libgit2.git_revwalk_hide_glob(walkerPointer, globC);
calloc.free(globC); calloc.free(globC);
} }
@ -217,7 +217,7 @@ void hideRef({
required Pointer<git_revwalk> walkerPointer, required Pointer<git_revwalk> walkerPointer,
required String refName, required String refName,
}) { }) {
final refNameC = refName.toNativeUtf8().cast<Int8>(); final refNameC = refName.toNativeUtf8().cast<Char>();
final error = libgit2.git_revwalk_hide_ref(walkerPointer, refNameC); final error = libgit2.git_revwalk_hide_ref(walkerPointer, refNameC);
calloc.free(refNameC); calloc.free(refNameC);

View file

@ -19,8 +19,8 @@ Pointer<git_signature> create({
required int offset, required int offset,
}) { }) {
final out = calloc<Pointer<git_signature>>(); final out = calloc<Pointer<git_signature>>();
final nameC = name.toNativeUtf8().cast<Int8>(); final nameC = name.toNativeUtf8().cast<Char>();
final emailC = email.toNativeUtf8().cast<Int8>(); final emailC = email.toNativeUtf8().cast<Char>();
final error = libgit2.git_signature_new(out, nameC, emailC, time, offset); final error = libgit2.git_signature_new(out, nameC, emailC, time, offset);
final result = out.value; final result = out.value;
@ -42,8 +42,8 @@ Pointer<git_signature> create({
/// Throws a [LibGit2Error] if error occured. /// Throws a [LibGit2Error] if error occured.
Pointer<git_signature> now({required String name, required String email}) { Pointer<git_signature> now({required String name, required String email}) {
final out = calloc<Pointer<git_signature>>(); final out = calloc<Pointer<git_signature>>();
final nameC = name.toNativeUtf8().cast<Int8>(); final nameC = name.toNativeUtf8().cast<Char>();
final emailC = email.toNativeUtf8().cast<Int8>(); final emailC = email.toNativeUtf8().cast<Char>();
final error = libgit2.git_signature_now(out, nameC, emailC); final error = libgit2.git_signature_now(out, nameC, emailC);
final result = out.value; final result = out.value;

View file

@ -18,7 +18,7 @@ Pointer<git_oid> save({
required int flags, required int flags,
}) { }) {
final out = calloc<git_oid>(); final out = calloc<git_oid>();
final messageC = message?.toNativeUtf8().cast<Int8>() ?? nullptr; final messageC = message?.toNativeUtf8().cast<Char>() ?? nullptr;
final error = libgit2.git_stash_save( final error = libgit2.git_stash_save(
out, out,
repoPointer, repoPointer,
@ -143,7 +143,7 @@ var _stashList = <Stash>[];
/// A callback function to iterate over all the stashed states. /// A callback function to iterate over all the stashed states.
int _stashCb( int _stashCb(
int index, int index,
Pointer<Int8> message, Pointer<Char> message,
Pointer<git_oid> oid, Pointer<git_oid> oid,
Pointer<Void> payload, Pointer<Void> payload,
) { ) {

View file

@ -62,8 +62,8 @@ Pointer<git_status_entry> getByIndex({
/// ///
/// Throws a [LibGit2Error] if error occured. /// Throws a [LibGit2Error] if error occured.
int file({required Pointer<git_repository> repoPointer, required String path}) { int file({required Pointer<git_repository> repoPointer, required String path}) {
final out = calloc<Uint32>(); final out = calloc<UnsignedInt>();
final pathC = path.toNativeUtf8().cast<Int8>(); final pathC = path.toNativeUtf8().cast<Char>();
final error = libgit2.git_status_file(out, repoPointer, pathC); final error = libgit2.git_status_file(out, repoPointer, pathC);
final result = out.value; final result = out.value;

View file

@ -15,7 +15,7 @@ List<String> _pathsList = [];
/// Function to be called with the name of each submodule. /// Function to be called with the name of each submodule.
int _listCb( int _listCb(
Pointer<git_submodule> submodule, Pointer<git_submodule> submodule,
Pointer<Int8> name, Pointer<Char> name,
Pointer<Void> payload, Pointer<Void> payload,
) { ) {
_pathsList.add(path(submodule)); _pathsList.add(path(submodule));
@ -26,7 +26,7 @@ int _listCb(
List<String> list(Pointer<git_repository> repo) { List<String> list(Pointer<git_repository> repo) {
const except = -1; const except = -1;
final callback = Pointer.fromFunction< final callback = Pointer.fromFunction<
Int32 Function(Pointer<git_submodule>, Pointer<Int8>, Pointer<Void>)>( Int Function(Pointer<git_submodule>, Pointer<Char>, Pointer<Void>)>(
_listCb, _listCb,
except, except,
); );
@ -50,7 +50,7 @@ Pointer<git_submodule> lookup({
required String name, required String name,
}) { }) {
final out = calloc<Pointer<git_submodule>>(); final out = calloc<Pointer<git_submodule>>();
final nameC = name.toNativeUtf8().cast<Int8>(); final nameC = name.toNativeUtf8().cast<Char>();
final error = libgit2.git_submodule_lookup(out, repoPointer, nameC); final error = libgit2.git_submodule_lookup(out, repoPointer, nameC);
@ -159,8 +159,8 @@ Pointer<git_submodule> addSetup({
bool useGitlink = true, bool useGitlink = true,
}) { }) {
final out = calloc<Pointer<git_submodule>>(); final out = calloc<Pointer<git_submodule>>();
final urlC = url.toNativeUtf8().cast<Int8>(); final urlC = url.toNativeUtf8().cast<Char>();
final pathC = path.toNativeUtf8().cast<Int8>(); final pathC = path.toNativeUtf8().cast<Char>();
final useGitlinkC = useGitlink ? 1 : 0; final useGitlinkC = useGitlink ? 1 : 0;
final error = libgit2.git_submodule_add_setup( final error = libgit2.git_submodule_add_setup(
out, out,
@ -232,8 +232,8 @@ int status({
required String name, required String name,
required int ignore, required int ignore,
}) { }) {
final out = calloc<Uint32>(); final out = calloc<UnsignedInt>();
final nameC = name.toNativeUtf8().cast<Int8>(); final nameC = name.toNativeUtf8().cast<Char>();
libgit2.git_submodule_status(out, repoPointer, nameC, ignore); libgit2.git_submodule_status(out, repoPointer, nameC, ignore);
final result = out.value; final result = out.value;
@ -294,8 +294,8 @@ void setUrl({
required String name, required String name,
required String url, required String url,
}) { }) {
final nameC = name.toNativeUtf8().cast<Int8>(); final nameC = name.toNativeUtf8().cast<Char>();
final urlC = url.toNativeUtf8().cast<Int8>(); final urlC = url.toNativeUtf8().cast<Char>();
libgit2.git_submodule_set_url(repoPointer, nameC, urlC); libgit2.git_submodule_set_url(repoPointer, nameC, urlC);
@ -318,8 +318,8 @@ void setBranch({
required String name, required String name,
required String branch, required String branch,
}) { }) {
final nameC = name.toNativeUtf8().cast<Int8>(); final nameC = name.toNativeUtf8().cast<Char>();
final branchC = branch.toNativeUtf8().cast<Int8>(); final branchC = branch.toNativeUtf8().cast<Char>();
libgit2.git_submodule_set_branch(repoPointer, nameC, branchC); libgit2.git_submodule_set_branch(repoPointer, nameC, branchC);
@ -369,7 +369,7 @@ void setIgnore({
required String name, required String name,
required int ignore, required int ignore,
}) { }) {
final nameC = name.toNativeUtf8().cast<Int8>(); final nameC = name.toNativeUtf8().cast<Char>();
libgit2.git_submodule_set_ignore(repoPointer, nameC, ignore); libgit2.git_submodule_set_ignore(repoPointer, nameC, ignore);
calloc.free(nameC); calloc.free(nameC);
} }
@ -389,7 +389,7 @@ void setUpdateRule({
required String name, required String name,
required int update, required int update,
}) { }) {
final nameC = name.toNativeUtf8().cast<Int8>(); final nameC = name.toNativeUtf8().cast<Char>();
libgit2.git_submodule_set_update(repoPointer, nameC, update); libgit2.git_submodule_set_update(repoPointer, nameC, update);
calloc.free(nameC); calloc.free(nameC);
} }

View file

@ -115,8 +115,8 @@ Pointer<git_oid> createAnnotated({
required bool force, required bool force,
}) { }) {
final out = calloc<git_oid>(); final out = calloc<git_oid>();
final tagNameC = tagName.toNativeUtf8().cast<Int8>(); final tagNameC = tagName.toNativeUtf8().cast<Char>();
final messageC = message.toNativeUtf8().cast<Int8>(); final messageC = message.toNativeUtf8().cast<Char>();
final error = libgit2.git_tag_create( final error = libgit2.git_tag_create(
out, out,
repoPointer, repoPointer,
@ -155,7 +155,7 @@ Pointer<git_oid> createLightweight({
required bool force, required bool force,
}) { }) {
final out = calloc<git_oid>(); final out = calloc<git_oid>();
final tagNameC = tagName.toNativeUtf8().cast<Int8>(); final tagNameC = tagName.toNativeUtf8().cast<Char>();
final error = libgit2.git_tag_create_lightweight( final error = libgit2.git_tag_create_lightweight(
out, out,
repoPointer, repoPointer,
@ -183,7 +183,7 @@ void delete({
required Pointer<git_repository> repoPointer, required Pointer<git_repository> repoPointer,
required String tagName, required String tagName,
}) { }) {
final tagNameC = tagName.toNativeUtf8().cast<Int8>(); final tagNameC = tagName.toNativeUtf8().cast<Char>();
final error = libgit2.git_tag_delete(repoPointer, tagNameC); final error = libgit2.git_tag_delete(repoPointer, tagNameC);
calloc.free(tagNameC); calloc.free(tagNameC);

View file

@ -59,7 +59,7 @@ Pointer<git_tree_entry> getByName({
required Pointer<git_tree> treePointer, required Pointer<git_tree> treePointer,
required String filename, required String filename,
}) { }) {
final filenameC = filename.toNativeUtf8().cast<Int8>(); final filenameC = filename.toNativeUtf8().cast<Char>();
final result = libgit2.git_tree_entry_byname(treePointer, filenameC); final result = libgit2.git_tree_entry_byname(treePointer, filenameC);
calloc.free(filenameC); calloc.free(filenameC);
@ -83,7 +83,7 @@ Pointer<git_tree_entry> getByPath({
required String path, required String path,
}) { }) {
final out = calloc<Pointer<git_tree_entry>>(); final out = calloc<Pointer<git_tree_entry>>();
final pathC = path.toNativeUtf8().cast<Int8>(); final pathC = path.toNativeUtf8().cast<Char>();
final error = libgit2.git_tree_entry_bypath(out, rootPointer, pathC); final error = libgit2.git_tree_entry_bypath(out, rootPointer, pathC);
final result = out.value; final result = out.value;

View file

@ -53,7 +53,7 @@ Pointer<git_tree_entry> getByFilename({
required Pointer<git_treebuilder> builderPointer, required Pointer<git_treebuilder> builderPointer,
required String filename, required String filename,
}) { }) {
final filenameC = filename.toNativeUtf8().cast<Int8>(); final filenameC = filename.toNativeUtf8().cast<Char>();
final result = libgit2.git_treebuilder_get(builderPointer, filenameC); final result = libgit2.git_treebuilder_get(builderPointer, filenameC);
calloc.free(filenameC); calloc.free(filenameC);
@ -82,7 +82,7 @@ void add({
required Pointer<git_oid> oidPointer, required Pointer<git_oid> oidPointer,
required int filemode, required int filemode,
}) { }) {
final filenameC = filename.toNativeUtf8().cast<Int8>(); final filenameC = filename.toNativeUtf8().cast<Char>();
final error = libgit2.git_treebuilder_insert( final error = libgit2.git_treebuilder_insert(
nullptr, nullptr,
builderPointer, builderPointer,
@ -105,7 +105,7 @@ void remove({
required Pointer<git_treebuilder> builderPointer, required Pointer<git_treebuilder> builderPointer,
required String filename, required String filename,
}) { }) {
final filenameC = filename.toNativeUtf8().cast<Int8>(); final filenameC = filename.toNativeUtf8().cast<Char>();
final error = libgit2.git_treebuilder_remove(builderPointer, filenameC); final error = libgit2.git_treebuilder_remove(builderPointer, filenameC);
calloc.free(filenameC); calloc.free(filenameC);

View file

@ -20,8 +20,8 @@ Pointer<git_worktree> create({
Pointer<git_reference>? refPointer, Pointer<git_reference>? refPointer,
}) { }) {
final out = calloc<Pointer<git_worktree>>(); final out = calloc<Pointer<git_worktree>>();
final nameC = name.toNativeUtf8().cast<Int8>(); final nameC = name.toNativeUtf8().cast<Char>();
final pathC = path.toNativeUtf8().cast<Int8>(); final pathC = path.toNativeUtf8().cast<Char>();
final opts = calloc<git_worktree_add_options>(); final opts = calloc<git_worktree_add_options>();
libgit2.git_worktree_add_options_init(opts, GIT_WORKTREE_ADD_OPTIONS_VERSION); libgit2.git_worktree_add_options_init(opts, GIT_WORKTREE_ADD_OPTIONS_VERSION);
@ -56,7 +56,7 @@ Pointer<git_worktree> lookup({
required String name, required String name,
}) { }) {
final out = calloc<Pointer<git_worktree>>(); final out = calloc<Pointer<git_worktree>>();
final nameC = name.toNativeUtf8().cast<Int8>(); final nameC = name.toNativeUtf8().cast<Char>();
final error = libgit2.git_worktree_lookup(out, repoPointer, nameC); final error = libgit2.git_worktree_lookup(out, repoPointer, nameC);
final result = out.value; final result = out.value;

View file

@ -348,7 +348,7 @@ class IndexEntry extends Equatable {
String get path => _indexEntryPointer.ref.path.cast<Utf8>().toDartString(); String get path => _indexEntryPointer.ref.path.cast<Utf8>().toDartString();
set path(String path) => set path(String path) =>
_indexEntryPointer.ref.path = path.toNativeUtf8().cast<Int8>(); _indexEntryPointer.ref.path = path.toNativeUtf8().cast<Char>();
/// UNIX file attributes of a index entry. /// UNIX file attributes of a index entry.
GitFilemode get mode { GitFilemode get mode {

View file

@ -12,9 +12,9 @@ class Libgit2 {
static String get version { static String get version {
libgit2.git_libgit2_init(); libgit2.git_libgit2_init();
final major = calloc<Int32>(); final major = calloc<Int>();
final minor = calloc<Int32>(); final minor = calloc<Int>();
final rev = calloc<Int32>(); final rev = calloc<Int>();
libgit2.git_libgit2_version(major, minor, rev); libgit2.git_libgit2_version(major, minor, rev);
final version = '${major.value}.${minor.value}.${rev.value}'; final version = '${major.value}.${minor.value}.${rev.value}';
@ -39,8 +39,8 @@ class Libgit2 {
static bool get ownerValidation { static bool get ownerValidation {
libgit2.git_libgit2_init(); libgit2.git_libgit2_init();
final out = calloc<Int8>(); final out = calloc<Char>();
libgit2.git_libgit2_opts( libgit2Opts.git_libgit2_opts(
git_libgit2_opt_t.GIT_OPT_GET_OWNER_VALIDATION, git_libgit2_opt_t.GIT_OPT_GET_OWNER_VALIDATION,
out, out,
); );
@ -53,8 +53,9 @@ class Libgit2 {
/// Sets owner validation setting for repository directories. /// Sets owner validation setting for repository directories.
static set ownerValidation(bool value) { static set ownerValidation(bool value) {
libgit2.git_libgit2_init(); libgit2.git_libgit2_init();
final valueC = value ? 1 : 0; final valueC = value ? 1 : 0;
libgit2.git_libgit2_opts_set( libgit2Opts.git_libgit2_opts_set(
git_libgit2_opt_t.GIT_OPT_SET_OWNER_VALIDATION, git_libgit2_opt_t.GIT_OPT_SET_OWNER_VALIDATION,
valueC, valueC,
); );

View file

@ -3,8 +3,8 @@
import 'dart:ffi'; import 'dart:ffi';
import 'dart:io'; import 'dart:io';
import 'package:cli_util/cli_logging.dart' show Ansi, Logger;
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart'; import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
import 'package:libgit2dart/src/bindings/libgit2_opts_bindings.dart';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
import 'package:pub_cache/pub_cache.dart'; import 'package:pub_cache/pub_cache.dart';
@ -78,19 +78,16 @@ DynamicLibrary loadLibrary(String name) {
_resolveLibPath(name) ?? name, _resolveLibPath(name) ?? name,
); );
} catch (e) { } catch (e) {
final logger = Logger.standard(); stderr.writeln(
final ansi = Ansi(Ansi.terminalSupportsAnsi); 'Failed to open the library. Make sure that libgit2 library is bundled '
'with the application.',
logger.stderr(
'${ansi.red}Failed to open the library. Make sure that libgit2 '
'library is bundled with the application.${ansi.none}',
); );
logger.stdout(ansi.none);
rethrow; rethrow;
} }
} }
final libgit2 = Libgit2(loadLibrary(getLibName())); final libgit2 = Libgit2(loadLibrary(getLibName()));
final libgit2Opts = Libgit2Opts(loadLibrary(getLibName()));
bool isValidShaHex(String str) { bool isValidShaHex(String str) {
final hexRegExp = RegExp(r'^[0-9a-fA-F]+$'); final hexRegExp = RegExp(r'^[0-9a-fA-F]+$');

View file

@ -1,6 +1,6 @@
name: libgit2dart name: libgit2dart
description: Dart bindings to libgit2. description: Dart bindings to libgit2, provides ability to use libgit2 library in Dart and Flutter.
version: 1.0.0 version: 1.0.0
@ -8,11 +8,10 @@ homepage: https://github.com/SkinnyMind/libgit2dart
environment: environment:
sdk: ">=2.17.0 <3.0.0" sdk: ">=2.17.0 <3.0.0"
flutter: ">=2.13.0-0.0.pre.578" flutter: ">=3.0.0"
dependencies: dependencies:
args: ^2.3.0 args: ^2.3.0
cli_util: ^0.3.5
equatable: ^2.0.3 equatable: ^2.0.3
ffi: ^1.1.2 ffi: ^1.1.2
meta: ^1.7.0 meta: ^1.7.0
@ -20,7 +19,7 @@ dependencies:
pub_cache: ^0.3.1 pub_cache: ^0.3.1
dev_dependencies: dev_dependencies:
ffigen: ^4.1.2 ffigen: ^5.0.0
lints: ^2.0.0 lints: ^2.0.0
test: ^1.20.0 test: ^1.20.0