fix: branch assumes git file will be correctly formated

This commit is contained in:
shadmansaleh 2021-08-25 12:18:47 +06:00 committed by Shadman
parent 1cbf0686b4
commit fa1f001207
1 changed files with 7 additions and 5 deletions

View File

@ -62,14 +62,16 @@ function Branch.find_git_dir()
git_dir = git_dir:match('gitdir: (.+)$')
file:close()
-- submodule / relative file path
if git_dir:sub(1, 1) ~= Branch.sep and not git_dir:match('^%a:.*$') then
if git_dir and git_dir:sub(1, 1) ~= Branch.sep and not git_dir:match('^%a:.*$') then
git_dir = git_path:match('(.*).git') .. git_dir
end
end
local head_file_stat = vim.loop.fs_stat(git_dir..Branch.sep..'HEAD')
if head_file_stat and head_file_stat.type == 'file' then
break
else git_dir = nil end
if git_dir then
local head_file_stat = vim.loop.fs_stat(git_dir..Branch.sep..'HEAD')
if head_file_stat and head_file_stat.type == 'file' then
break
else git_dir = nil end
end
end
root_dir = root_dir:match('(.*)'..Branch.sep..'.-')
end