Skip to content

Commit 93ab5fd

Browse files
committed
fix: Watch $GIT_DIR for git changes, if set
While rarely used, it's possible to set the $GIT_DIR environment variable to instruct git to use a directory other than `.git`. This checks if that environment variable is set; if it is, the plugin will watch that directory. If it's not set, it'll fall back to the default `.git` directory.
1 parent 4af5722 commit 93ab5fd

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lua/nvim-tree/git/init.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ function M.load_project_status(cwd)
186186
end)
187187
end
188188

189-
watcher = Watcher:new(utils.path_join { project_root, ".git" }, WATCHED_FILES, callback, {
189+
local git_dir = vim.env.GIT_DIR or utils.path_join { project_root, ".git" }
190+
watcher = Watcher:new(git_dir, WATCHED_FILES, callback, {
190191
project_root = project_root,
191192
})
192193
end

0 commit comments

Comments
 (0)