| ... | ... | @@ -41,14 +41,14 @@ pub const TagId = struct { |
| 41 | 41 | } |
| 42 | 42 | }; |
| 43 | 43 | |
| 44 | | pub const OidKind = enum { |
| 44 | pub const RefType = enum { |
| 45 | 45 | blob, |
| 46 | 46 | tree, |
| 47 | 47 | commit, |
| 48 | 48 | tag, |
| 49 | 49 | }; |
| 50 | 50 | |
| 51 | | pub const AnyId = union(OidKind) { |
| 51 | pub const AnyId = union(RefType) { |
| 52 | 52 | blob: BlobId, |
| 53 | 53 | tree: TreeId, |
| 54 | 54 | commit: CommitId, |
| ... | ... | @@ -159,7 +159,7 @@ pub fn getObjectSize(alloc: std.mem.Allocator, dir: nfs.Dir, obj: Id) !u64 { |
| 159 | 159 | // TODO make this inspect .git manually |
| 160 | 160 | // https://git-scm.com/book/en/v2/Git-Internals-Git-Objects |
| 161 | 161 | // https://git-scm.com/book/en/v2/Git-Internals-Packfiles |
| 162 | | pub fn isType(alloc: std.mem.Allocator, dir: nfs.Dir, maybeobj: Id, typ: OidKind) !bool { |
| 162 | pub fn isType(alloc: std.mem.Allocator, dir: nfs.Dir, maybeobj: Id, typ: RefType) !bool { |
| 163 | 163 | const t = tracer.trace(@src(), " {s} = {s} ?", .{ maybeobj, @tagName(typ) }); |
| 164 | 164 | defer t.end(); |
| 165 | 165 | |
| ... | ... | @@ -170,13 +170,13 @@ pub fn isType(alloc: std.mem.Allocator, dir: nfs.Dir, maybeobj: Id, typ: OidKind |
| 170 | 170 | }); |
| 171 | 171 | std.debug.assert(result.term == .Exited and result.term.Exited == 0); |
| 172 | 172 | const output = std.mem.trimRight(u8, result.stdout, "\n"); |
| 173 | | return std.meta.stringToEnum(OidKind, output).? == typ; |
| 173 | return std.meta.stringToEnum(RefType, output).? == typ; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | // TODO make this inspect .git manually |
| 177 | 177 | // https://git-scm.com/book/en/v2/Git-Internals-Git-Objects |
| 178 | 178 | // https://git-scm.com/book/en/v2/Git-Internals-Packfiles |
| 179 | | pub fn getType(alloc: std.mem.Allocator, dir: nfs.Dir, obj: Id) !OidKind { |
| 179 | pub fn getType(alloc: std.mem.Allocator, dir: nfs.Dir, obj: Id) !RefType { |
| 180 | 180 | const t = tracer.trace(@src(), " {s}", .{obj}); |
| 181 | 181 | defer t.end(); |
| 182 | 182 | |
| ... | ... | @@ -187,7 +187,7 @@ pub fn getType(alloc: std.mem.Allocator, dir: nfs.Dir, obj: Id) !OidKind { |
| 187 | 187 | }); |
| 188 | 188 | std.debug.assert(result.term == .Exited and result.term.Exited == 0); |
| 189 | 189 | const output = std.mem.trimRight(u8, result.stdout, "\n"); |
| 190 | | return std.meta.stringToEnum(OidKind, output) orelse @panic(output); |
| 190 | return std.meta.stringToEnum(RefType, output) orelse @panic(output); |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | // TODO make this inspect .git/objects manually |
| ... | ... | @@ -331,7 +331,7 @@ pub fn parseTree(alloc: std.mem.Allocator, treefile: string) !Tree { |
| 331 | 331 | } |
| 332 | 332 | var jter = std.mem.splitScalar(u8, line, ' '); |
| 333 | 333 | const mode = jter.next().?; |
| 334 | | const otype = std.meta.stringToEnum(OidKind, jter.next().?).?; |
| 334 | const otype = std.meta.stringToEnum(RefType, jter.next().?).?; |
| 335 | 335 | const id_and_name = jter.rest(); |
| 336 | 336 | const tab_pos = std.mem.indexOfScalar(u8, id_and_name, '\t').?; // why git. why. |
| 337 | 337 | std.debug.assert(tab_pos == 40); |
| ... | ... | @@ -844,7 +844,7 @@ pub fn parseTag(tagfile: string) !Tag { |
| 844 | 844 | std.debug.assert(object.len == 40); |
| 845 | 845 | result.object = object[0..40]; |
| 846 | 846 | const ty = extras.trimPrefixEnsure(iter.next().?, "type ").?; |
| 847 | | result.type = std.meta.stringToEnum(OidKind, ty).?; |
| 847 | result.type = std.meta.stringToEnum(RefType, ty).?; |
| 848 | 848 | const tag = extras.trimPrefixEnsure(iter.next().?, "tag ").?; |
| 849 | 849 | _ = tag; |
| 850 | 850 | |
| ... | ... | @@ -861,7 +861,7 @@ pub fn parseTag(tagfile: string) !Tag { |
| 861 | 861 | |
| 862 | 862 | pub const Tag = struct { |
| 863 | 863 | object: Id, |
| 864 | | type: OidKind, |
| 864 | type: RefType, |
| 865 | 865 | tagger: ?UserAndAt, |
| 866 | 866 | message: string, |
| 867 | 867 | }; |
| ... | ... | @@ -1156,13 +1156,6 @@ pub const Repository = struct { |
| 1156 | 1156 | return null; |
| 1157 | 1157 | } |
| 1158 | 1158 | |
| 1159 | | const RefType = enum { |
| 1160 | | blob, |
| 1161 | | tree, |
| 1162 | | commit, |
| 1163 | | tag, |
| 1164 | | }; |
| 1165 | | |
| 1166 | 1159 | const GitObject = struct { |
| 1167 | 1160 | type: RefType, |
| 1168 | 1161 | content: []const u8, |