Skip to content

Commit ff6e796

Browse files
committed
fix(#1484): better error handling in git utils get_toplevel
1 parent 7323c81 commit ff6e796

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lua/nvim-tree/git/utils.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function M.get_toplevel(cwd)
1414
log.raw("git", toplevel)
1515
log.profile_end(ps, "git toplevel %s", cwd)
1616

17-
if not toplevel or #toplevel == 0 or toplevel:match "fatal" then
17+
if vim.v.shell_error ~= 0 or not toplevel or #toplevel == 0 or toplevel:match "fatal" then
1818
return nil
1919
end
2020

@@ -23,6 +23,9 @@ function M.get_toplevel(cwd)
2323
-- msys2 git support
2424
if has_cygpath then
2525
toplevel = vim.fn.system("cygpath -w " .. vim.fn.shellescape(toplevel))
26+
if vim.v.shell_error ~= 0 then
27+
return nil
28+
end
2629
end
2730
toplevel = toplevel:gsub("/", "\\")
2831
end

0 commit comments

Comments
 (0)