@@ -48,38 +48,35 @@ local get_root_for_item = function(item)
48
48
end
49
49
50
50
M .mark_ignored = function (state , items )
51
- local git_roots = {}
51
+ local folders = {}
52
+ log .trace (" ================================================================================" )
53
+ log .trace (" IGNORED: mark_ignore BEGIN..." )
52
54
for _ , item in ipairs (items ) do
53
- local root = get_root_for_item (item )
54
- if root then
55
- if not git_roots [ root ] then
56
- git_roots [ root ] = {}
55
+ local folder = utils . split_path (item . path )
56
+ if folder then
57
+ if not folders [ folder ] then
58
+ folders [ folder ] = {}
57
59
end
58
- table.insert (git_roots [ root ], item .path )
60
+ table.insert (folders [ folder ], item .path )
59
61
end
60
62
end
61
63
62
64
local all_results = {}
63
- for repo_root , repo_items in pairs (git_roots ) do
64
- local cmd = {" git" , " -C" , repo_root , " check-ignore" }
65
- for _ , item in ipairs (repo_items ) do
65
+ for folder , folder_items in pairs (folders ) do
66
+ local cmd = {" git" , " -C" , folder , " check-ignore" }
67
+ for _ , item in ipairs (folder_items ) do
66
68
table.insert (cmd , item )
67
69
end
70
+ log .trace (" IGNORED: Running cmd: " , cmd )
68
71
local result = vim .fn .systemlist (cmd )
69
72
if vim .v .shell_error == 128 then
70
- if type (result ) == " table" then
71
- if vim .startswith (result [1 ], " fatal:" ) then
72
- -- These errors are all about not being in a repository
73
- log .error (" Error in git.mark_ignored: " , result [1 ])
74
- result = {}
75
- end
76
- end
77
- log .error (" Failed to load ignored files for" , state .path , " :" , result )
73
+ log .debug (" Failed to load ignored files for" , state .path , " :" , result )
78
74
result = {}
79
75
end
80
76
81
77
-- check-ignore does not indicate directories the same as 'status' so we need to
82
78
-- add the trailing slash to the path manually.
79
+ log .trace (" IGNORED: Checking types of" , # result , " items to see which ones are directories" )
83
80
for i , item in ipairs (result ) do
84
81
local stat = vim .loop .fs_stat (item )
85
82
if stat and stat .type == " directory" then
@@ -89,14 +86,19 @@ M.mark_ignored = function(state, items)
89
86
vim .list_extend (all_results , result )
90
87
end
91
88
92
-
89
+ log .trace (" IGNORED: Comparing results to mark items as ignored" )
90
+ local ignored , not_ignored = 0 , 0
93
91
for _ , item in ipairs (items ) do
94
92
if M .is_ignored (all_results , item .path , item .type ) then
95
93
item .filtered_by = item .filtered_by or {}
96
94
item .filtered_by .gitignored = true
95
+ ignored = ignored + 1
96
+ else
97
+ not_ignored = not_ignored + 1
97
98
end
98
99
end
99
-
100
+ log .trace (" IGNORED: mark_ignored is complete, ignored:" , ignored , " , not ignored:" , not_ignored )
101
+ log .trace (" ================================================================================" )
100
102
return all_results
101
103
end
102
104
0 commit comments