fix: convert some warnings to errors

This commit is contained in:
2026-05-06 01:33:39 +02:00
parent c70d5dfce5
commit 2a81c50156
7 changed files with 23 additions and 23 deletions
+1 -1
View File
@@ -180,7 +180,7 @@ end
function M.run(args) function M.run(args)
local r = repo.resolve() local r = repo.resolve()
if not r then if not r then
util.warning("not in a git repository") util.error("not in a git repository")
return return
end end
+1 -1
View File
@@ -9,7 +9,7 @@ function M.commit(opts)
local amend = opts and opts.amend or false local amend = opts and opts.amend or false
local r = repo.resolve() local r = repo.resolve()
if not r then if not r then
util.warning("not in a git repository") util.error("not in a git repository")
return return
end end
+10 -10
View File
@@ -72,11 +72,11 @@ end
local function uri_split(opts, buf, rev) local function uri_split(opts, buf, rev)
local r = repo.resolve(buf) local r = repo.resolve(buf)
if not r then if not r then
util.warning("git URI buffer has no worktree") util.error("git URI buffer has no worktree")
return return
end end
if not rev.path then if not rev.path then
util.warning("git URI has no path, cannot diff against worktree") util.error("git URI has no path, cannot diff against worktree")
return return
end end
local object = require("git.object") local object = require("git.object")
@@ -87,7 +87,7 @@ local function uri_split(opts, buf, rev)
{ cwd = r.worktree, silent = true } { cwd = r.worktree, silent = true }
) )
if not content then if not content then
util.warning("invalid rev: %s", opts.rev) util.error("invalid rev: %s", opts.rev)
return return
end end
place_pair( place_pair(
@@ -102,7 +102,7 @@ local function uri_split(opts, buf, rev)
if not opts.rev then if not opts.rev then
local worktree_path = vim.fs.joinpath(r.worktree, rev.path) local worktree_path = vim.fs.joinpath(r.worktree, rev.path)
if not vim.uv.fs_stat(worktree_path) then if not vim.uv.fs_stat(worktree_path) then
util.warning("worktree file does not exist: %s", rev.path) util.error("worktree file does not exist: %s", rev.path)
return return
end end
local worktree_buf = vim.fn.bufadd(worktree_path) local worktree_buf = vim.fn.bufadd(worktree_path)
@@ -112,7 +112,7 @@ local function uri_split(opts, buf, rev)
end end
if rev.stage == 1 then if rev.stage == 1 then
util.warning("gD on merge base is ambiguous, use :Gdiffsplit <rev>") util.error("gD on merge base is ambiguous, use :Gdiffsplit <rev>")
return return
end end
@@ -129,7 +129,7 @@ local function uri_split(opts, buf, rev)
{ cwd = r.worktree, silent = true } { cwd = r.worktree, silent = true }
) )
if not content then if not content then
util.warning("invalid rev: %s", other_rev:format()) util.error("invalid rev: %s", other_rev:format())
return return
end end
place_pair(buf, object.buf_for(r, other_rev, content), left, opts.vertical) place_pair(buf, object.buf_for(r, other_rev, content), left, opts.vertical)
@@ -150,17 +150,17 @@ function M.split(opts)
end end
if cur_path == "" then if cur_path == "" then
util.warning("no file in current buffer") util.error("no file in current buffer")
return return
end end
if vim.bo[cur_buf].buftype ~= "" then if vim.bo[cur_buf].buftype ~= "" then
util.warning("cannot diff this buffer (not a worktree file)") util.error("cannot diff this buffer (not a worktree file)")
return return
end end
cur_path = vim.fn.resolve(cur_path) cur_path = vim.fn.resolve(cur_path)
local r = repo.resolve(cur_path) local r = repo.resolve(cur_path)
if not r then if not r then
util.warning("not in a git repository") util.error("not in a git repository")
return return
end end
local rel = vim.fs.relpath(r.worktree, cur_path) local rel = vim.fs.relpath(r.worktree, cur_path)
@@ -178,7 +178,7 @@ function M.split(opts)
{ cwd = r.worktree, silent = true } { cwd = r.worktree, silent = true }
) )
if not content then if not content then
util.warning("invalid rev: %s", rev:format()) util.error("invalid rev: %s", rev:format())
return return
end end
local buf = require("git.object").buf_for(r, rev, content) local buf = require("git.object").buf_for(r, rev, content)
+1 -1
View File
@@ -126,7 +126,7 @@ function M.open(opts)
opts = opts or {} opts = opts or {}
local r = repo.resolve() local r = repo.resolve()
if not r then if not r then
util.warning("not in a git repository") util.error("not in a git repository")
return return
end end
+4 -4
View File
@@ -268,7 +268,7 @@ end
local function load_blob(r, blob, path, sha) local function load_blob(r, blob, path, sha)
local buf = blob_buf(r, blob, path, sha) local buf = blob_buf(r, blob, path, sha)
if not buf then if not buf then
util.warning("no content for %s at %s", path, sha) util.error("no content for %s at %s", path, sha)
return return
end end
vim.cmd.normal({ "m'", bang = true }) vim.cmd.normal({ "m'", bang = true })
@@ -279,7 +279,7 @@ end
---@param section ow.Git.DiffSection ---@param section ow.Git.DiffSection
local function open_section(s, section) local function open_section(s, section)
if not section.blob_a or not section.blob_b then if not section.blob_a or not section.blob_b then
util.warning("no index line, cannot determine blob SHAs") util.error("no index line, cannot determine blob SHAs")
return return
end end
local parent = s.parent_sha or "0" local parent = s.parent_sha or "0"
@@ -291,7 +291,7 @@ local function open_section(s, section)
return return
end end
if not left and not right then if not left and not right then
util.warning("no content for %s", section.path_b) util.error("no content for %s", section.path_b)
return return
end end
local buf = left or right local buf = left or right
@@ -319,7 +319,7 @@ function M.open(r, rev, opts)
{ cwd = r.worktree, silent = true } { cwd = r.worktree, silent = true }
) )
if not content then if not content then
util.warning("not a git object: %s", rev) util.error("not a git object: %s", rev)
return return
end end
local buf = M.buf_for(r, parsed, content) local buf = M.buf_for(r, parsed, content)
+4 -4
View File
@@ -56,7 +56,7 @@ function Repo:_fetch_status()
{ cwd = self.worktree, text = true }, { cwd = self.worktree, text = true },
vim.schedule_wrap(function(obj) vim.schedule_wrap(function(obj)
if obj.code ~= 0 then if obj.code ~= 0 then
util.warning( util.error(
"git status failed: %s", "git status failed: %s",
vim.trim(obj.stderr or "") vim.trim(obj.stderr or "")
) )
@@ -95,7 +95,7 @@ end
function Repo:start_watcher() function Repo:start_watcher()
local watcher, err = vim.uv.new_fs_event() local watcher, err = vim.uv.new_fs_event()
if not watcher then if not watcher then
util.warning( util.error(
"git: failed to create fs_event for %s: %s", "git: failed to create fs_event for %s: %s",
self.gitdir, self.gitdir,
err err
@@ -117,7 +117,7 @@ function Repo:start_watcher()
end end
) )
if not ok then if not ok then
util.warning("failed to watch %s: %s", self.gitdir, tostring(start_err)) util.error("failed to watch %s: %s", self.gitdir, tostring(start_err))
watcher:close() watcher:close()
return return
end end
@@ -323,7 +323,7 @@ function M.resolve(arg)
f:close() f:close()
local rel = content:match("gitdir:%s*(%S+)") local rel = content:match("gitdir:%s*(%S+)")
if not rel then if not rel then
util.warning(".git file at %s has no `gitdir:` line", found) util.error(".git file at %s has no `gitdir:` line", found)
return nil return nil
end end
gitdir = vim.fs.normalize( gitdir = vim.fs.normalize(
+2 -2
View File
@@ -195,7 +195,7 @@ function M.watch()
local w, err = vim.uv.new_fs_event() local w, err = vim.uv.new_fs_event()
if not w then if not w then
util.warning("pack: failed to create fs_event: %s", err) util.error("pack: failed to create fs_event: %s", err)
return return
end end
local on_change, handle = util.keyed_debounce( local on_change, handle = util.keyed_debounce(
@@ -232,7 +232,7 @@ function M.watch()
end end
) )
if not ok then if not ok then
util.warning("pack: failed to watch %s: %s", plugins_dir, err) util.error("pack: failed to watch %s: %s", plugins_dir, err)
w:close() w:close()
handle:close() handle:close()
return return