From cc07dc1599f3443ee73d7e85afc45598923ef113 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20V=C3=A9lez?= Date: Wed, 4 Dec 2024 12:44:05 -0400 Subject: [PATCH] feat: use git-dir and work-tree from environment (#142) Passes `work-tree` and `git-dir` arguments for Lazygit. This is very useful when using a bare git repo, so that Lazygit can still be used to manage the repo. --- lua/lazygit.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/lazygit.lua b/lua/lazygit.lua index 770e042..1d1064b 100644 --- a/lua/lazygit.lua +++ b/lua/lazygit.lua @@ -101,7 +101,9 @@ local function lazygit(path) cmd = cmd .. " -ucf '" .. config_path .. "'" -- quote config_path to avoid whitespace errors end - if path == nil then + if vim.env.GIT_DIR ~= nil and vim.env.GIT_WORK_TREE ~= nil then + cmd = cmd .. " -w " .. vim.env.GIT_WORK_TREE .. " -g " .. vim.env.GIT_DIR + elseif path == nil then if is_symlink() then path = project_root_dir() end