| ... | ... | @@ -11,7 +11,7 @@ pub const BlobId = struct { id: Id }; |
| 11 | 11 | /// Returns the result of running `git rev-parse HEAD` |
| 12 | 12 | /// dir must already be pointing at the .git folder |
| 13 | 13 | // TODO this doesnt handle when there are 0 commits |
| 14 | | pub fn getHEAD(alloc: std.mem.Allocator, dir: std.fs.Dir) !Id { |
| 14 | pub fn getHEAD(alloc: std.mem.Allocator, dir: std.fs.Dir) !CommitId { |
| 15 | 15 | const h = std.mem.trimRight(u8, try dir.readFileAlloc(alloc, "HEAD", 1024), "\n"); |
| 16 | 16 | |
| 17 | 17 | if (std.mem.startsWith(u8, h, "ref:")) { |
| ... | ... | @@ -34,12 +34,12 @@ pub fn getHEAD(alloc: std.mem.Allocator, dir: std.fs.Dir) !Id { |
| 34 | 34 | break :blk std.mem.trimRight(u8, try dir.readFileAlloc(alloc, h[5..], 1024), "\n"); |
| 35 | 35 | }; |
| 36 | 36 | std.debug.assert(r.len == 40); |
| 37 | | return r[0..40]; |
| 37 | return .{ .id = r[0..40] }; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | // content should be 40-char sha1 hash |
| 41 | 41 | std.debug.assert(h.len == 40); |
| 42 | | return h[0..40]; |
| 42 | return .{ .id = h[0..40] }; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | // TODO make this inspect .git/objects |