diff --git a/lib/src/bindings/odb.dart b/lib/src/bindings/odb.dart index 15cf904..5eddc9e 100644 --- a/lib/src/bindings/odb.dart +++ b/lib/src/bindings/odb.dart @@ -81,8 +81,20 @@ bool exists({ } /// List of objects in the database. +/// +/// IMPORTANT: make sure to clear that list since it's a global variable. var _objects = []; +/// The callback to call for each object. +int _forEachCb( + Pointer oid, + Pointer payload, +) { + final _oid = oid_bindings.copy(oid); + _objects.add(Oid(_oid)); + return 0; +} + /// List all objects available in the database. /// /// Throws a [LibGit2Error] if error occured. @@ -105,16 +117,6 @@ List objects(Pointer odb) { return result; } -/// The callback to call for each object. -int _forEachCb( - Pointer oid, - Pointer payload, -) { - final _oid = oid_bindings.copy(oid); - _objects.add(Oid(_oid)); - return 0; -} - /// Read an object from the database. /// /// This method queries all available ODB backends trying to read the given OID. diff --git a/lib/src/bindings/stash.dart b/lib/src/bindings/stash.dart index 800f356..ad2dbaf 100644 --- a/lib/src/bindings/stash.dart +++ b/lib/src/bindings/stash.dart @@ -139,18 +139,6 @@ void pop({ /// IMPORTANT: make sure to clear that list since it's a global variable. var _stashList = []; -/// Loop over all the stashed states. -List list(Pointer 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. int _stashCb( int index, @@ -165,3 +153,15 @@ int _stashCb( )); return 0; } + +/// Loop over all the stashed states. +List list(Pointer 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; +}