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;
}
defer std.testing.allocator.free(bo.data);
if (treeEntry.permissions.len == 6) {
- std.debug.print("{s}: {s}\n", .{ treeEntry.name, bo.data[0..50] });
+ std.debug.print("{s}: [{x} {}]{s}\n", .{ treeEntry.name, treeEntry.id, bo.data.len, bo.data[0..50] });
} else {
std.debug.print("[{s}]\n", .{treeEntry.name});
}