Skip to content

Commit 1d194df

Browse files
committed
fix(#1970): revert git kill, to be completed via #1974 experiment
1 parent ddd0b75 commit 1d194df

File tree

2 files changed

+25
-33
lines changed

2 files changed

+25
-33
lines changed

lua/nvim-tree/explorer/explore.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ local function populate_children(handle, cwd, node, git_status)
2626

2727
local abs = utils.path_join { cwd, name }
2828

29-
local profile = log.profile_start("explore populate_children %s", abs)
29+
-- local profile = log.profile_start("explore populate_children %s", abs)
3030

3131
t = get_type_from(t, abs)
3232
if
@@ -52,7 +52,7 @@ local function populate_children(handle, cwd, node, git_status)
5252
end
5353
end
5454

55-
log.profile_end(profile)
55+
-- log.profile_end(profile)
5656
end
5757
end
5858

@@ -63,7 +63,7 @@ function M.explore(node, status)
6363
return
6464
end
6565

66-
local profile = log.profile_start("explore init %s", node.absolute_path)
66+
-- local profile = log.profile_start("explore init %s", node.absolute_path)
6767

6868
populate_children(handle, cwd, node, status)
6969

@@ -74,14 +74,14 @@ function M.explore(node, status)
7474
local ns = M.explore(child_folder_only, status)
7575
node.nodes = ns or {}
7676

77-
log.profile_end(profile)
77+
-- log.profile_end(profile)
7878
return ns
7979
end
8080

8181
sorters.merge_sort(node.nodes, sorters.node_comparator)
8282
live_filter.apply_filter(node)
8383

84-
log.profile_end(profile)
84+
-- log.profile_end(profile)
8585
return node.nodes
8686
end
8787

lua/nvim-tree/git/runner.lua

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -70,53 +70,46 @@ function Runner:_log_raw_output(output)
7070
end
7171

7272
function Runner:_run_git_job()
73-
local handle
73+
local handle, pid
7474
local stdout = vim.loop.new_pipe(false)
7575
local stderr = vim.loop.new_pipe(false)
7676
local timer = vim.loop.new_timer()
7777

78-
local function on_finish(rc, signal)
79-
log.line("git", "rc=%d, signal=%s", tostring(rc), tostring(signal))
78+
local function on_finish(rc)
8079
self.rc = rc or 0
81-
82-
if timer and not timer:is_closing() then
83-
timer:stop()
84-
timer:close()
85-
end
86-
if stdout and not stdout:is_closing() then
87-
stdout:read_stop()
88-
stdout:close()
89-
end
90-
if stderr and not stderr:is_closing() then
91-
stderr:read_stop()
92-
stderr:close()
80+
if timer:is_closing() or stdout:is_closing() or stderr:is_closing() or (handle and handle:is_closing()) then
81+
return
9382
end
94-
if handle and not handle:is_closing() then
83+
timer:stop()
84+
timer:close()
85+
stdout:read_stop()
86+
stderr:read_stop()
87+
stdout:close()
88+
stderr:close()
89+
if handle then
9590
handle:close()
9691
end
92+
93+
pcall(vim.loop.kill, pid)
9794
end
9895

9996
local opts = self:_getopts(stdout, stderr)
10097
log.line("git", "running job with timeout %dms", self.timeout)
10198
log.line("git", "git %s", table.concat(utils.array_remove_nils(opts.args), " "))
10299

103-
handle = vim.loop.spawn(
100+
handle, pid = vim.loop.spawn(
104101
"git",
105102
opts,
106-
vim.schedule_wrap(function(rc, signal)
107-
on_finish(rc, signal)
103+
vim.schedule_wrap(function(rc)
104+
on_finish(rc)
108105
end)
109106
)
110107

111108
timer:start(
112109
self.timeout,
113110
0,
114111
vim.schedule_wrap(function()
115-
log.line("git", "timed out, killing")
116-
self.timed_out = true
117-
if handle then
118-
handle:kill "sigkill"
119-
end
112+
on_finish(-1)
120113
end)
121114
)
122115

@@ -142,7 +135,7 @@ end
142135

143136
function Runner:_wait()
144137
local function is_done()
145-
return self.rc ~= nil or self.timed_out
138+
return self.rc ~= nil
146139
end
147140

148141
while not vim.wait(30, is_done) do
@@ -160,16 +153,15 @@ function Runner.run(opts)
160153
list_ignored = opts.list_ignored,
161154
timeout = opts.timeout or 400,
162155
output = {},
163-
rc = nil,
164-
timed_out = false,
156+
rc = nil, -- -1 indicates timeout
165157
}, Runner)
166158

167159
self:_run_git_job()
168160
self:_wait()
169161

170162
log.profile_end(profile)
171163

172-
if self.timed_out then
164+
if self.rc == -1 then
173165
log.line("git", "job timed out %s %s", opts.project_root, opts.path)
174166
timeouts = timeouts + 1
175167
if timeouts == MAX_TIMEOUTS then

0 commit comments

Comments
 (0)