feat(git): per-key cache invalidation and optional submodule tracking

This commit is contained in:
2026-05-19 09:50:31 +02:00
parent c66b2f04d2
commit 5f956401c1
7 changed files with 611 additions and 69 deletions
+43
View File
@@ -274,6 +274,49 @@ local function strip_dir_slash(path)
return path
end
---@param a ow.Git.Status.Entry?
---@param b ow.Git.Status.Entry?
---@return boolean
function M.entry_equal(a, b)
if a == nil or b == nil then
return a == b
end
if a.kind ~= b.kind or a.path ~= b.path then
return false
end
if a.kind == "changed" then
---@cast a ow.Git.Status.ChangedEntry
---@cast b ow.Git.Status.ChangedEntry
return a.staged == b.staged
and a.unstaged == b.unstaged
and a.orig == b.orig
end
if a.kind == "unmerged" then
---@cast a ow.Git.Status.UnmergedEntry
---@cast b ow.Git.Status.UnmergedEntry
return a.conflict == b.conflict
end
return true
end
---@param prior table<string, ow.Git.Status.Entry>
---@param next_ table<string, ow.Git.Status.Entry>
---@return table<string, true>
function M.diff_entries(prior, next_)
local paths = {}
for path, entry in pairs(next_) do
if not M.entry_equal(prior[path], entry) then
paths[path] = true
end
end
for path in pairs(prior) do
if next_[path] == nil then
paths[path] = true
end
end
return paths
end
---@param stdout string
---@return ow.Git.Status
function M.parse(stdout)