authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2025-01-31 13:32:47 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2025-01-31 13:32:47 -08:00
log9fbcc8ce4944dba742296f1e42788bbf1e82be7a
tree858bfccb3b1fa610eceb05d6007edeb4a3b82b81
parent191ba7cdb755536c0eb83e01715a6552db6189bc

add eql methods to the ids


1 files changed, 32 insertions(+), 4 deletions(-)

git.zig+32-4
......@@ -7,10 +7,38 @@ const tracer = @import("tracer");
77
88// 40 is length of sha1 hash
99pub const Id = *const [40]u8;
10pub const TreeId = struct { id: Id };
11pub const CommitId = struct { id: Id };
12pub const BlobId = struct { id: Id };
13pub const TagId = struct { id: Id };
10
11pub const TreeId = struct {
12 id: Id,
13
14 pub fn eql(self: TreeId, other: TreeId) bool {
15 return std.mem.eql(u8, self.id, other.id);
16 }
17};
18
19pub const CommitId = struct {
20 id: Id,
21
22 pub fn eql(self: CommitId, other: CommitId) bool {
23 return std.mem.eql(u8, self.id, other.id);
24 }
25};
26
27pub const BlobId = struct {
28 id: Id,
29
30 pub fn eql(self: BlobId, other: BlobId) bool {
31 return std.mem.eql(u8, self.id, other.id);
32 }
33};
34
35pub const TagId = struct {
36 id: Id,
37
38 pub fn eql(self: TagId, other: TagId) bool {
39 return std.mem.eql(u8, self.id, other.id);
40 }
41};
1442
1543pub fn version(alloc: std.mem.Allocator) !string {
1644 const result = try std.process.Child.run(.{