diff --git a/git.zig b/git.zig index 5c8e83b678a902f631dec45ed1d33e1f2abd7b0e..eab03ba5f884a51acbbcd4837c3bc1c7d513a555 100644 --- a/git.zig +++ b/git.zig @@ -1137,9 +1137,9 @@ pub const Repository = struct { if (cache_behavior == .cache) if (r.commits.get(id.id)) |val| { return .{ id, val }; }; - if (try r.getObject(id.id, .cache)) |obj| { + if (try r.getObject(id.id, .no_cache)) |obj| { if (obj.type == .commit) { - const raw = try r.gpa.dupe(u8, obj.content); + const raw = obj.content; errdefer r.gpa.free(raw); const commit = try r.gpa.create(Commit); errdefer r.gpa.destroy(commit); @@ -1147,6 +1147,7 @@ pub const Repository = struct { if (cache_behavior == .cache) try r.commits.put(r.gpa, id.id, commit); return .{ id, commit }; } + r.gpa.free(obj.content); } return null; }