From acc383d1eab516318816f43e3e380fead8249acb Mon Sep 17 00:00:00 2001 From: Dheepak Krishnamurthy Date: Mon, 10 May 2021 00:36:04 -0600 Subject: [PATCH] Fix submodule bug --- lua/lazygit.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lua/lazygit.lua b/lua/lazygit.lua index 19aaf16..8c80659 100644 --- a/lua/lazygit.lua +++ b/lua/lazygit.lua @@ -18,6 +18,12 @@ end --- Get project_root_dir for git repository 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 + return trim(gitdir) + end + -- try file location first local gitdir = fn.system('cd "' .. fn.expand('%:p:h') .. '" && git rev-parse --show-toplevel') local isgitdir = fn.matchstr(gitdir, '^fatal:.*') == ""