aboutsummaryrefslogtreecommitdiff
path: root/test/functional/plugin/pack_spec.lua
diff options
context:
space:
mode:
authorEvgeni Chasnovski <evgeni.chasnovski@gmail.com>2025-09-08 00:42:09 +0300
committerGitHub <noreply@github.com>2025-09-07 14:42:09 -0700
commitfa3920282da007f0ea7ce37873ccb3c1db0af0ec (patch)
tree29f138195575d0d8679e51a55c5c7f3ebbecb877 /test/functional/plugin/pack_spec.lua
parent448f15ca396aa7007eb2c5cb82dd2ea6c5c82953 (diff)
downloadrneovim-fa3920282da007f0ea7ce37873ccb3c1db0af0ec.tar.gz
rneovim-fa3920282da007f0ea7ce37873ccb3c1db0af0ec.tar.bz2
rneovim-fa3920282da007f0ea7ce37873ccb3c1db0af0ec.zip
fix(pack): handle Git environment variables #35626
Problem: Some environment variables which are useful when working inside a bare repository can affect any Git operation. Solution: Explicitly unset problematic environment variables.
Diffstat (limited to 'test/functional/plugin/pack_spec.lua')
-rw-r--r--test/functional/plugin/pack_spec.lua27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/functional/plugin/pack_spec.lua b/test/functional/plugin/pack_spec.lua
index a8664b80b9..bbd9ada85a 100644
--- a/test/functional/plugin/pack_spec.lua
+++ b/test/functional/plugin/pack_spec.lua
@@ -664,6 +664,19 @@ describe('vim.pack', function()
eq('basic main', exec_lua('return require("basic")'))
end)
+ it('is not affected by special environment variables', function()
+ fn.setenv('GIT_WORK_TREE', fn.getcwd())
+ fn.setenv('GIT_DIR', vim.fs.joinpath(fn.getcwd(), '.git'))
+ local ref_environ = fn.environ()
+
+ exec_lua(function()
+ vim.pack.add({ repos_src.basic })
+ end)
+ eq('basic main', exec_lua('return require("basic")'))
+
+ eq(ref_environ, fn.environ())
+ end)
+
it('validates input', function()
local validate = function(err_pat, input)
local add_input = function()
@@ -1163,6 +1176,20 @@ describe('vim.pack', function()
eq({ 'return "fetch new 2"' }, fn.readfile(fetch_lua_file))
end)
+ it('is not affected by special environment variables', function()
+ fn.setenv('GIT_WORK_TREE', fn.getcwd())
+ fn.setenv('GIT_DIR', vim.fs.joinpath(fn.getcwd(), '.git'))
+ local ref_environ = fn.environ()
+
+ exec_lua(function()
+ vim.pack.add({ repos_src.fetch })
+ vim.pack.update({ 'fetch' }, { force = true })
+ end)
+ eq({ 'return "fetch new 2"' }, fn.readfile(fetch_lua_file))
+
+ eq(ref_environ, fn.environ())
+ end)
+
it('validates input', function()
local validate = function(err_pat, input)
local update_input = function()