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");...@@ -7,7 +7,7 @@ const tracer = @import("tracer");
7const nfs = @import("nfs");7const nfs = @import("nfs");
8const nio = @import("nio");8const nio = @import("nio");
99
10pub const Id = []const u8;10pub const Id = *const [40]u8;
1111
12pub const TreeId = struct {12pub const TreeId = struct {
13 id: Id,13 id: Id,
...@@ -99,7 +99,7 @@ pub fn getHEAD(alloc: std.mem.Allocator, dir: nfs.Dir) !?CommitId {...@@ -99,7 +99,7 @@ pub fn getHEAD(alloc: std.mem.Allocator, dir: nfs.Dir) !?CommitId {
99// 40 is length of sha1 hash99// 40 is length of sha1 hash
100pub fn ensureObjId(comptime T: type, input: string) T {100pub fn ensureObjId(comptime T: type, input: string) T {
101 extras.assertLog(input.len == 40, "ensureObjId: {s}", .{input});101 extras.assertLog(input.len == 40, "ensureObjId: {s}", .{input});
102 return .{ .id = input };102 return .{ .id = input[0..40] };
103}103}
104104
105// TODO make this inspect .git/objects105// TODO make this inspect .git/objects
...@@ -579,7 +579,7 @@ pub fn parseTreeDiff(alloc: std.mem.Allocator, input: string) !TreeDiff {...@@ -579,7 +579,7 @@ pub fn parseTreeDiff(alloc: std.mem.Allocator, input: string) !TreeDiff {
579 var n: usize = 0;579 var n: usize = 0;
580 while (n < i) : (n += 1) i -= @intFromBool(overview.items[n].action == .T);580 while (n < i) : (n += 1) i -= @intFromBool(overview.items[n].action == .T);
581 try diffs.append(.{581 try diffs.append(.{
582 .index = .{ "", "" },582 .index = @splat(.{ .id = undefined }),
583 .before_path = overview.items[i].sub_path,583 .before_path = overview.items[i].sub_path,
584 .after_path = overview.items[i].sub_path,584 .after_path = overview.items[i].sub_path,
585 .subs = 0,585 .subs = 0,
...@@ -596,10 +596,11 @@ pub fn parseTreeDiff(alloc: std.mem.Allocator, input: string) !TreeDiff {...@@ -596,10 +596,11 @@ pub fn parseTreeDiff(alloc: std.mem.Allocator, input: string) !TreeDiff {
596 if (std.mem.startsWith(u8, lin, "index")) {596 if (std.mem.startsWith(u8, lin, "index")) {
597 const index = lin[6..];597 const index = lin[6..];
598 var iiter = std.mem.splitSequence(u8, index, "..");598 var iiter = std.mem.splitSequence(u8, index, "..");
599 diff.index[0] = iiter.next().?;599 var xx: [2][]const u8 = .{ iiter.next().?, iiter.next().? };
600 diff.index[1] = iiter.next().?;
601 std.debug.assert(iiter.next() == null);600 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
604 lineiter.index.? += lin.len + 1;605 lineiter.index.? += lin.len + 1;
605 break;606 break;
...@@ -734,7 +735,7 @@ pub const TreeDiff = struct {...@@ -734,7 +735,7 @@ pub const TreeDiff = struct {
734 };735 };
735736
736 pub const Diff = struct {737 pub const Diff = struct {
737 index: [2][]const u8,738 index: [2]CommitId,
738 before_path: string,739 before_path: string,
739 after_path: string,740 after_path: string,
740 adds: u32,741 adds: u32,