fix: git rev-parse --show-superproject-working-tree return fatal: not a git repository (or any of the parent directories): .git when execute not in a git repo

This commit is contained in:
f
2021-11-21 10:51:23 +08:00
parent bcd111df61
commit 148d19ca7a

View File

@@ -27,7 +27,7 @@ local function project_root_dir()
-- try submodule first
local gitdir = fn.system('cd "' .. fn.expand('%:p:h') .. '" && git rev-parse --show-superproject-working-tree')
if gitdir ~= '' then
if gitdir ~= '' and fn.matchstr(gitdir, '^fatal:.*') == '' then
vim.o.shell = oldshell
return trim(gitdir)
end