1
- local Job = require (" plenary.job" )
2
1
local utils = require (" neo-tree.utils" )
3
2
local log = require (" neo-tree.log" )
4
3
local git_utils = require (" neo-tree.git.utils" )
@@ -10,36 +9,26 @@ M.load_ignored_per_directory = function(path)
10
9
log .error (" load_ignored_per_directory: path must be a string" )
11
10
return {}
12
11
end
13
-
14
- local result = {}
15
- local job = Job :new ({
16
- cwd = path ,
17
- command = " git" ,
18
- args = { " check-ignore" , " *" },
19
- enabled_recording = false ,
20
- record = true ,
21
- on_exit = function (job , retval )
22
- result = job :result ()
23
- log .info (" load_ignored_per_directory: " .. path .. " : " .. # result .. " ignored files" )
24
- if retval == 128 then
25
- if utils .truthy (result ) and vim .startswith (result [1 ], " fatal: not a git repository" ) then
26
- result = {}
27
- log .error (result )
28
- else
29
- result = {}
30
- log .error (" Failed to load ignored files for " , path , " : " , result )
31
- end
32
- end
12
+ path = vim .fn .shellescape (path ) .. utils .path_separator .. " *"
13
+ local cmd = " git check-ignore " .. path
14
+ local result = vim .fn .systemlist (cmd )
15
+ if vim .v .shell_error == 128 then
16
+ if utils .truthy (result ) and vim .startswith (result [1 ], " fatal: not a git repository" ) then
17
+ return {}
33
18
end
34
- })
35
-
36
- local success , msg = pcall (job .sync , job , 200 , 5 )
37
- if success then
38
- return result
39
- else
40
- log .error (" Failed to load ignored files for " , path , " : " , msg )
19
+ log .error (" Failed to load ignored files for " , path , " : " , result )
41
20
return {}
42
21
end
22
+
23
+ -- check-ignore does not indicate directories the same as 'status' so we need to
24
+ -- add the trailing slash to the path manually.
25
+ for i , item in ipairs (result ) do
26
+ local stat = vim .loop .fs_stat (item )
27
+ if stat and stat .type == " directory" then
28
+ result [i ] = item .. utils .path_separator
29
+ end
30
+ end
31
+ return result
43
32
end
44
33
45
34
M .load_ignored = function (path )
0 commit comments