| ... | @@ -7,7 +7,7 @@ const tracer = @import("tracer"); | ... | @@ -7,7 +7,7 @@ const tracer = @import("tracer"); |
| 7 | const nfs = @import("nfs"); | 7 | const nfs = @import("nfs"); |
| 8 | const nio = @import("nio"); | 8 | const nio = @import("nio"); |
| 9 | | 9 | |
| 10 | pub const Id = []const u8; | 10 | pub const Id = *const [40]u8; |
| 11 | | 11 | |
| 12 | pub const TreeId = struct { | 12 | pub 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 hash | 99 | // 40 is length of sha1 hash |
| 100 | pub fn ensureObjId(comptime T: type, input: string) T { | 100 | pub 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 | } |
| 104 | | 104 | |
| 105 | // TODO make this inspect .git/objects | 105 | // 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]); |
| 603 | | 604 | |
| 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 | }; |
| 735 | | 736 | |
| 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, |