isAncestor method

Future<bool> isAncestor(
  1. GitCommit ancestor,
  2. GitCommit child
)

isAncestor returns true if the actual commit is ancestor of the passed one. It returns an error if the history is not transversable It mimics the behavior of git merge --is-ancestor actual other

Implementation

Future<bool> isAncestor(GitCommit ancestor, GitCommit child) async {
  var iter = commitPreOrderIterator(objStorage: objStorage, from: child);
  await for (var commit in iter) {
    if (commit.hash == ancestor.hash) {
      return true;
    }
  }
  return false;
}