From e6616e260b8ad17d4de0d0457af013a6f6dc51ad Mon Sep 17 00:00:00 2001 From: Oscar Wallberg Date: Fri, 29 May 2026 14:29:09 +0200 Subject: [PATCH] fix: warn for inapplicable git commands --- lua/git/cmd.lua | 2 +- lua/git/commit.lua | 2 +- lua/git/diffsplit.lua | 6 +++--- lua/git/log_view.lua | 2 +- lua/git/status_view.lua | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lua/git/cmd.lua b/lua/git/cmd.lua index e18ca3b..eeb9e23 100644 --- a/lua/git/cmd.lua +++ b/lua/git/cmd.lua @@ -465,7 +465,7 @@ end function M.run(args, opts) local r = repo.resolve() if not r then - util.error("not in a git repository") + util.warning("not in a git repository") return end diff --git a/lua/git/commit.lua b/lua/git/commit.lua index 79ace26..29ded3f 100644 --- a/lua/git/commit.lua +++ b/lua/git/commit.lua @@ -8,7 +8,7 @@ local M = {} function M.commit(opts) local r = repo.resolve() if not r then - util.error("not in a git repository") + util.warning("not in a git repository") return end diff --git a/lua/git/diffsplit.lua b/lua/git/diffsplit.lua index 6ba5688..1da6e9b 100644 --- a/lua/git/diffsplit.lua +++ b/lua/git/diffsplit.lua @@ -172,7 +172,7 @@ function M.open(opts) other, err = infer_other(cur_buf) end if not other then - util.error("%s", err or "no diff side") + util.warning("%s", err or "no diff side") return end local mods = layout_mods(opts.mods, opts.layout) @@ -197,12 +197,12 @@ function M.open_pair(old, new, opts) local cur_buf = vim.api.nvim_get_current_buf() local new_buf, err = buf_for_side(new, cur_buf) if not new_buf then - util.error("%s", err or "no new diff side") + util.warning("%s", err or "no new diff side") return end local old_name, _, old_err = resolve_side(old, cur_buf) if not old_name then - util.error("%s", old_err or "no old diff side") + util.warning("%s", old_err or "no old diff side") return end diff --git a/lua/git/log_view.lua b/lua/git/log_view.lua index 00944ee..0f81b8d 100644 --- a/lua/git/log_view.lua +++ b/lua/git/log_view.lua @@ -81,7 +81,7 @@ function M.open(opts) opts = opts or {} local r = repo.resolve() if not r then - util.error("not in a git repository") + util.warning("not in a git repository") return end diff --git a/lua/git/status_view.lua b/lua/git/status_view.lua index 162e4ff..ff17263 100644 --- a/lua/git/status_view.lua +++ b/lua/git/status_view.lua @@ -685,7 +685,7 @@ function M.open(opts) end local r = repo.resolve() if not r then - util.error("not in a git repository") + util.warning("not in a git repository") return end