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 {...@@ -957,8 +957,6 @@ pub const Repository = struct {
957 t4.end();957 t4.end();
958958
959 // parse .pack959 // parse .pack
960 // std.log.debug("pack_index={d} pack_offset={d}", .{ pack_index, pack_offset });
961
962 return try r.getPackedObject(arena, oid, pack_index, pack_offset);960 return try r.getPackedObject(arena, oid, pack_index, pack_offset);
963 }961 }
964962
...@@ -983,7 +981,7 @@ pub const Repository = struct {...@@ -983,7 +981,7 @@ pub const Repository = struct {
983 size += (c & 0x7f) << shift;981 size += (c & 0x7f) << shift;
984 shift += 7;982 shift += 7;
985 }983 }
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 });
987 const t2 = tracer.trace(@src(), " 2 {s} {d}", .{ @tagName(ty), size });985 const t2 = tracer.trace(@src(), " 2 {s} {d}", .{ @tagName(ty), size });
988 defer t2.end();986 defer t2.end();
989 switch (ty) {987 switch (ty) {
...@@ -1017,13 +1015,11 @@ pub const Repository = struct {...@@ -1017,13 +1015,11 @@ pub const Repository = struct {
1017 const base_pack_offset = pack_offset - offset;1015 const base_pack_offset = pack_offset - offset;
1018 const base_obj = try r.getPackedObject(arena, null, pack_index, base_pack_offset);1016 const base_obj = try r.getPackedObject(arena, null, pack_index, base_pack_offset);
1019 defer r.gpa.free(base_obj.content);1017 defer r.gpa.free(base_obj.content);
1020 // std.log.debug("base: type={s} content=[{d}]", .{ @tagName(base_obj.type), base_obj.content.len });
1021 return r.getDeltadObject(maybe_oid, &packedobj_fbs, size, base_obj);1018 return r.getDeltadObject(maybe_oid, &packedobj_fbs, size, base_obj);
1022 },1019 },
1023 .ref_delta => {1020 .ref_delta => {
1024 const base_oid = extras.to_hex(packedobj_fbs.takeSlice(20)[0..20].*);1021 const base_oid = extras.to_hex(packedobj_fbs.takeSlice(20)[0..20].*);
1025 const base_obj = (try r.getObject(arena, &base_oid)).?;1022 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 });
1027 return r.getDeltadObject(maybe_oid, &packedobj_fbs, size, base_obj);1023 return r.getDeltadObject(maybe_oid, &packedobj_fbs, size, base_obj);
1028 },1024 },
1029 }1025 }
...@@ -1044,6 +1040,7 @@ pub const Repository = struct {...@@ -1044,6 +1040,7 @@ pub const Repository = struct {
1044 // try std.compress.flate.inflate.decompress(.zlib, bufr.anyReadable(), list.writer(r.gpa));1040 // try std.compress.flate.inflate.decompress(.zlib, bufr.anyReadable(), list.writer(r.gpa));
1045 try inflate_decompress(compressed_content, &list, r.gpa);1041 try inflate_decompress(compressed_content, &list, r.gpa);
1046 std.debug.assert(list.items.len == size);1042 std.debug.assert(list.items.len == size);
1043 // std.log.debug("maybe_oid={?s} size={d}", .{ maybe_oid, size });
1047 // std.log.debug("transformation data=[{d}]{d}", .{ list.items.len, list.items });1044 // std.log.debug("transformation data=[{d}]{d}", .{ list.items.len, list.items });
10481045
1049 var unpackedobj_fbs = nio.FixedBufferStream([]const u8).init(list.items);1046 var unpackedobj_fbs = nio.FixedBufferStream([]const u8).init(list.items);
...@@ -1079,8 +1076,10 @@ pub const Repository = struct {...@@ -1079,8 +1076,10 @@ pub const Repository = struct {
1079 b.append(if (c2 & mask > 0) unpackedobj_fbs.takeByte() else 0);1076 b.append(if (c2 & mask > 0) unpackedobj_fbs.takeByte() else 0);
1080 }1077 }
1081 const start: u32 = @bitCast(b.items[0..4].*);1078 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;
1083 // std.log.debug("- copy from base: start={d} nbytes={d}", .{ start, nbytes });1081 // std.log.debug("- copy from base: start={d} nbytes={d}", .{ start, nbytes });
1082 // std.log.debug(" - {d} {d}", .{ c2, b.items });
1084 const bytes = base_obj.content[start..][0..nbytes];1083 const bytes = base_obj.content[start..][0..nbytes];
1085 // std.log.debug("{s}\n", .{bytes});1084 // std.log.debug("{s}\n", .{bytes});
1086 try list2.appendSlice(r.gpa, bytes);1085 try list2.appendSlice(r.gpa, bytes);
...@@ -1095,7 +1094,7 @@ pub const Repository = struct {...@@ -1095,7 +1094,7 @@ pub const Repository = struct {
1095 }1094 }
1096 }1095 }
10971096
1098 // std.log.debug("- done", .{});1097 // std.log.debug("- done {d}", .{list2.items.len});
1099 // std.log.debug("{s}\n", .{list2.items});1098 // std.log.debug("{s}\n", .{list2.items});
1100 const _type = base_obj.type;1099 const _type = base_obj.type;
1101 const content = try list2.toOwnedSlice(r.gpa);1100 const content = try list2.toOwnedSlice(r.gpa);