feat(git): submodule recursion on by default

This commit is contained in:
2026-05-19 09:53:48 +02:00
parent 5f956401c1
commit 50db85ea5f
2 changed files with 10 additions and 18 deletions
+2 -2
View File
@@ -249,7 +249,7 @@ function Repo.new(gitdir, worktree)
util.debounce(Repo._fetch_status, 50)
self:start_watcher()
self:refresh()
if vim.g.git_submodule_recursion then
if vim.g.git_submodule_recursion ~= false then
self:_start_modules_watcher()
for _, name in ipairs(find_submodules(gitdir)) do
self:_register_submodule(name)
@@ -382,7 +382,7 @@ function Repo:_handle_fs_event(relpath)
return
end
self:_invalidate(relpath)
if relpath == "modules" and vim.g.git_submodule_recursion then
if relpath == "modules" and vim.g.git_submodule_recursion ~= false then
if vim.uv.fs_stat(vim.fs.joinpath(self.gitdir, "modules")) then
self:_start_modules_watcher()
for _, name in ipairs(find_submodules(self.gitdir)) do
+8 -16
View File
@@ -218,21 +218,13 @@ t.test("refresh emits change.paths listing structurally-changed paths", function
t.falsy(change.paths["b"], "b is unchanged structurally")
end)
t.test("submodule: parent enumerates initialized submodules with flag on", function()
vim.g.git_submodule_recursion = true
t.defer(function()
vim.g.git_submodule_recursion = nil
end)
t.test("submodule: parent enumerates initialized submodules by default", function()
local outer_path = h.make_submodule_repo()
local outer = assert(require("git.core.repo").resolve(outer_path))
t.truthy(outer._submodules["sub"], "sub recorded as submodule")
end)
t.test("submodule: recursion flag eagerly creates child Repos and subscribes", function()
vim.g.git_submodule_recursion = true
t.defer(function()
vim.g.git_submodule_recursion = nil
end)
t.test("submodule: eagerly creates child Repos and subscribes by default", function()
local outer_path = h.make_submodule_repo()
local outer = assert(require("git.core.repo").resolve(outer_path))
wait_initial(outer)
@@ -257,23 +249,23 @@ t.test("submodule: recursion flag eagerly creates child Repos and subscribes", f
t.eq(entry.kind, "changed")
end)
t.test("submodule: no eager creation when flag is off", function()
t.test("submodule: no eager creation when flag is explicitly disabled", function()
vim.g.git_submodule_recursion = false
t.defer(function()
vim.g.git_submodule_recursion = nil
end)
local outer_path = h.make_submodule_repo()
local outer = assert(require("git.core.repo").resolve(outer_path))
wait_initial(outer)
t.eq(
require("git.core.repo").all()[outer_path .. "/sub"],
nil,
"inner Repo not created when flag off"
"inner Repo not created when flag is false"
)
t.eq(next(outer._submodules), nil)
end)
t.test("submodule: outer created after inner picks up existing child", function()
vim.g.git_submodule_recursion = true
t.defer(function()
vim.g.git_submodule_recursion = nil
end)
local outer_path = h.make_submodule_repo()
local inner = assert(
require("git.core.repo").resolve(outer_path .. "/sub")