Skip to content

Commit

Permalink
Correct git status for directories without changes
Browse files Browse the repository at this point in the history
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 athityakumar#334.
  • Loading branch information
avdv committed Jan 20, 2020
1 parent b43a476 commit c2b2059
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/colorls/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c2b2059

Please # to comment.