fix: #21 accurately detect git-enabled parent directories

main
HumblePresent 2022-08-15 01:58:37 -05:00 committed by GitHub
parent 06023617d7
commit 17ee9ed4e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -55,7 +55,8 @@ end
---Get the current Git branch ---Get the current Git branch
---@return string ---@return string
local function get_branch() 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 if config.options.use_git_branch and git_enabled then
local branch = vim.fn.systemlist([[git rev-parse --abbrev-ref HEAD 2>/dev/null]]) local branch = vim.fn.systemlist([[git rev-parse --abbrev-ref HEAD 2>/dev/null]])