Closed
Description
Subject of the issue
The current escape method for Windows is basically not doing anything:
Line 1156 in f9abb18
def escape_for_windows(s)
# Windows does not need single quote escaping inside double quotes
%Q{"#{s}"}
end
This works fine for single quotation marks but if the message contains a double quote the commit method breaks:
I, [2020-12-01T13:47:55.042634 #5488] INFO -- : git "--git-dir=Z:/Trash/repo/.git" "--work-tree=Z:/Trash/repo" "-c" "color.ui=false" commit "--message="Hello World"" 2>&1
D, [2020-12-01T13:47:55.042873 #5488] DEBUG -- : error: pathspec 'World' did not match any file(s) known to git
Git::GitExecuteError: git "--git-dir=Z:/Trash/repo/.git" "--work-tree=Z:/Trash/repo" "-c" "color.ui=false" commit "--message="Hello World"" 2>&1:error: pathspec 'World' did not match any file(s) known to git
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/git-1.7.0/lib/git/lib.rb:989:in `command'
Your environment
- ruby-git: 1.7.0
- Ruby: 2.6.4
- Windows 10
Steps to reproduce
Create a repository, open with with Git and then create a commit with a newline on the message:
mkdir repo
cd repo
git init
echo "Hello World" > hello.txt
git add hello.txt
pry
require 'git'
git = Git.open('.')
git.commit('"Hello World"')
Expected behaviour
I would expect this to work like it does on Unix-like systems. I.e. the commit is performed and the message includes the quotation marks.
Actual behaviour
A Git::GitExecuteError
is raised and the origin of the problem is the incorrectly escaped commit message.
Metadata
Metadata
Assignees
Labels
No labels