From dd3c1c9bb10360f6c4f8862e86e940d9a00ea7fb Mon Sep 17 00:00:00 2001 From: Abhishek Banerji Date: Sat, 17 Jul 2021 01:50:25 +0530 Subject: [PATCH] pass git_dir into get_git_detached_head as argument and use it in to set correct --git-dir --- lua/galaxyline/provider_vcs.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lua/galaxyline/provider_vcs.lua b/lua/galaxyline/provider_vcs.lua index 2a9f8ff..dd10246 100644 --- a/lua/galaxyline/provider_vcs.lua +++ b/lua/galaxyline/provider_vcs.lua @@ -101,8 +101,9 @@ function M.get_git_dir(path) return path .. '/' .. git_dir end -local function get_git_detached_head() - local git_branches_file = io.popen("git branch -a --no-abbrev --contains", "r") +local function get_git_detached_head(git_dir) + local git_branches_cmd = "git --git-dir=" .. git_dir .. " branch -a --no-abbrev --contains" + local git_branches_file = io.popen(git_branches_cmd, "r") if not git_branches_file then return end local git_branches_data = git_branches_file:read("*l") io.close(git_branches_file) @@ -161,7 +162,7 @@ function M.get_git_branch() local branch_name = head_cache[git_root].head:match("ref: refs/heads/([^\n\r%s]+)") if not branch_name then -- check if detached head - branch_name = get_git_detached_head() + branch_name = get_git_detached_head(git_dir) if not branch_name then return end end