Skip to content

Commit

Permalink
fix: git root search infinite loop on windows (issue: #126)
Browse files Browse the repository at this point in the history
  • Loading branch information
Robitx committed Aug 5, 2024
1 parent 9fcd990 commit 7eb91da
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lua/gp/helper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,18 @@ _H.find_git_root = function(path)
if path then
cwd = vim.fn.fnamemodify(path, ":p:h")
end
while cwd ~= "/" do

for _ = 0, 1000 do
local files = vim.fn.readdir(cwd)
if vim.tbl_contains(files, ".git") then
logger.debug("found git root: " .. cwd)
return cwd
end
cwd = vim.fn.fnamemodify(cwd, ":h")
local parent = vim.fn.fnamemodify(cwd, ":h")
if parent == cwd then
break
end
cwd = parent
end
logger.debug("git root not found")
return ""
Expand Down

0 comments on commit 7eb91da

Please sign in to comment.