Skip to content

Commit d9556b4

Browse files
Fixing Git::Lib.escape
closes ruby-git#5 closes ruby-git#39
1 parent 577db1e commit d9556b4

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

lib/git/lib.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -783,8 +783,7 @@ def run_command(git_cmd, &block)
783783
end
784784

785785
def escape(s)
786-
escaped = s.to_s.gsub('\'', '\'\\\'\'')
787-
%Q{"#{escaped}"}
786+
"'#{s && s.to_s.gsub("'","\\'")}'"
788787
end
789788

790789
end

tests/units/test_branch.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ def test_branch_create_and_switch
6161

6262
new_file('test-file1', 'blahblahblah1')
6363
new_file('test-file2', 'blahblahblah2')
64+
new_file('.test-dot-file1', 'blahblahblahdot1')
6465
assert(g.status.untracked.assoc('test-file1'))
66+
assert(g.status.untracked.assoc('.test-dot-file1'))
6567

6668
g.add(['test-file1', 'test-file2'])
6769
assert(!g.status.untracked.assoc('test-file1'))

tests/units/test_logger.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def test_logger
1919
@git.branches.size
2020

2121
logc = File.read(log.path)
22-
assert(/INFO -- : git branch "-a"/.match(logc))
22+
assert(/INFO -- : git branch '-a'/.match(logc))
2323
assert(/DEBUG -- : \* git_grep/.match(logc))
2424

2525
log = Tempfile.new('logfile')
@@ -31,7 +31,7 @@ def test_logger
3131
@git.branches.size
3232

3333
logc = File.read(log.path)
34-
assert(/INFO -- : git branch "-a"/.match(logc))
34+
assert(/INFO -- : git branch '-a'/.match(logc))
3535
assert(!/DEBUG -- : \* git_grep/.match(logc))
3636
end
3737

0 commit comments

Comments
 (0)