Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

apply svn patch to git repository

Tags:

git

svn

patch

Ok, I've tried all answers i could find on stackoverflow, but apparently none seem to be able to solve my problem. I want to apply a patch made by SVN to a git repository. Apparently the easiest way to do it is by using 'git apply', but that does not seem to work.

$ git apply --ignore-space-change --ignore-whitespace < xxx_parser.patch   <stdin>:10: trailing whitespace.         FORCE_LA_CHECK = false; stdin:23: trailing whitespace.  <stdin>:79: trailing whitespace .  .  .  .  error: pmd/grammar/JspParser.jjt: No such file or directory  error: patch failed: pmd/pom.xml:251  error: pmd/pom.xml: patch does not apply 

This is the content of xxx_parser.patch:

 $ head xxx_parser.patch Index: etc/grammar/JspParser.jjt  --- etc/grammar/JspParser.jjt   (revision 7704)  +++ etc/grammar/JspParser.jjt   (working copy) 

now why does it complain that it cannot find file pmd/grammar/JspParser.jjt?

The path in the patch is pointing to proper directory.

like image 719
victor Avatar asked Jul 17 '12 09:07

victor


People also ask

What is Apply patch in SVN?

A patch is a file that show the differences between two revisions or between your local repository and the last revision your repository is pointing. In order to apply the patch successfully, you must run the command from the same path where the patch was created.

Can you use SVN with Git?

The git-svn tool is an interface between a local Git repository and a remote SVN repository. Git-svn lets developers write code and create commits locally with Git, then push them up to a central SVN repository with svn commit-style behavior.


1 Answers

I've had a few issues applying SVN generated patches with git. I'd recommend applying any subversion patches directly with patch command, and use git to verify that said patch was successfully applied.

$ patch -p0 < xxx_parser.patch $ git diff 
like image 62
emcconville Avatar answered Oct 02 '22 14:10

emcconville