authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2025-01-31 13:35:35 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2025-01-31 13:35:35 -08:00
log174944517fd98f8831c5f5aa9738f880fe00ac4d
treef6651db1f8aad31a813ea02cae5a6747d1157dea
parentc72a3e29f201a301452f16ae323e168c8fbed13e

remove optional from isType return


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

git.zig+3-3
...@@ -134,7 +134,7 @@ pub fn getObjectSize(alloc: std.mem.Allocator, dir: std.fs.Dir, obj: Id) !u64 {...@@ -134,7 +134,7 @@ pub fn getObjectSize(alloc: std.mem.Allocator, dir: std.fs.Dir, obj: Id) !u64 {
134// TODO make this inspect .git manually134// TODO make this inspect .git manually
135// https://git-scm.com/book/en/v2/Git-Internals-Git-Objects135// https://git-scm.com/book/en/v2/Git-Internals-Git-Objects
136// https://git-scm.com/book/en/v2/Git-Internals-Packfiles136// https://git-scm.com/book/en/v2/Git-Internals-Packfiles
137pub fn isType(alloc: std.mem.Allocator, dir: std.fs.Dir, maybeobj: Id, typ: Tree.Object.Id.Tag) !?bool {137pub fn isType(alloc: std.mem.Allocator, dir: std.fs.Dir, maybeobj: Id, typ: Tree.Object.Id.Tag) !bool {
138 const t = tracer.trace(@src(), " {s} = {s} ?", .{ maybeobj, @tagName(typ) });138 const t = tracer.trace(@src(), " {s} = {s} ?", .{ maybeobj, @tagName(typ) });
139 defer t.end();139 defer t.end();
140140
...@@ -143,7 +143,7 @@ pub fn isType(alloc: std.mem.Allocator, dir: std.fs.Dir, maybeobj: Id, typ: Tree...@@ -143,7 +143,7 @@ pub fn isType(alloc: std.mem.Allocator, dir: std.fs.Dir, maybeobj: Id, typ: Tree
143 .cwd_dir = dir,143 .cwd_dir = dir,
144 .argv = &.{ "git", "cat-file", "-t", maybeobj },144 .argv = &.{ "git", "cat-file", "-t", maybeobj },
145 });145 });
146 if (result.term != .Exited or result.term.Exited != 0) return null;146 std.debug.assert(result.term == .Exited and result.term.Exited == 0);
147 const output = std.mem.trimRight(u8, result.stdout, "\n");147 const output = std.mem.trimRight(u8, result.stdout, "\n");
148 return std.meta.stringToEnum(Tree.Object.Id.Tag, output).? == typ;148 return std.meta.stringToEnum(Tree.Object.Id.Tag, output).? == typ;
149}149}
...@@ -739,7 +739,7 @@ pub fn getTags(alloc: std.mem.Allocator, dir: std.fs.Dir) ![]const Ref {...@@ -739,7 +739,7 @@ pub fn getTags(alloc: std.mem.Allocator, dir: std.fs.Dir) ![]const Ref {
739 extras.assertLog(std.mem.endsWith(u8, label2, "^{}"), "{s}", .{label2});739 extras.assertLog(std.mem.endsWith(u8, label2, "^{}"), "{s}", .{label2});
740 std.debug.assert(std.mem.eql(u8, label, extras.trimSuffixEnsure(label2, "^{}").?));740 std.debug.assert(std.mem.eql(u8, label, extras.trimSuffixEnsure(label2, "^{}").?));
741 // extras.assertLog(try isType(alloc, dir, id2, .commit), id2); // linux kernel has a single tag that points at a tree741 // extras.assertLog(try isType(alloc, dir, id2, .commit), id2); // linux kernel has a single tag that points at a tree
742 if (!(try isType(alloc, dir, id2, .commit)).?) continue;742 if (!try isType(alloc, dir, id2, .commit)) continue;
743743
744 try list.append(Ref{744 try list.append(Ref{
745 .label = label,745 .label = label,