GitTree constructor

GitTree(
  1. Uint8List raw,
  2. GitHash? _hash
)

Implementation

GitTree(Uint8List raw, this._hash) {
  var start = 0;
  while (start < raw.length) {
    var x = raw.indexOf(asciiHelper.space, start);
    assert(x - start == 5 || x - start == 6);

    var mode = raw.sublistView(start, x);
    var y = raw.indexOf(0, x);
    var name = raw.sublistView(x + 1, y);
    var hashBytes = raw.sublistView(y + 1, y + 21);

    var entry = GitTreeEntry(
      mode: GitFileMode.parse(ascii.decode(mode)),
      name: utf8.decode(name),
      hash: GitHash.fromBytes(hashBytes),
    );

    entries.add(entry);

    start = y + 21;
  }
}