diff --git a/git.zig b/git.zig index 85eec0284d7a401c0460bb9b7d2f97765eec786e..33828b7e4226836cf00ac470778e4e45b235d48e 100644 --- a/git.zig +++ b/git.zig @@ -518,6 +518,8 @@ pub fn parseTreeDiff(alloc: std.mem.Allocator, input: string) !TreeDiff { }, .action = std.meta.stringToEnum(TreeDiff.Action, action_s).?, .sub_path = kter.rest(), + .adds = 0, + .subs = 0, }); } @@ -581,18 +583,24 @@ pub fn parseTreeDiff(alloc: std.mem.Allocator, input: string) !TreeDiff { while (lineiter.next()) |lin| { if (std.mem.startsWith(u8, lin, "diff --git")) { const end_index = lineiter.index.? - lin.len - 2; + const content = input[start_index..end_index]; + overview.items[diffs.items.len].adds = @intCast(std.mem.count(u8, content, "\n+")); + overview.items[diffs.items.len].subs = @intCast(std.mem.count(u8, content, "\n-")); try diffs.append(.{ .before_path = before_path, .after_path = after_path, - .content = input[start_index..end_index], + .content = content, }); continue :blk; } } + const content = input[start_index..]; + overview.items[diffs.items.len].adds = @intCast(std.mem.count(u8, content, "\n+")); + overview.items[diffs.items.len].subs = @intCast(std.mem.count(u8, content, "\n-")); try diffs.append(.{ .before_path = before_path, .after_path = after_path, - .content = input[start_index..], + .content = content, }); break :blk; } @@ -612,6 +620,8 @@ pub const TreeDiff = struct { after: State, action: Action, sub_path: string, + adds: u16, + subs: u16, }; pub const State = struct {