fixup: error on branch component when stray .git files exist

fixes #490
This commit is contained in:
shadmansaleh 2021-12-25 16:13:39 +06:00
parent afaa540333
commit 9e26823ea6
2 changed files with 6 additions and 4 deletions

View File

@ -347,7 +347,7 @@ in component.
theme = 'auto', -- lualine theme
component_separators = {left = '', right = ''},
section_separators = {left = '', right = ''},
disabled_filetypes = {}, -- filetypes to diable lualine on
disabled_filetypes = {}, -- filetypes to disable lualine on
always_divide_middle = true, -- When true left_sections (a,b,c) can't
-- take over entiee statusline even
-- when none of section x, y, z is present.

View File

@ -78,9 +78,11 @@ function M.find_git_dir(dir_path)
elseif git_file_stat.type == 'file' then
-- separate git-dir or submodule is used
local file = io.open(git_path)
git_dir = file:read()
git_dir = git_dir:match 'gitdir: (.+)$'
file:close()
if file then
git_dir = file:read()
git_dir = git_dir and git_dir:match 'gitdir: (.+)$'
file:close()
end
-- submodule / relative file path
if git_dir and git_dir:sub(1, 1) ~= sep and not git_dir:match '^%a:.*$' then
git_dir = git_path:match '(.*).git' .. git_dir