diff options
Diffstat (limited to 'git.zig')
| -rw-r--r-- | git.zig | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -23,6 +23,11 @@ const Tree = std.ArrayList(TreeEntry); const Blob = struct { data: []u8, }; +const ParsedObject = union(enum) { + c: Commit, + t: Tree, + b: Blob, +}; const Object = struct { kind: u3, data: []u8, @@ -33,7 +38,7 @@ const Object = struct { .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; @@ -350,7 +355,9 @@ const PackFile = struct { 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; } |
