chore(git): consistent error reporting on git failures
This commit is contained in:
+17
-8
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user