nirvdrum / svn2git

Ruby tool for importing existing svn projects into git.
MIT License
2.11k stars 443 forks source link

Issue creating tags if commit message contains double quotes #86

Open chappy84 opened 12 years ago

chappy84 commented 12 years ago

I was creating a git copy of an svn repository and when it got to a tag which was encased in double quotes it failed as the command had too many arguments

here's the screen output:

Running command: git config --local user.name "wojciech" Running command: git config --local user.email "wojciech" Running command: git tag -a -m ""added Polish translation"" "release-0.7.0@2895" "svn/tags/release-0.7.0@2895" fatal: too many params command failed: 2>&1 git tag -a -m ""added Polish translation"" "release-0.7.0@2895" "svn/tags/release-0.7.0@2895" Running command: git config --local --unset user.email Running command: git config --local --unset user.name

wolandscat commented 12 years ago

yep - this is a problem, I just got the same thing. Example:

2>&1 git tag -a -m "EDT-633: The characters that disallowed in an openEHR URI following the '\'':'\'' were <>|{}^~"[] and the space character. Three of these characters overlap with the RFC 3986 reserved or unreserved characters: ~[]" "Aug2007" "svn/tags/Aug2007"

wolandscat commented 12 years ago

After messing around with the script, i tried the following. I'm not a Ruby programmer, so don't trust me, but it worked (in /var/lib/gems/1.8/gems/svn2git-2.2.2/lib/svn2git/migration.rb)

def escape_quotes(str) str.gsub("'", "'\''") str.gsub("\"", "\"") end

alci63 commented 11 years ago

I am also affected by the problem... and replacing the original escape_quotes function with your version (correctly indented) didn't work. I get a syntax error... I instead tried this: def escape_quotes(str) str.gsub("'", "'\\''") str.gsub("\"", 34.char) end

This process is still ongoing, but at least I didn't get a syntax error.

wolandscat commented 11 years ago

On 29/10/2012 16:45, alci63 wrote:

I am also affected by the problem... and replacing the original escape_quotes function with your version (correctly indented) didn't work. I get a syntax error... I instead tried this: def escape_quotes(str) str.gsub("'", "'\''") str.gsub("\"", 34.char) end

I assume this is to do with versions of RUby or something like that? The thing I posted is the first line of Ruby I have ever written, but it did run on my machine (Ubuntu, latest stable Ruby download about 10 days ago).

BTW the first line which was intended to fix single quotes looked 'wrong' to me, but .. I don't know Ruby, so I left it.

I have no idea what the proper Ruby is for this function, but the original tool certainly needs a reliable fix for both kinds of quotes occurring in messages.

best,

alci63 commented 11 years ago

Thomas, I think I get caught by the formating of messages here on github, as it takes a lot of \ to get one on screen. So on your first post, I see two backslash, but I guess there are 4 of them really. So your code might well work (I got to try tomorow). Anyway a fix for this would indeed be welcome !

wolandscat commented 11 years ago

Right - I didn't think of that. I'll try quoting with 'markdown'. I just previewed it, it now looks correct.

    def escape_quotes(str)
      str.gsub("'", "'\\\\''")
      str.gsub("\"", "\\\"")
    end
markeissler commented 11 years ago

Just ran across this myself. Pretty nasty bug considering svn2git will simply stop importing tags when it comes across this situation. Luckily (?) even if you don't run with the "-v" flag enabled, svn2git will display the "command failed:" error.

kohlerm commented 9 years ago

same Problem with $ signs in messages. You have to quote them as well

ghost commented 7 years ago

If you have stored the commit message in a variable and the message contains spaces, the variable should be double quoted (example:- "$message") in the git tag command. Otherwise it will consider it as separate parameters passed to that git tag command. example:- msg = "this is a tag name" sh """ git tag -a "tag_name" -m "$msg" #//this is correct git tag -a "tag_name" -m $msg #//this is in correct. since it contains spaces the actual understanding is git tag -a "tag_name" -m this is a tag name . That's why it shows error. """

ayodorigan commented 3 years ago

Try replacing the double quotes to single quotes in your tag message -m