views:

1911

answers:

3

Is there any way to get a patch created with git format-patch to be svn compatible so that I can submit it to an svn repo?

I'm working off an svn repo on github and want to submit my changes back to the main repo. I need to create a patch to do this, however the patch cannot be applied since git formats that patch differently then svn. Is there some secret I haven't discovered yet?

UPDATE: Although currently there exists no script or native git way to do this, I did managed to find a post from earlier this year about how to manually accomplish this. I have followed the instructions and had success getting my git patches to work with svn.

If someone could take a stab at writing a script to accomplish this and contribute to the git project, I'm everyone would be much appreciated.

http://kerneltrap.org/mailarchive/git/2008/1/15/570308/thread#mid-570308

+2  A: 

It is indeed a feature request early 2008

Linus Torvalds said at the time:

So I would argue that you need something stronger to say "don't do a git diff", and that should also disallow rename detection at a minimum.
Quite frankly, any program that is so stupid as to not accept current git patches (ie TortoiseSVN), then we damn well shouldn't just disable the most trivial part of it. We should make sure that we do not enable any of the rather important extensions:
even if ToirtoiseSVN would ignore them, if ignoring them means that it mis-understands the diff, it shouldn't be allowed at all.

That may be why

 git-format-patch: add --no-binary to omit binary changes in the patch.

has been introduced in Git1.5.6 in May/July 2008 (I have not tested it though)

VonC
Typo: Linus *Torvalds*
akaihola
@akaihola: thank you, fixed
VonC
+3  A: 

SVN probably cannot understand the output of git diff -p, but you can resort to brute force:

  1. Make two clones of your repo
  2. In one clone check out your latest stuff
  3. In the other clone checkout whatever is equivalent to the svn upstream. If you have planned ahead you have a copy of svn upstream on its own branch, or you have tagged the last svn version. If you have not planned ahead, use the date or gitk to find the git SHA1 hash that most closely approximates the svn state.
  4. Now compute a real patch by running diff -r over the two clones.
Norman Ramsey
+2  A: 

Subversion < 1.6 doesn't have patch support. It looks like Subversion 1.7 will allow applying patches and the git/hg extensions to unified diff are on our TODO list.

Bert Huijben