perf(git): minor performance cleanups

This commit is contained in:
2026-04-27 13:27:22 +02:00
parent 5966454462
commit 20dc6cc3c9
4 changed files with 51 additions and 30 deletions
+13 -17
View File
@@ -23,16 +23,20 @@ local function attach_index_writer(buf, worktree, path)
return
end
local sha = vim.trim(hash.stdout or "")
local mode = "100644"
local ls = vim.system(
{ "git", "ls-files", "-s", "--", path },
{ cwd = worktree, text = true }
):wait()
if ls.code == 0 and ls.stdout then
local m = ls.stdout:match("^(%d+)")
if m then
mode = m
local mode = vim.b[buf].git_index_mode
if not mode then
mode = "100644"
local ls = vim.system(
{ "git", "ls-files", "-s", "--", path },
{ cwd = worktree, text = true }
):wait()
if ls.code == 0 and ls.stdout then
local m = ls.stdout:match("^(%d+)")
if m then
mode = m
end
end
vim.b[buf].git_index_mode = mode
end
local upd = vim.system({
"git",
@@ -116,14 +120,6 @@ end
---@param abs_path string
---@return integer
function M.load_file_buf(abs_path)
for _, buf in ipairs(vim.api.nvim_list_bufs()) do
if
vim.api.nvim_buf_is_loaded(buf)
and vim.api.nvim_buf_get_name(buf) == abs_path
then
return buf
end
end
local buf = vim.fn.bufadd(abs_path)
vim.fn.bufload(buf)
return buf