Skip to content

Properly escape double quotes in shell commands on Windows #552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 3, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add test for properly escaping double quote on Windows
Signed-off-by: James Couball <jcouball@yahoo.com>
  • Loading branch information
jcouball committed Jan 3, 2022
commit 934d17da36db2fabdfed384936ce2dfdd52abfc9
22 changes: 22 additions & 0 deletions tests/units/test_windows_cmd_escaping.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env ruby
# encoding: utf-8

require File.dirname(__FILE__) + '/../test_helper'

# Test diff when the file path has to be quoted according to core.quotePath
# See https://git-scm.com/docs/git-config#Documentation/git-config.txt-corequotePath
#
class TestWindowsCmdEscaping < Test::Unit::TestCase
def test_commit_with_double_quote_in_commit_message
expected_commit_message = 'Commit message with "double quotes"'
in_temp_dir do |path|
create_file('README.md', "# README\n")
git = Git.init('.')
git.add
git.commit(expected_commit_message)
commits = git.log(1)
actual_commit_message = commits.first.message
assert_equal(expected_commit_message, actual_commit_message)
end
end
end