refactor(git): consolidate sync subprocess pattern via util.system_sync
This commit is contained in:
+3
-14
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user