From 2a81c50156efbda8df415e96188f29cb42ef4ec5 Mon Sep 17 00:00:00 2001 From: Oscar Wallberg Date: Wed, 6 May 2026 01:33:39 +0200 Subject: [PATCH] fix: convert some warnings to errors --- lua/git/cmd.lua | 2 +- lua/git/commit.lua | 2 +- lua/git/diff.lua | 20 ++++++++++---------- lua/git/log_view.lua | 2 +- lua/git/object.lua | 8 ++++---- lua/git/repo.lua | 8 ++++---- lua/pack.lua | 4 ++-- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lua/git/cmd.lua b/lua/git/cmd.lua index 2f7720f..556082b 100644 --- a/lua/git/cmd.lua +++ b/lua/git/cmd.lua @@ -180,7 +180,7 @@ end function M.run(args) local r = repo.resolve() if not r then - util.warning("not in a git repository") + util.error("not in a git repository") return end diff --git a/lua/git/commit.lua b/lua/git/commit.lua index c929c30..407e80c 100644 --- a/lua/git/commit.lua +++ b/lua/git/commit.lua @@ -9,7 +9,7 @@ function M.commit(opts) local amend = opts and opts.amend or false local r = repo.resolve() if not r then - util.warning("not in a git repository") + util.error("not in a git repository") return end diff --git a/lua/git/diff.lua b/lua/git/diff.lua index b0e9889..d54585f 100644 --- a/lua/git/diff.lua +++ b/lua/git/diff.lua @@ -72,11 +72,11 @@ end local function uri_split(opts, buf, rev) local r = repo.resolve(buf) if not r then - util.warning("git URI buffer has no worktree") + util.error("git URI buffer has no worktree") return end 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 end local object = require("git.object") @@ -87,7 +87,7 @@ local function uri_split(opts, buf, rev) { cwd = r.worktree, silent = true } ) if not content then - util.warning("invalid rev: %s", opts.rev) + util.error("invalid rev: %s", opts.rev) return end place_pair( @@ -102,7 +102,7 @@ local function uri_split(opts, buf, rev) if not opts.rev then local worktree_path = vim.fs.joinpath(r.worktree, rev.path) 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 end local worktree_buf = vim.fn.bufadd(worktree_path) @@ -112,7 +112,7 @@ local function uri_split(opts, buf, rev) end if rev.stage == 1 then - util.warning("gD on merge base is ambiguous, use :Gdiffsplit ") + util.error("gD on merge base is ambiguous, use :Gdiffsplit ") return end @@ -129,7 +129,7 @@ local function uri_split(opts, buf, rev) { cwd = r.worktree, silent = true } ) if not content then - util.warning("invalid rev: %s", other_rev:format()) + util.error("invalid rev: %s", other_rev:format()) return end place_pair(buf, object.buf_for(r, other_rev, content), left, opts.vertical) @@ -150,17 +150,17 @@ function M.split(opts) end if cur_path == "" then - util.warning("no file in current buffer") + util.error("no file in current buffer") return end 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 end cur_path = vim.fn.resolve(cur_path) local r = repo.resolve(cur_path) if not r then - util.warning("not in a git repository") + util.error("not in a git repository") return end local rel = vim.fs.relpath(r.worktree, cur_path) @@ -178,7 +178,7 @@ function M.split(opts) { cwd = r.worktree, silent = true } ) if not content then - util.warning("invalid rev: %s", rev:format()) + util.error("invalid rev: %s", rev:format()) return end local buf = require("git.object").buf_for(r, rev, content) diff --git a/lua/git/log_view.lua b/lua/git/log_view.lua index 1bd39a5..803dfbe 100644 --- a/lua/git/log_view.lua +++ b/lua/git/log_view.lua @@ -126,7 +126,7 @@ function M.open(opts) opts = opts or {} local r = repo.resolve() if not r then - util.warning("not in a git repository") + util.error("not in a git repository") return end diff --git a/lua/git/object.lua b/lua/git/object.lua index b9371fa..fab9ef4 100644 --- a/lua/git/object.lua +++ b/lua/git/object.lua @@ -268,7 +268,7 @@ end local function load_blob(r, blob, path, sha) local buf = blob_buf(r, blob, path, sha) 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 end vim.cmd.normal({ "m'", bang = true }) @@ -279,7 +279,7 @@ end ---@param section ow.Git.DiffSection local function open_section(s, section) 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 end local parent = s.parent_sha or "0" @@ -291,7 +291,7 @@ local function open_section(s, section) return end 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 end local buf = left or right @@ -319,7 +319,7 @@ function M.open(r, rev, opts) { cwd = r.worktree, silent = true } ) if not content then - util.warning("not a git object: %s", rev) + util.error("not a git object: %s", rev) return end local buf = M.buf_for(r, parsed, content) diff --git a/lua/git/repo.lua b/lua/git/repo.lua index db3b7d9..edb9f1c 100644 --- a/lua/git/repo.lua +++ b/lua/git/repo.lua @@ -56,7 +56,7 @@ function Repo:_fetch_status() { cwd = self.worktree, text = true }, vim.schedule_wrap(function(obj) if obj.code ~= 0 then - util.warning( + util.error( "git status failed: %s", vim.trim(obj.stderr or "") ) @@ -95,7 +95,7 @@ end function Repo:start_watcher() local watcher, err = vim.uv.new_fs_event() if not watcher then - util.warning( + util.error( "git: failed to create fs_event for %s: %s", self.gitdir, err @@ -117,7 +117,7 @@ function Repo:start_watcher() end ) 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() return end @@ -323,7 +323,7 @@ function M.resolve(arg) f:close() local rel = content:match("gitdir:%s*(%S+)") 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 end gitdir = vim.fs.normalize( diff --git a/lua/pack.lua b/lua/pack.lua index 6240605..884a27f 100644 --- a/lua/pack.lua +++ b/lua/pack.lua @@ -195,7 +195,7 @@ function M.watch() local w, err = vim.uv.new_fs_event() 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 end local on_change, handle = util.keyed_debounce( @@ -232,7 +232,7 @@ function M.watch() end ) 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() handle:close() return