| ... | @@ -802,9 +802,9 @@ pub const Repository = struct { | ... | @@ -802,9 +802,9 @@ pub const Repository = struct { |
| 802 | const t = tracer.trace(@src(), " {s}", .{oid}); | 802 | const t = tracer.trace(@src(), " {s}", .{oid}); |
| 803 | defer t.end(); | 803 | defer t.end(); |
| 804 | | 804 | |
| 805 | if (r.unpacked_loose_objects.get(oid)) |obj| { | 805 | if (cache_behavior == .cache) if (r.unpacked_loose_objects.get(oid)) |obj| { |
| 806 | return obj; | 806 | return obj; |
| 807 | } | 807 | }; |
| 808 | if (oid.len == 40) blk: { //sha1 object | 808 | if (oid.len == 40) blk: { //sha1 object |
| 809 | var sub_path: [49:0]u8 = "objects/00/00000000000000000000000000000000000000".*; | 809 | var sub_path: [49:0]u8 = "objects/00/00000000000000000000000000000000000000".*; |
| 810 | @memcpy(sub_path[8..][0..2], oid[0..2]); | 810 | @memcpy(sub_path[8..][0..2], oid[0..2]); |
| ... | @@ -928,7 +928,7 @@ pub const Repository = struct { | ... | @@ -928,7 +928,7 @@ pub const Repository = struct { |
| 928 | defer t.end(); | 928 | defer t.end(); |
| 929 | | 929 | |
| 930 | const key = std.hash.Wyhash.hash(0, &(std.mem.toBytes(pack_index) ++ std.mem.toBytes(pack_offset))); | 930 | const key = std.hash.Wyhash.hash(0, &(std.mem.toBytes(pack_index) ++ std.mem.toBytes(pack_offset))); |
| 931 | if (r.unpacked_objects.get(key)) |o| return o; | 931 | if (cache_behavior == .cache) if (r.unpacked_objects.get(key)) |o| return o; |
| 932 | | 932 | |
| 933 | const pack_content = r.pack_content.values()[pack_index]; | 933 | const pack_content = r.pack_content.values()[pack_index]; |
| 934 | if (!std.mem.eql(u8, pack_content[0..4], "PACK")) return error.InvalidGitPack; | 934 | if (!std.mem.eql(u8, pack_content[0..4], "PACK")) return error.InvalidGitPack; |
| ... | @@ -1108,9 +1108,9 @@ pub const Repository = struct { | ... | @@ -1108,9 +1108,9 @@ pub const Repository = struct { |
| 1108 | const t = tracer.trace(@src(), " {s}", .{id.id}); | 1108 | const t = tracer.trace(@src(), " {s}", .{id.id}); |
| 1109 | defer t.end(); | 1109 | defer t.end(); |
| 1110 | | 1110 | |
| 1111 | if (r.commits.getPtr(id.id)) |val| { | 1111 | if (cache_behavior == .cache) if (r.commits.getPtr(id.id)) |val| { |
| 1112 | return .{ id, val.* }; | 1112 | return .{ id, val.* }; |
| 1113 | } | 1113 | }; |
| 1114 | if (try r.getObject(id.id, cache_behavior)) |obj| { | 1114 | if (try r.getObject(id.id, cache_behavior)) |obj| { |
| 1115 | if (obj.type == .commit) { | 1115 | if (obj.type == .commit) { |
| 1116 | errdefer if (cache_behavior == .no_cache) r.gpa.free(obj.content); | 1116 | errdefer if (cache_behavior == .no_cache) r.gpa.free(obj.content); |
| ... | @@ -1131,9 +1131,9 @@ pub const Repository = struct { | ... | @@ -1131,9 +1131,9 @@ pub const Repository = struct { |
| 1131 | const t = tracer.trace(@src(), " {s}", .{id.id}); | 1131 | const t = tracer.trace(@src(), " {s}", .{id.id}); |
| 1132 | defer t.end(); | 1132 | defer t.end(); |
| 1133 | | 1133 | |
| 1134 | if (r.trees.getPtr(id.id)) |val| { | 1134 | if (cache_behavior == .cache) if (r.trees.getPtr(id.id)) |val| { |
| 1135 | return .{ id, val.* }; | 1135 | return .{ id, val.* }; |
| 1136 | } | 1136 | }; |
| 1137 | if (try r.getObject(id.id, cache_behavior)) |obj| { | 1137 | if (try r.getObject(id.id, cache_behavior)) |obj| { |
| 1138 | if (obj.type == .tree) { | 1138 | if (obj.type == .tree) { |
| 1139 | errdefer if (cache_behavior == .no_cache) r.gpa.free(obj.content); | 1139 | errdefer if (cache_behavior == .no_cache) r.gpa.free(obj.content); |
| ... | @@ -1192,9 +1192,9 @@ pub const Repository = struct { | ... | @@ -1192,9 +1192,9 @@ pub const Repository = struct { |
| 1192 | const t = tracer.trace(@src(), " {s}", .{id.id}); | 1192 | const t = tracer.trace(@src(), " {s}", .{id.id}); |
| 1193 | defer t.end(); | 1193 | defer t.end(); |
| 1194 | | 1194 | |
| 1195 | if (r.tags.getPtr(id.id)) |val| { | 1195 | if (cache_behavior == .cache) if (r.tags.getPtr(id.id)) |val| { |
| 1196 | return .{ id, val.* }; | 1196 | return .{ id, val.* }; |
| 1197 | } | 1197 | }; |
| 1198 | if (try r.getObject(id.id, cache_behavior)) |obj| { | 1198 | if (try r.getObject(id.id, cache_behavior)) |obj| { |
| 1199 | if (obj.type == .tag) { | 1199 | if (obj.type == .tag) { |
| 1200 | errdefer if (cache_behavior == .no_cache) r.gpa.free(obj.content); | 1200 | errdefer if (cache_behavior == .no_cache) r.gpa.free(obj.content); |