fix(#2382): git watcher handles worktrees and submodules, via --absolute-git-dir when it is available (#2389)

* fix(#2382): use --absolute-git-dir when available

* fix(#2382): use --absolute-git-dir when available

* fix(#2382): rename private git members, destroy git watchers on purge

* fix(#2382): consistent naming of toplevel

* fix(#2382): more doc and safety

* fix(#2382): consistent naming of toplevel

* fix(#2382): consistent naming of toplevel
This commit is contained in:
Alexander Courtis
2023-09-02 12:05:34 +10:00
committed by GitHub
parent 00741206c2
commit 28c3980b25
5 changed files with 139 additions and 83 deletions

View File

@@ -14,7 +14,7 @@ function Runner:_parse_status_output(status, path)
path = path:gsub("/", "\\")
end
if #status > 0 and #path > 0 then
self.output[utils.path_remove_trailing(utils.path_join { self.project_root, path })] = status
self.output[utils.path_remove_trailing(utils.path_join { self.toplevel, path })] = status
end
end
@@ -57,7 +57,7 @@ function Runner:_getopts(stdout_handle, stderr_handle)
local ignored = (self.list_untracked and self.list_ignored) and "--ignored=matching" or "--ignored=no"
return {
args = { "--no-optional-locks", "status", "--porcelain=v1", "-z", ignored, untracked, self.path },
cwd = self.project_root,
cwd = self.toplevel,
stdio = { nil, stdout_handle, stderr_handle },
}
end
@@ -151,7 +151,7 @@ end
function Runner:_finalise(opts)
if self.rc == -1 then
log.line("git", "job timed out %s %s", opts.project_root, opts.path)
log.line("git", "job timed out %s %s", opts.toplevel, opts.path)
timeouts = timeouts + 1
if timeouts == MAX_TIMEOUTS then
notify.warn(
@@ -164,9 +164,9 @@ function Runner:_finalise(opts)
require("nvim-tree.git").disable_git_integration()
end
elseif self.rc ~= 0 then
log.line("git", "job fail rc %d %s %s", self.rc, opts.project_root, opts.path)
log.line("git", "job fail rc %d %s %s", self.rc, opts.toplevel, opts.path)
else
log.line("git", "job success %s %s", opts.project_root, opts.path)
log.line("git", "job success %s %s", opts.toplevel, opts.path)
end
end
@@ -176,7 +176,7 @@ end
--- @return table|nil status by absolute path, nil if callback present
function Runner.run(opts, callback)
local self = setmetatable({
project_root = opts.project_root,
toplevel = opts.toplevel,
path = opts.path,
list_untracked = opts.list_untracked,
list_ignored = opts.list_ignored,
@@ -186,7 +186,7 @@ function Runner.run(opts, callback)
}, Runner)
local async = callback ~= nil
local profile = log.profile_start("git %s job %s %s", async and "async" or "sync", opts.project_root, opts.path)
local profile = log.profile_start("git %s job %s %s", async and "async" or "sync", opts.toplevel, opts.path)
if async and callback then
-- async, always call back