authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-04-15 13:44:48 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-04-15 13:44:48 -07:00
log0698318aecc1b414a792903d3b41f7b389da125c
treec1f33b3550df308e585c74a7ba6f437a1a30bbb1
parent8542465ecb6fa7e88cafae019a744fb7b71b1f99
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

fix oneliner in getDeltadObject when nbytes=0


1 files changed, 6 insertions(+), 7 deletions(-)

git.zig+6-7
......@@ -957,8 +957,6 @@ pub const Repository = struct {
957957 t4.end();
958958
959959 // parse .pack
960 // std.log.debug("pack_index={d} pack_offset={d}", .{ pack_index, pack_offset });
961
962960 return try r.getPackedObject(arena, oid, pack_index, pack_offset);
963961 }
964962
......@@ -983,7 +981,7 @@ pub const Repository = struct {
983981 size += (c & 0x7f) << shift;
984982 shift += 7;
985983 }
986 // std.log.debug("type={s} size={d}", .{ @tagName(ty), size });
984 // std.log.debug("pack_index={d} pack_offset={d} type={s} size={d}", .{ pack_index, pack_offset, @tagName(ty), size });
987985 const t2 = tracer.trace(@src(), " 2 {s} {d}", .{ @tagName(ty), size });
988986 defer t2.end();
989987 switch (ty) {
......@@ -1017,13 +1015,11 @@ pub const Repository = struct {
10171015 const base_pack_offset = pack_offset - offset;
10181016 const base_obj = try r.getPackedObject(arena, null, pack_index, base_pack_offset);
10191017 defer r.gpa.free(base_obj.content);
1020 // std.log.debug("base: type={s} content=[{d}]", .{ @tagName(base_obj.type), base_obj.content.len });
10211018 return r.getDeltadObject(maybe_oid, &packedobj_fbs, size, base_obj);
10221019 },
10231020 .ref_delta => {
10241021 const base_oid = extras.to_hex(packedobj_fbs.takeSlice(20)[0..20].*);
10251022 const base_obj = (try r.getObject(arena, &base_oid)).?;
1026 // std.log.debug("base: type={s} content=[{d}]", .{ @tagName(base_obj.type), base_obj.content.len });
10271023 return r.getDeltadObject(maybe_oid, &packedobj_fbs, size, base_obj);
10281024 },
10291025 }
......@@ -1044,6 +1040,7 @@ pub const Repository = struct {
10441040 // try std.compress.flate.inflate.decompress(.zlib, bufr.anyReadable(), list.writer(r.gpa));
10451041 try inflate_decompress(compressed_content, &list, r.gpa);
10461042 std.debug.assert(list.items.len == size);
1043 // std.log.debug("maybe_oid={?s} size={d}", .{ maybe_oid, size });
10471044 // std.log.debug("transformation data=[{d}]{d}", .{ list.items.len, list.items });
10481045
10491046 var unpackedobj_fbs = nio.FixedBufferStream([]const u8).init(list.items);
......@@ -1079,8 +1076,10 @@ pub const Repository = struct {
10791076 b.append(if (c2 & mask > 0) unpackedobj_fbs.takeByte() else 0);
10801077 }
10811078 const start: u32 = @bitCast(b.items[0..4].*);
1082 const nbytes: u24 = @bitCast(b.items[4..7].*);
1079 var nbytes: u24 = @bitCast(b.items[4..7].*);
1080 if (nbytes == 0) nbytes = 0x10000;
10831081 // std.log.debug("- copy from base: start={d} nbytes={d}", .{ start, nbytes });
1082 // std.log.debug(" - {d} {d}", .{ c2, b.items });
10841083 const bytes = base_obj.content[start..][0..nbytes];
10851084 // std.log.debug("{s}\n", .{bytes});
10861085 try list2.appendSlice(r.gpa, bytes);
......@@ -1095,7 +1094,7 @@ pub const Repository = struct {
10951094 }
10961095 }
10971096
1098 // std.log.debug("- done", .{});
1097 // std.log.debug("- done {d}", .{list2.items.len});
10991098 // std.log.debug("{s}\n", .{list2.items});
11001099 const _type = base_obj.type;
11011100 const content = try list2.toOwnedSlice(r.gpa);