Skip to content

Commit message escaping issues under Windows #495

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

Closed
sergio-bobillier opened this issue Dec 1, 2020 · 2 comments
Closed

Commit message escaping issues under Windows #495

sergio-bobillier opened this issue Dec 1, 2020 · 2 comments

Comments

@sergio-bobillier
Copy link

Subject of the issue

The current escape method for Windows is basically not doing anything:

def escape_for_windows(s)

    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.

@stale
Copy link

stale bot commented Jan 9, 2022

A friendly reminder that this issue had no activity for 60 days.

@jcouball
Copy link
Member

Fixed with #684 and released in git-2.0.0-pre1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants