chore(git): consistent error reporting on git failures

This commit is contained in:
2026-04-27 13:33:09 +02:00
parent 20dc6cc3c9
commit 6e0e05ae56
5 changed files with 81 additions and 14 deletions
+17 -8
View File
@@ -20,15 +20,17 @@ local cached_cmds
---@param result vim.SystemCompleted
local function populate_cached_cmds(result)
cached_cmds = {}
if result.code == 0 then
for line in (result.stdout or ""):gmatch("[^\r\n]+") do
if line ~= "" then
table.insert(cached_cmds, line)
end
end
table.sort(cached_cmds)
if result.code ~= 0 then
log.error("git --list-cmds failed: %s", vim.trim(result.stderr or ""))
return
end
cached_cmds = {}
for line in (result.stdout or ""):gmatch("[^\r\n]+") do
if line ~= "" then
table.insert(cached_cmds, line)
end
end
table.sort(cached_cmds)
end
---Prime `cached_cmds` asynchronously so the first `:G <Tab>` doesn't block.
@@ -111,6 +113,13 @@ local function run_in_split(worktree, args, conf)
vim.api.nvim_buf_set_lines(buf, 0, -1, false, split_lines(content))
vim.bo[buf].modifiable = false
vim.bo[buf].modified = false
if obj.code ~= 0 then
log.error(
"git %s failed: %s",
args[1] or "",
vim.trim(obj.stderr or "")
)
end
end)
end)
end