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.
This commit is contained in:
Diego Vélez
2024-12-04 12:44:05 -04:00
committed by GitHub
parent 56760339a8
commit cc07dc1599

View File

@@ -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