Correct git status for directories without changes

git does not report any status for empty directories, and it also does not
report any status for directories without any modified, untracked or ignored
files.

To correctly show the status, we need to check whether the directory is empty if
git did not report any status codes. When empty, show it as "not interesting",
otherwise the "no changes" green check mark is shown.

Note, I am specifically not using the untracked marker, as that would mean there
is some interesting file inside the directory which could be added.

Fixes #334.
This commit is contained in:
Claudio Bley 2020-01-20 22:08:38 +01:00 committed by Claudio Bley
parent d0244c2aa7
commit fb39a9da6d

View file

@ -248,12 +248,14 @@ module ColorLS
modes = if path == '.'
Set.new(@git_status.values).flatten
else
@git_status.fetch(path, nil)
@git_status[path]
end
return Git.colored_status_symbols(modes, @colors) unless modes.nil?
' '
if modes.empty? && Dir.empty?(File.join(@input, path))
' '
else
Git.colored_status_symbols(modes, @colors)
end
end
def long_info(content)