const Blob = struct {
data: []u8,
};
+const ParsedObject = union(enum) {
+ c: Commit,
+ t: Tree,
+ b: Blob,
+};
const Object = struct {
kind: u3,
data: []u8,
.data = data,
};
}
- pub fn parse(self: Object, alloc: Alloc) !union(enum) { c: Commit, t: Tree, b: Blob } {
+ pub fn parse(self: Object, alloc: Alloc) !ParsedObject {
switch (self.kind) {
1 => {
const authorOffset = std.mem.indexOf(u8, self.data, "author ") orelse return error.InvalidCommitFormat;
const pckReader = self.pckFile.reader().any();
try self.pckFile.seekTo(offset);
- return try self.readObject(pckReader);
+ const o = try self.readObject(pckReader);
+
+ return o;
}
return null;
}