refactor(git): consolidate sync subprocess pattern via util.system_sync

This commit is contained in:
2026-04-28 08:38:14 +02:00
parent d2633ae9c2
commit 4390b55dfe
5 changed files with 57 additions and 67 deletions
+3 -14
View File
@@ -152,13 +152,8 @@ function M.open_commit(worktree, ref, opts)
return
end
local result = vim.system(
{ "git", "show", ref },
{ cwd = worktree, text = true }
)
:wait()
if result.code ~= 0 then
log.error("git show %s failed: %s", ref, vim.trim(result.stderr or ""))
local stdout = util.system_sync({ "git", "show", ref }, { cwd = worktree })
if not stdout then
return
end
@@ -168,13 +163,7 @@ function M.open_commit(worktree, ref, opts)
vim.b[buf].git_ref = sha
vim.b[buf].git_parent_ref = parent
vim.bo[buf].modifiable = true
vim.api.nvim_buf_set_lines(
buf,
0,
-1,
false,
util.split_lines(result.stdout or "")
)
vim.api.nvim_buf_set_lines(buf, 0, -1, false, util.split_lines(stdout))
vim.bo[buf].modifiable = false
vim.bo[buf].modified = false
vim.bo[buf].filetype = "git"