Skip to content

Commit 5f7b11f

Browse files
committed
Keep Nvim 0.9 compatibility
1 parent f76e492 commit 5f7b11f

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lua/nvim-tree/git/utils.lua

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,18 @@ function M.get_toplevel(cwd)
1616
local cmd = { "git", "-C", cwd, "rev-parse", "--show-toplevel", "--absolute-git-dir" }
1717
log.line("git", "%s", table.concat(cmd, " "))
1818

19-
local obj = vim.system(cmd):wait()
20-
local out = obj.stdout or ""
19+
local out, exitCode
20+
if vim.fn.has("nvim-0.10") == 1 then
21+
local obj = vim.system(cmd):wait()
22+
out, exitCode = obj.stdout or "", obj.code
23+
else
24+
out, exitCode = vim.fn.system(cmd), vim.v.shell_error
25+
end
2126

2227
log.raw("git", out)
2328
log.profile_end(profile)
2429

25-
if obj.code ~= 0 or not out or #out == 0 or out:match("fatal") then
30+
if exitCode ~= 0 or not out or #out == 0 or out:match("fatal") then
2631
return nil, nil
2732
end
2833

0 commit comments

Comments
 (0)