Skip to content

Commit c42f9d3

Browse files
committed
fix: Don't create two watchers for $GIT_DIR
This will ignore a path for watching if EITHER it's '.git', or the value of $GIT_DIR (if it's set). If $GIT_DIR is not set, the vim.env object returns `nil`, which will never match `path`.
1 parent 93ab5fd commit c42f9d3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lua/nvim-tree/explorer/watch.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@ local M = {
88
}
99

1010
local function is_git(path)
11-
return vim.fn.fnamemodify(path, ":t") == ".git"
11+
-- If $GIT_DIR is set, consider its value to be equivalent to '.git'
12+
if path == vim.env.GIT_DIR then
13+
return true
14+
elseif vim.fn.fnamemodify(path, ":t") == ".git" then
15+
return true
16+
else
17+
return false
18+
end
1219
end
1320

1421
local IGNORED_PATHS = {

0 commit comments

Comments
 (0)