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