authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-03-27 19:11:19 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-03-27 19:11:19 -07:00
log6763a8608ffdf2462f6678145ac8d76cc418ff32
tree87a9773be11e9ac5e827108c16d6eafa9569a489
parentc75fe7aa5991f5708500eeaa07210655e7a154de
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

make Id 40 char again


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

git.zig+8-7
......@@ -7,7 +7,7 @@ const tracer = @import("tracer");
77const nfs = @import("nfs");
88const nio = @import("nio");
99
10pub const Id = []const u8;
10pub const Id = *const [40]u8;
1111
1212pub const TreeId = struct {
1313 id: Id,
......@@ -99,7 +99,7 @@ pub fn getHEAD(alloc: std.mem.Allocator, dir: nfs.Dir) !?CommitId {
9999// 40 is length of sha1 hash
100100pub fn ensureObjId(comptime T: type, input: string) T {
101101 extras.assertLog(input.len == 40, "ensureObjId: {s}", .{input});
102 return .{ .id = input };
102 return .{ .id = input[0..40] };
103103}
104104
105105// TODO make this inspect .git/objects
......@@ -579,7 +579,7 @@ pub fn parseTreeDiff(alloc: std.mem.Allocator, input: string) !TreeDiff {
579579 var n: usize = 0;
580580 while (n < i) : (n += 1) i -= @intFromBool(overview.items[n].action == .T);
581581 try diffs.append(.{
582 .index = .{ "", "" },
582 .index = @splat(.{ .id = undefined }),
583583 .before_path = overview.items[i].sub_path,
584584 .after_path = overview.items[i].sub_path,
585585 .subs = 0,
......@@ -596,10 +596,11 @@ pub fn parseTreeDiff(alloc: std.mem.Allocator, input: string) !TreeDiff {
596596 if (std.mem.startsWith(u8, lin, "index")) {
597597 const index = lin[6..];
598598 var iiter = std.mem.splitSequence(u8, index, "..");
599 diff.index[0] = iiter.next().?;
600 diff.index[1] = iiter.next().?;
599 var xx: [2][]const u8 = .{ iiter.next().?, iiter.next().? };
601600 std.debug.assert(iiter.next() == null);
602 if (std.mem.indexOfScalar(u8, diff.index[1], ' ')) |j| diff.index[1] = diff.index[1][0..j];
601 if (std.mem.indexOfScalar(u8, xx[1], ' ')) |j| xx[1] = xx[1][0..j];
602 diff.index[0] = ensureObjId(CommitId, xx[0]);
603 diff.index[1] = ensureObjId(CommitId, xx[1]);
603604
604605 lineiter.index.? += lin.len + 1;
605606 break;
......@@ -734,7 +735,7 @@ pub const TreeDiff = struct {
734735 };
735736
736737 pub const Diff = struct {
737 index: [2][]const u8,
738 index: [2]CommitId,
738739 before_path: string,
739740 after_path: string,
740741 adds: u32,