fix(pack): GIT_DIR/GIT_WORK_TREE env vars may interfere #39279

Problem:
With GIT_DIR/GIT_WORK_TREE set, the LSP on the vim.pack.update()
confirmation buffer does not show the correct git log on hover.

Solution:
Temporarily remove the git vars from the environment.
This commit is contained in:
fleesk
2026-04-22 10:46:48 +02:00
committed by GitHub
parent 44770bb924
commit e53e728c92
2 changed files with 11 additions and 1 deletions

View File

@@ -218,7 +218,11 @@ methods['textDocument/hover'] = function(params, callback)
local res = { contents = { kind = vim.lsp.protocol.MarkupKind.Markdown, value = markdown } }
callback(nil, res)
end
vim.system(cmd, { cwd = path }, vim.schedule_wrap(on_exit))
-- temporarily clear GIT env vars
local env = vim.fn.environ() --- @type table<string,string>
env.GIT_DIR, env.GIT_WORK_TREE = nil, nil
vim.system(cmd, { cwd = path, env = env, clear_env = true }, vim.schedule_wrap(on_exit))
end
local dispatchers = {}