Skip to content

Commit a1f5f4b

Browse files
authored
fix(files): remove git root lookup from git check ignored, fixes #236
1 parent 64ccd41 commit a1f5f4b

File tree

2 files changed

+22
-20
lines changed

2 files changed

+22
-20
lines changed

lua/neo-tree/git/ignored.lua

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -48,38 +48,35 @@ local get_root_for_item = function(item)
4848
end
4949

5050
M.mark_ignored = function(state, items)
51-
local git_roots = {}
51+
local folders = {}
52+
log.trace("================================================================================")
53+
log.trace("IGNORED: mark_ignore BEGIN...")
5254
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] = {}
5759
end
58-
table.insert(git_roots[root], item.path)
60+
table.insert(folders[folder], item.path)
5961
end
6062
end
6163

6264
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
6668
table.insert(cmd, item)
6769
end
70+
log.trace("IGNORED: Running cmd: ", cmd)
6871
local result = vim.fn.systemlist(cmd)
6972
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)
7874
result = {}
7975
end
8076

8177
--check-ignore does not indicate directories the same as 'status' so we need to
8278
--add the trailing slash to the path manually.
79+
log.trace("IGNORED: Checking types of", #result, "items to see which ones are directories")
8380
for i, item in ipairs(result) do
8481
local stat = vim.loop.fs_stat(item)
8582
if stat and stat.type == "directory" then
@@ -89,14 +86,19 @@ M.mark_ignored = function(state, items)
8986
vim.list_extend(all_results, result)
9087
end
9188

92-
89+
log.trace("IGNORED: Comparing results to mark items as ignored")
90+
local ignored, not_ignored = 0, 0
9391
for _, item in ipairs(items) do
9492
if M.is_ignored(all_results, item.path, item.type) then
9593
item.filtered_by = item.filtered_by or {}
9694
item.filtered_by.gitignored = true
95+
ignored = ignored + 1
96+
else
97+
not_ignored = not_ignored + 1
9798
end
9899
end
99-
100+
log.trace("IGNORED: mark_ignored is complete, ignored:", ignored, ", not ignored:", not_ignored)
101+
log.trace("================================================================================")
100102
return all_results
101103
end
102104

lua/neo-tree/git/utils.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ M.get_repository_root = function(path)
1919
git_root = utils.windowize_path(git_root)
2020
end
2121

22-
log.trace("GIT ROOT is ", git_root)
22+
log.trace("GIT ROOT for '", path, "' is '", git_root, "'")
2323
return git_root
2424
end
2525

0 commit comments

Comments
 (0)