From c2b20591b76bdf162b9370adefba213e0a312093 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Mon, 20 Jan 2020 22:08:38 +0100 Subject: [PATCH] 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 "untracked", otherwise show the "no changes" check mark. Fixes #334. --- lib/colorls/core.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/colorls/core.rb b/lib/colorls/core.rb index b7d0eb6a..e6f0254f 100644 --- a/lib/colorls/core.rb +++ b/lib/colorls/core.rb @@ -248,12 +248,14 @@ def git_dir_info(path) 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)