| ... | ... | @@ -1089,6 +1089,10 @@ pub const Repository = struct { |
| 1089 | 1089 | // parse .pack |
| 1090 | 1090 | std.log.warn("pack_index={d} pack_offset={d}", .{ pack_index, pack_offset }); |
| 1091 | 1091 | |
| 1092 | return try r.getPackedObject(obj, pack_index, pack_offset); |
| 1093 | } |
| 1094 | |
| 1095 | fn getPackedObject(r: *Repository, maybe_obj: ?Id, pack_index: usize, pack_offset: usize) ![]const u8 { |
| 1092 | 1096 | const pack_content = r.pack_content.values()[pack_index]; |
| 1093 | 1097 | if (!std.mem.eql(u8, pack_content[0..4], "PACK")) return error.InvalidGitPack; |
| 1094 | 1098 | const pack_version = std.mem.readInt(u32, pack_content[4..][0..4], .big); |
| ... | ... | @@ -1112,8 +1116,11 @@ pub const Repository = struct { |
| 1112 | 1116 | std.log.warn("type={s} size={d}", .{ @tagName(ty), size }); |
| 1113 | 1117 | |
| 1114 | 1118 | switch (ty) { |
| 1115 | | .none, .reserved => { |
| 1116 | | return null; |
| 1119 | .none => { |
| 1120 | unreachable; |
| 1121 | }, |
| 1122 | .reserved => { |
| 1123 | unreachable; |
| 1117 | 1124 | }, |
| 1118 | 1125 | .commit, .tree, .blob, .tag => { |
| 1119 | 1126 | const compressed_content = packedobj_fbs.rest()[0..size]; |
| ... | ... | @@ -1125,14 +1132,16 @@ pub const Repository = struct { |
| 1125 | 1132 | try list.writer().print(" {d}\x00", .{size}); |
| 1126 | 1133 | try std.compress.flate.inflate.decompress(.zlib, bufr.anyReadable(), list.writer()); |
| 1127 | 1134 | const content = try list.toOwnedSlice(); |
| 1128 | | try r.raw_object_contents.put(r.gpa, obj, content); |
| 1135 | if (maybe_obj) |obj| try r.raw_object_contents.put(r.gpa, obj, content); |
| 1129 | 1136 | return content; |
| 1130 | 1137 | }, |
| 1131 | 1138 | .ofs_delta => { |
| 1132 | | return null; |
| 1139 | std.log.debug("type={s} size={d}", .{ @tagName(ty), size }); |
| 1140 | unreachable; |
| 1133 | 1141 | }, |
| 1134 | 1142 | .ref_delta => { |
| 1135 | | return null; |
| 1143 | std.log.debug("type={s} size={d}", .{ @tagName(ty), size }); |
| 1144 | unreachable; |
| 1136 | 1145 | }, |
| 1137 | 1146 | } |
| 1138 | 1147 | comptime unreachable; |
| ... | ... | @@ -1142,7 +1151,6 @@ pub const Repository = struct { |
| 1142 | 1151 | }, |
| 1143 | 1152 | else => return error.InvalidGitPack, |
| 1144 | 1153 | } |
| 1145 | | return null; |
| 1146 | 1154 | } |
| 1147 | 1155 | |
| 1148 | 1156 | pub fn getGitObject(r: *Repository, arena: std.mem.Allocator, obj: Id) !?GitObject { |