Skip to content

Commit 978b052

Browse files
committed
fix: Attempt to make a relative $GIT_DIR absolute
1 parent c42f9d3 commit 978b052

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lua/nvim-tree/explorer/watch.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ local M = {
88
}
99

1010
local function is_git(path)
11-
-- If $GIT_DIR is set, consider its value to be equivalent to '.git'
12-
if path == vim.env.GIT_DIR then
11+
-- If $GIT_DIR is set, consider its value to be equivalent to '.git'.
12+
-- Expand $GIT_DIR (and `path`) to a full path (see :help filename-modifiers), since
13+
-- it's possible to set it to a relative path. We want to make our best
14+
-- effort to expand that to a valid absolute path.
15+
if vim.fn.fnamemodify(path, ":p") == vim.fn.fnamemodify(vim.env.GIT_DIR, ":p") then
1316
return true
1417
elseif vim.fn.fnamemodify(path, ":t") == ".git" then
1518
return true

0 commit comments

Comments
 (0)