perf(git): fold revspec validation into the cat-file -p the loader needs anyway

This commit is contained in:
2026-04-29 09:53:48 +02:00
parent 5c5da7a854
commit 590651e9d8
3 changed files with 42 additions and 28 deletions
-14
View File
@@ -343,18 +343,4 @@ function M.rev_parse(worktree, ref, short)
return trimmed ~= "" and trimmed or nil
end
---Verify a revspec resolves to an existing git object. `cat-file -e` is
---git's cheapest existence check, and unlike `rev-parse --verify` it
---also accepts the `<commit>:<path>` form that BufReadCmd revspec URIs
---use.
---@param worktree string
---@param revspec string
---@return boolean
function M.object_exists(worktree, revspec)
return util.exec(
{ "git", "cat-file", "-e", revspec },
{ cwd = worktree, silent = true }
) ~= nil
end
return M