authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-09-17 13:14:00 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-09-17 13:14:00 -07:00
logc19c852be7662588df137d5eace2ee2408f27863
treef6c7913d17696d0a45ac62da412fddf34ede1075
parentae6cf5fbe23993d09f9e99ed80fc6717f25f6317

util: git_rev_HEAD: fix behavior when HEAD is not a ref


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

src/util/funcs.zig+1
......@@ -233,6 +233,7 @@ pub fn do_hash(alloc: std.mem.Allocator, comptime algo: type, data: string) !str
233233pub fn git_rev_HEAD(alloc: std.mem.Allocator, dir: std.fs.Dir) !string {
234234 const dirg = try dir.openDir(".git", .{});
235235 const h = std.mem.trim(u8, try dirg.readFileAlloc(alloc, "HEAD", 50), "\n");
236 if (!std.mem.startsWith(u8, h, "ref:")) return h;
236237 const r = std.mem.trim(u8, try dirg.readFileAlloc(alloc, h[5..], 50), "\n");
237238 return r;
238239}