From: patrick-scho Date: Sat, 10 Aug 2024 15:09:43 +0000 (+0200) Subject: replace packfile with optional X-Git-Url: https://gitweb.ps.run/ziggit/commitdiff_plain/fba8e20a91f6cd9fc54c14abcd3580bf0b687332 replace packfile with optional --- diff --git a/git.zig b/git.zig index 7dd1d96..fd79e6c 100644 --- a/git.zig +++ b/git.zig @@ -326,7 +326,10 @@ const Repo = struct { } pub fn getObject(self: *Repo, id: Id) !?Object { - return self.packfile.getObject(id); + if (self.packfile) |*packfile| { + return packfile.getObject(id); + } + return null; } }; @@ -343,8 +346,10 @@ test "parse idx" { var repo = try Repo.open(std.testing.allocator, "../microwindows/.git"); defer repo.close(); - std.debug.print("{}\n", .{repo.packfile.objectOffsets.keys().len}); - std.debug.print("{}\n", .{repo.packfile.objectOffsets.values().len}); + if (repo.packfile) |packfile| { + std.debug.print("{}\n", .{packfile.objectOffsets.keys().len}); + std.debug.print("{}\n", .{packfile.objectOffsets.values().len}); + } } test "get object" {