authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2025-06-23 01:20:32 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2025-06-23 01:20:32 -07:00
log39da44aebc515c2dfb10d78f54a48bed85444196
tree157407d2d062377b715a55396bac222a7733d50e
parent12a2aa9ae3b958fc59f19271a4cfdd947158e4cc

don't crash on trees with files with spaces in the name


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

git.zig+1-2
...@@ -270,8 +270,7 @@ pub fn parseTree(alloc: std.mem.Allocator, treefile: string) !Tree {...@@ -270,8 +270,7 @@ pub fn parseTree(alloc: std.mem.Allocator, treefile: string) !Tree {
270 var jter = std.mem.splitScalar(u8, line, ' ');270 var jter = std.mem.splitScalar(u8, line, ' ');
271 const mode = jter.next().?;271 const mode = jter.next().?;
272 const otype = std.meta.stringToEnum(Tree.Object.Id.Tag, jter.next().?).?;272 const otype = std.meta.stringToEnum(Tree.Object.Id.Tag, jter.next().?).?;
273 const id_and_name = jter.next().?;273 const id_and_name = jter.rest();
274 std.debug.assert(jter.next() == null);
275 const tab_pos = std.mem.indexOfScalar(u8, id_and_name, '\t').?; // why git. why.274 const tab_pos = std.mem.indexOfScalar(u8, id_and_name, '\t').?; // why git. why.
276 std.debug.assert(tab_pos == 40);275 std.debug.assert(tab_pos == 40);
277 const id = id_and_name[0..tab_pos][0..40];276 const id = id_and_name[0..tab_pos][0..40];