Merge pull request #48 from UzimakiNaruto/fix-git-rev-not-in-a-git-repo

Fix git rev path check when execute not in a git repo
This commit is contained in:
Dheepak Krishnamurthy
2021-11-21 07:10:22 -07:00
committed by GitHub

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
@@ -165,6 +165,10 @@ local function lazygit(path)
if path == nil then
path = project_root_dir()
end
if path == nil or fn.isdirectory(path .. '/.git/') == 0 then
print('Not in a git repository')
return
end
open_floating_window()
local cmd = 'lazygit'
if not vim.env.GIT_DIR then