From 8cac0cbd46ecdd17bc76b3e136724e2b67f5d55b Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Thu, 4 May 2023 20:32:48 -0700 Subject: [PATCH] handle binary file diffs better --- git.zig | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/git.zig b/git.zig index e3ecaa8480bf5b224babfb5a9acd24093658c89e..b4853360ec91fcad92922589f72245b78390b1ef 100644 --- a/git.zig +++ b/git.zig @@ -312,13 +312,17 @@ pub fn parseTreeDiffMeta(input: string) !TreeDiffMeta { 'd' => continue, // diff --git a/src/Sema.zig b/src/Sema.zig // deleted file mode 100644 'n' => continue, // new file mode 100644 - 'B' => continue, // Binary files a/stage1/zig1.wasm and b/stage1/zig1.wasm differ 'i' => continue, // index 327ff3800..df199be97 100644 '@' => continue, // @@ -24629,10 +24634,11 @@ ' ' => continue, '+' => result.lines_added += 1, '-' => result.lines_removed += 1, '\\' => continue, // \ No newline at end of file + 'B' => { + // Binary files a/stage1/zig1.wasm and b/stage1/zig1.wasm differ + result.lines_added += 1; + result.lines_removed += 1; + }, else => { std.log.err("{s}", .{lin}); std.log.err("{s}", .{input}); @@ -397,6 +401,15 @@ pub fn parseTreeDiff(alloc: std.mem.Allocator, input: string) !TreeDiff { } const before_path_raw = lineiter.next().?; + if (std.mem.startsWith(u8, before_path_raw, "Binary files")) { + try diffs.append(.{ + .before_path = overview.items[diffs.items.len].sub_path, + .after_path = overview.items[diffs.items.len].sub_path, + .content = before_path_raw, + }); + _ = lineiter.index orelse break :blk; + continue :blk; + } const before_path = extras.trimPrefixEnsure(before_path_raw, "--- a/") orelse extras.trimPrefixEnsure(before_path_raw, "--- ").?; const after_path_raw = lineiter.next().?; -- 2.54.0