Skip to content

Commit

Permalink
Merge pull request #478 from athityakumar/fix-461
Browse files Browse the repository at this point in the history
  • Loading branch information
avdv authored Mar 19, 2022
2 parents 1f2c7ee + a3b9431 commit 0b61d73
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/colorls/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

module ColorLS
module Git
EMPTY_SET = Set.new.freeze
private_constant :EMPTY_SET

def self.status(repo_path)
prefix, success = git_prefix(repo_path)

Expand All @@ -13,10 +16,11 @@ def self.status(repo_path)
prefix_path = Pathname.new(prefix)

git_status = Hash.new { |hash, key| hash[key] = Set.new }
git_status_default = EMPTY_SET

git_subdir_status(repo_path) do |mode, file|
if file == prefix
git_status.default = Set[mode].freeze
git_status_default = Set[mode].freeze
else
path = Pathname.new(file).relative_path_from(prefix_path)
git_status[path.descend.first.cleanpath.to_s].add(mode)
Expand All @@ -25,7 +29,7 @@ def self.status(repo_path)

warn "git status failed in #{repo_path}" unless $CHILD_STATUS.success?

git_status.default = Set.new.freeze if git_status.default.nil?
git_status.default = git_status_default
git_status.freeze
end

Expand Down

0 comments on commit 0b61d73

Please sign in to comment.