mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-04 20:29:08 -04:00
style: move declarations of callbacks above the function they will be used in
This commit is contained in:
parent
a1d617e053
commit
5be0d0a6b5
2 changed files with 24 additions and 22 deletions
|
@ -81,8 +81,20 @@ bool exists({
|
||||||
}
|
}
|
||||||
|
|
||||||
/// List of objects in the database.
|
/// List of objects in the database.
|
||||||
|
///
|
||||||
|
/// IMPORTANT: make sure to clear that list since it's a global variable.
|
||||||
var _objects = <Oid>[];
|
var _objects = <Oid>[];
|
||||||
|
|
||||||
|
/// The callback to call for each object.
|
||||||
|
int _forEachCb(
|
||||||
|
Pointer<git_oid> oid,
|
||||||
|
Pointer<Void> payload,
|
||||||
|
) {
|
||||||
|
final _oid = oid_bindings.copy(oid);
|
||||||
|
_objects.add(Oid(_oid));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/// List all objects available in the database.
|
/// List all objects available in the database.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
|
@ -105,16 +117,6 @@ List<Oid> objects(Pointer<git_odb> odb) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The callback to call for each object.
|
|
||||||
int _forEachCb(
|
|
||||||
Pointer<git_oid> oid,
|
|
||||||
Pointer<Void> payload,
|
|
||||||
) {
|
|
||||||
final _oid = oid_bindings.copy(oid);
|
|
||||||
_objects.add(Oid(_oid));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Read an object from the database.
|
/// Read an object from the database.
|
||||||
///
|
///
|
||||||
/// This method queries all available ODB backends trying to read the given OID.
|
/// This method queries all available ODB backends trying to read the given OID.
|
||||||
|
|
|
@ -139,18 +139,6 @@ void pop({
|
||||||
/// IMPORTANT: make sure to clear that list since it's a global variable.
|
/// IMPORTANT: make sure to clear that list since it's a global variable.
|
||||||
var _stashList = <Stash>[];
|
var _stashList = <Stash>[];
|
||||||
|
|
||||||
/// Loop over all the stashed states.
|
|
||||||
List<Stash> list(Pointer<git_repository> repo) {
|
|
||||||
const except = -1;
|
|
||||||
git_stash_cb callBack = Pointer.fromFunction(_stashCb, except);
|
|
||||||
libgit2.git_stash_foreach(repo, callBack, nullptr);
|
|
||||||
|
|
||||||
final result = _stashList.toList(growable: false);
|
|
||||||
_stashList.clear();
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 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,
|
||||||
|
@ -165,3 +153,15 @@ int _stashCb(
|
||||||
));
|
));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Loop over all the stashed states.
|
||||||
|
List<Stash> list(Pointer<git_repository> repo) {
|
||||||
|
const except = -1;
|
||||||
|
git_stash_cb callBack = Pointer.fromFunction(_stashCb, except);
|
||||||
|
libgit2.git_stash_foreach(repo, callBack, nullptr);
|
||||||
|
|
||||||
|
final result = _stashList.toList(growable: false);
|
||||||
|
_stashList.clear();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue