Skip to content

Commit 0df07cd

Browse files
committed
fix: set working dir when calling git check-ignore
1 parent 45aba1f commit 0df07cd

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ test:
1010

1111
.PHONY: format
1212
format:
13-
stylua ./lua ./tests
13+
stylua --glob '*.lua' --glob '!defaults.lua' .

lua/neo-tree/git/ignored.lua

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ local log = require("neo-tree.log")
33
local git_utils = require("neo-tree.git.utils")
44

55
local M = {}
6+
local sep = utils.path_separator
67

78
M.load_ignored_per_directory = function(path)
89
if type(path) ~= "string" then
910
log.error("load_ignored_per_directory: path must be a string")
1011
return {}
1112
end
12-
path = vim.fn.shellescape(path) .. utils.path_separator .. "*"
13-
local cmd = "git check-ignore " .. path
13+
local esc_path = vim.fn.shellescape(path)
14+
local cmd = string.format("git -C %s check-ignore %s%s*", esc_path, esc_path, sep)
1415
local result = vim.fn.systemlist(cmd)
1516
if vim.v.shell_error == 128 then
1617
if utils.truthy(result) and vim.startswith(result[1], "fatal: not a git repository") then
@@ -25,7 +26,7 @@ M.load_ignored_per_directory = function(path)
2526
for i, item in ipairs(result) do
2627
local stat = vim.loop.fs_stat(item)
2728
if stat and stat.type == "directory" then
28-
result[i] = item .. utils.path_separator
29+
result[i] = item .. sep
2930
end
3031
end
3132
return result
@@ -65,7 +66,7 @@ M.load_ignored = function(path)
6566
end
6667

6768
M.is_ignored = function(ignored, path, _type)
68-
path = _type == "directory" and (path .. utils.path_separator) or path
69+
path = _type == "directory" and (path .. sep) or path
6970
for _, v in ipairs(ignored) do
7071
if v:sub(-1) == utils.path_separator then
7172
-- directory ignore

0 commit comments

Comments
 (0)