diff options
Diffstat (limited to 'src/diff.zig')
| -rw-r--r-- | src/diff.zig | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/diff.zig b/src/diff.zig index 842a6b41..ed54c149 100644 --- a/src/diff.zig +++ b/src/diff.zig @@ -405,14 +405,6 @@ pub fn targetAt(lines: []const []const u8, row: usize, continued_rows: bool) ?Ta const testing = std.testing; -fn splitLines(comptime text: []const u8) [std.mem.count(u8, text, "\n")][]const u8 { - @setEvalBranchQuota(100_000); - var out: [std.mem.count(u8, text, "\n")][]const u8 = undefined; - var it = std.mem.splitScalar(u8, text, '\n'); - for (&out) |*line| line.* = it.next().?; - return out; -} - const git_diff = \\diff --git a/src/a.zig b/src/a.zig \\index 1111111..2222222 100644 @@ -439,6 +431,22 @@ const git_diff = \\ ; +fn splitLines(comptime text: []const u8) [std.mem.count(u8, text, "\n")][]const u8 { + @setEvalBranchQuota(100_000); + var out: [std.mem.count(u8, text, "\n")][]const u8 = undefined; + var it = std.mem.splitScalar(u8, text, '\n'); + for (&out) |*line| line.* = it.next().?; + return out; +} + +fn pathsOf(comptime text: []const u8) ![3][]const u8 { + const lines = splitLines(text); + var w: Walk = .{}; + for (lines) |line| _ = w.step(line); + const t = targetAt(&lines, 3, false) orelse return error.NoTarget; + return .{ w.old_path, w.new_path, t.path }; +} + test "diff every line of a section that deletes its file is about a file this diff deletes" { const lines = splitLines(git_diff); var rows: usize = 0; @@ -623,14 +631,6 @@ test "diff git's side prefixes: dropped when both sides carry different ones, el try testing.expect(gitHeader("diff -u old new") == null); } -fn pathsOf(comptime text: []const u8) ![3][]const u8 { - const lines = splitLines(text); - var w: Walk = .{}; - for (lines) |line| _ = w.step(line); - const t = targetAt(&lines, 3, false) orelse return error.NoTarget; - return .{ w.old_path, w.new_path, t.path }; -} - test "diff a section's paths are the repository's names under every prefix git writes, and as written elsewhere" { const expect = struct { fn paths(got: [3][]const u8, old: []const u8, new: []const u8) !void { |
