feat(git/repo): add Repo:head_sha for cached HEAD blob lookups
This commit is contained in:
@@ -143,6 +143,7 @@ function Repo:_invalidate(relpath)
|
||||
end
|
||||
if affects_resolve(relpath) then
|
||||
self:_clear_cache_prefix("resolve:")
|
||||
self:_clear_cache_prefix("head_blob:")
|
||||
end
|
||||
if relpath == "index" then
|
||||
self:_clear_cache_prefix("index:")
|
||||
@@ -605,6 +606,15 @@ function Repo:index_sha(rel)
|
||||
return sha or nil
|
||||
end
|
||||
|
||||
---@param rel string worktree-relative path
|
||||
---@return string?
|
||||
function Repo:head_sha(rel)
|
||||
local sha = self:get_cached("head_blob:" .. rel, function(self)
|
||||
return self:rev_parse("HEAD:" .. rel, false) or false
|
||||
end)
|
||||
return sha or nil
|
||||
end
|
||||
|
||||
---@alias ow.Git.Repo.ResolveStatus "ok"|"ambiguous"|"missing"
|
||||
|
||||
---@param abbrev string
|
||||
|
||||
Reference in New Issue
Block a user