]> gitweb.ps.run Git - ziggit/blobdiff - git.zig
Update Tree struct
[ziggit] / git.zig
diff --git a/git.zig b/git.zig
index e21847c2a05e8579e8db53220eeedbdb14670633..8c44fb6bd891daf0c2bc30c5e2444e85f2732365 100644 (file)
--- a/git.zig
+++ b/git.zig
@@ -8,11 +8,18 @@ const MaxFileSize = 1024 * 1024;
 
 const Id = u160;
 const Commit = struct {
+    tree: Id,
+    parent: Id,
     author: []u8,
+    committer: []u8,
     message: []u8,
-    parent: Id,
-    tree: Id,
 };
+const TreeEntry = struct {
+    permissions: []u8,
+    name: []u8,
+    id: Id,
+};
+const Tree = std.ArrayList(TreeEntry);
 const Blob = struct {
     data: []u8,
 };
@@ -30,6 +37,14 @@ const Object = struct {
     // pub fn getBlob(self: *Object) Blob {}
 };
 
+fn decompress(alloc: Alloc, r: Reader) ![]u8 {
+    var buffer = std.ArrayList(u8).init(alloc);
+
+    try std.compress.zlib.decompress(r, buffer.writer().any());
+
+    return alloc.realloc(buffer.allocatedSlice(), buffer.items.len);
+}
+
 const PackFile = struct {
     alloc: Alloc,
     idxFile: std.fs.File,