authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-05-04 20:32:48 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-05-04 20:32:48 -07:00
log8cac0cbd46ecdd17bc76b3e136724e2b67f5d55b
tree71fe5ab61c0c8459eaeb7947d62ea065374d1cdc
parent259015937048a1ff820ded783ab65376b8f79f4b

handle binary file diffs better


1 files changed, 14 insertions(+), 1 deletions(-)

git.zig+14-1
......@@ -312,13 +312,17 @@ pub fn parseTreeDiffMeta(input: string) !TreeDiffMeta {
312312 'd' => continue, // diff --git a/src/Sema.zig b/src/Sema.zig
313313 // deleted file mode 100644
314314 'n' => continue, // new file mode 100644
315 'B' => continue, // Binary files a/stage1/zig1.wasm and b/stage1/zig1.wasm differ
316315 'i' => continue, // index 327ff3800..df199be97 100644
317316 '@' => continue, // @@ -24629,10 +24634,11 @@
318317 ' ' => continue,
319318 '+' => result.lines_added += 1,
320319 '-' => result.lines_removed += 1,
321320 '\\' => continue, // \ No newline at end of file
321 'B' => {
322 // Binary files a/stage1/zig1.wasm and b/stage1/zig1.wasm differ
323 result.lines_added += 1;
324 result.lines_removed += 1;
325 },
322326 else => {
323327 std.log.err("{s}", .{lin});
324328 std.log.err("{s}", .{input});
......@@ -397,6 +401,15 @@ pub fn parseTreeDiff(alloc: std.mem.Allocator, input: string) !TreeDiff {
397401 }
398402
399403 const before_path_raw = lineiter.next().?;
404 if (std.mem.startsWith(u8, before_path_raw, "Binary files")) {
405 try diffs.append(.{
406 .before_path = overview.items[diffs.items.len].sub_path,
407 .after_path = overview.items[diffs.items.len].sub_path,
408 .content = before_path_raw,
409 });
410 _ = lineiter.index orelse break :blk;
411 continue :blk;
412 }
400413 const before_path = extras.trimPrefixEnsure(before_path_raw, "--- a/") orelse extras.trimPrefixEnsure(before_path_raw, "--- ").?;
401414
402415 const after_path_raw = lineiter.next().?;