From fa1f0012079e2040ecdc492a07a1f2728d53eef8 Mon Sep 17 00:00:00 2001 From: shadmansaleh <13149513+shadmansaleh@users.noreply.github.com> Date: Wed, 25 Aug 2021 12:18:47 +0600 Subject: [PATCH] fix: branch assumes git file will be correctly formated --- lua/lualine/components/branch.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lua/lualine/components/branch.lua b/lua/lualine/components/branch.lua index 35bb707..ad3c77b 100644 --- a/lua/lualine/components/branch.lua +++ b/lua/lualine/components/branch.lua @@ -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