From 8e740db70c04923217339b6b3f916d244fc7dec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20RAYBAUD-ROIG?= <1268110+m-r-r@users.noreply.github.com> Date: Thu, 9 Oct 2025 22:40:26 +0200 Subject: [PATCH] fix(vim.pack): skip checkout on bad `version` #36038 Refs: #36037 --- runtime/lua/vim/pack.lua | 2 +- test/functional/plugin/pack_spec.lua | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/runtime/lua/vim/pack.lua b/runtime/lua/vim/pack.lua index 532c85c5fe..1a0a3c4540 100644 --- a/runtime/lua/vim/pack.lua +++ b/runtime/lua/vim/pack.lua @@ -144,7 +144,7 @@ end --- @param url string --- @param path string local function git_clone(url, path) - local cmd = { 'clone', '--quiet', '--origin', 'origin' } + local cmd = { 'clone', '--quiet', '--origin', 'origin', '--no-checkout' } if vim.startswith(url, 'file://') then cmd[#cmd + 1] = '--no-hardlinks' diff --git a/test/functional/plugin/pack_spec.lua b/test/functional/plugin/pack_spec.lua index 82f3f6c28e..bc28b026b3 100644 --- a/test/functional/plugin/pack_spec.lua +++ b/test/functional/plugin/pack_spec.lua @@ -583,6 +583,16 @@ describe('vim.pack', function() eq(false, vim.tbl_contains(rtp, after_dir)) end) + it('does not checkout on bad `version`', function() + local err = pcall_err(exec_lua, function() + vim.pack.add({ { src = repos_src.basic, version = 'not-exist' } }) + end) + matches('`not%-exist` is not a branch/tag/commit', err) + local plug_path = pack_get_plug_path('basic') + local entries = vim.iter(vim.fs.dir(plug_path)):totable() + eq({ { '.git', 'directory' } }, entries) + end) + it('can install from the Internet', function() t.skip(skip_integ, 'NVIM_TEST_INTEG not set: skipping network integration test') exec_lua(function()