feat(git): replace vim-fugitive with custom git module

This commit is contained in:
2026-04-27 12:41:38 +02:00
parent 5a3e39574d
commit f55d7ac11d
13 changed files with 837 additions and 145 deletions
+26
View File
@@ -274,12 +274,38 @@ local function head(path)
return nil
end
---Resolve a git revision to its object SHA. Returns nil if the ref can't be
---resolved (root-commit's `^`, blob's `^`, malformed ref, etc.). When `short`
---is true, the result is abbreviated via `core.abbrev` (auto-extended by git
---to keep the prefix unique in the current repo).
---@param worktree string
---@param ref string
---@param short? boolean
---@return string?
local function rev_parse(worktree, ref, short)
local cmd = { "git", "rev-parse", "--verify", "--quiet" }
if short then
table.insert(cmd, "--short")
end
table.insert(cmd, ref)
local result = vim.system(cmd, { cwd = worktree, text = true }):wait()
if result.code ~= 0 then
return nil
end
local sha = vim.trim(result.stdout or "")
if sha == "" then
return nil
end
return sha
end
return {
UNMERGED = UNMERGED,
head = head,
indicator = indicator,
refresh_buf = refresh_buf,
resolve = resolve,
rev_parse = rev_parse,
stop_all = stop_all,
unregister = unregister,
}