From 17ee9ed4e078508c15a653f384c316ce016920a0 Mon Sep 17 00:00:00 2001 From: HumblePresent <60856003+HumblePresent@users.noreply.github.com> Date: Mon, 15 Aug 2022 01:58:37 -0500 Subject: [PATCH] fix: #21 accurately detect git-enabled parent directories --- lua/persisted/init.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/persisted/init.lua b/lua/persisted/init.lua index 1f9a2e4..80e27fe 100644 --- a/lua/persisted/init.lua +++ b/lua/persisted/init.lua @@ -55,7 +55,8 @@ end ---Get the current Git branch ---@return string local function get_branch() - local git_enabled = (vim.fn.isdirectory(vim.fn.getcwd() .. "/.git") == 1) + vim.fn.system([[git rev-parse 2> /dev/null]]) + local git_enabled = (vim.v.shell_error == 0) if config.options.use_git_branch and git_enabled then local branch = vim.fn.systemlist([[git rev-parse --abbrev-ref HEAD 2>/dev/null]])