authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-05-08 04:25:14 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-05-08 04:25:14 -07:00
log803c0cd0c72c3db01885a3706d67499f9679c87f
tree367850ae6e3bfee05ec88504299bd97208434380
parent0388abb98856ee28b48571e5ab36911f4d53a5b7

parseTreeDiff: print line when parsing fails


1 files changed, 7 insertions(+), 2 deletions(-)

git.zig+7-2
......@@ -428,6 +428,11 @@ pub fn parseTreeDiff(alloc: std.mem.Allocator, input: string) !TreeDiff {
428428 blk: while (true) {
429429 while (lineiter.next()) |lin| {
430430 if (std.mem.startsWith(u8, lin, "index")) break;
431 if (std.mem.startsWith(u8, lin, "new file mode")) continue;
432 if (std.mem.startsWith(u8, lin, "deleted file mode")) continue;
433
434 std.log.err("{s}", .{lin});
435 unreachable;
431436 }
432437
433438 const before_path_raw = lineiter.next().?;
......@@ -440,10 +445,10 @@ pub fn parseTreeDiff(alloc: std.mem.Allocator, input: string) !TreeDiff {
440445 _ = lineiter.index orelse break :blk;
441446 continue :blk;
442447 }
443 const before_path = extras.trimPrefixEnsure(before_path_raw, "--- a/") orelse extras.trimPrefixEnsure(before_path_raw, "--- ").?;
448 const before_path = extras.trimPrefixEnsure(before_path_raw, "--- a/") orelse extras.trimPrefixEnsure(before_path_raw, "--- ") orelse @panic(before_path_raw);
444449
445450 const after_path_raw = lineiter.next().?;
446 const after_path = extras.trimPrefixEnsure(after_path_raw, "+++ b/") orelse extras.trimPrefixEnsure(after_path_raw, "+++ ").?;
451 const after_path = extras.trimPrefixEnsure(after_path_raw, "+++ b/") orelse extras.trimPrefixEnsure(after_path_raw, "+++ ") orelse @panic(after_path_raw);
447452
448453 const start_index = lineiter.index.?;
449454