Skip to content

Commit

Permalink
When core.ignoreCase, check for untracked files case-insensitively
Browse files Browse the repository at this point in the history
  • Loading branch information
nevinera authored and jcouball committed Jun 1, 2024
1 parent 7758ee4 commit 2bacccc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/git/status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@ def untracked
# untracked?('lib/git.rb')
# @return [Boolean]
def untracked?(file)
untracked.member?(file)
if ignore_case?
untracked.keys.map(&:downcase).include?(file.downcase)
else
untracked.member?(file)
end
end

def pretty
Expand Down
5 changes: 5 additions & 0 deletions tests/units/test_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,18 @@ def test_untracked_from_subdir
def test_untracked_boolean
in_temp_dir do |path|
git = Git.clone(@wdir, 'test_dot_files_status')
git.config('core.ignorecase', 'false')

create_file('test_dot_files_status/test_file_1', 'content tets_file_1')
create_file('test_dot_files_status/test_file_2', 'content tets_file_2')
git.add('test_file_2')

assert(git.status.untracked?('test_file_1'))
assert(!git.status.untracked?('test_file_2'))
assert(!git.status.untracked?('TEST_FILE_1'))

git.config('core.ignorecase', 'true')
assert(git.status.untracked?('TEST_FILE_1'))
end
end

Expand Down

0 comments on commit 2bacccc

Please sign in to comment.