diff --git a/lua/persistence/init.lua b/lua/persistence/init.lua index 1acf0b1..7d1f502 100644 --- a/lua/persistence/init.lua +++ b/lua/persistence/init.lua @@ -120,7 +120,10 @@ end --- get current branch name ---@return string? function M.branch() - return vim.fn.systemlist("git branch --show-current")[1] + if uv.fs_stat(".git") then + local ret = vim.fn.systemlist("git branch --show-current")[1] + return vim.v.shell_error == 0 and ret or nil + end end return M