Skip to content

Commit 993eb78

Browse files
nevinerajcouball
authored andcommitted
When core.ignoreCase, check for added files case-insensitively
1 parent d943bf4 commit 993eb78

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/git/status.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ def added
5858
# added?('lib/git.rb')
5959
# @return [Boolean]
6060
def added?(file)
61-
added.member?(file)
61+
if ignore_case?
62+
added.keys.map(&:downcase).include?(file.downcase)
63+
else
64+
added.member?(file)
65+
end
6266
end
6367

6468
#

tests/units/test_status.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ def test_dot_files_status
9292
def test_added_boolean
9393
in_temp_dir do |path|
9494
git = Git.clone(@wdir, 'test_dot_files_status')
95+
git.config('core.ignorecase', 'false')
9596

9697
create_file('test_dot_files_status/test_file_1', 'content tets_file_1')
9798
create_file('test_dot_files_status/test_file_2', 'content tets_file_2')
@@ -100,6 +101,10 @@ def test_added_boolean
100101

101102
assert(git.status.added?('test_file_1'))
102103
assert(!git.status.added?('test_file_2'))
104+
assert(!git.status.added?('TEST_FILE_1'))
105+
106+
git.config('core.ignorecase', 'true')
107+
assert(git.status.added?('TEST_FILE_1'))
103108
end
104109
end
105110

0 commit comments

Comments
 (0)