views:

3089

answers:

4

I have some local changes to an open source project which uses Subversion as its source control. (I do not have commit access on the original project repository.)

My change adds a file, but this file is not included in the output of "svn diff". (It may be worth noting that the new file is a binary, not plain text.)

How can I make a patch which includes the new files?


 $ svn st
   A      tests/foo.zip
 $ svn diff
 $
A: 

If you're building a patch, you might want to use plain old 'diff' with the --new-file option which treats the missing file as empty.

Note that the syntax for this option may actually vary depending on what version of plain old diff you're using.

Mark Roddy
+3  A: 

The fact that your file is binary is exactly why it is not displayed I'm afraid. Subversion's diff command only does textual diffs/patches (even though Subversion internally can handle binary file differences efficiently between versions).

Duncan Smart
+1  A: 

There is a --force option to the diff command, but it produces an incorrect patch file for binaries on my machine. Using it with the --diff-cmd option works for me though:

svn diff --force --diff-cmd /usr/bin/diff -x -au

I think this produces exactly what you wanted.

Pozsár Balázs
+2  A: 

I experienced similar behavior to Pozsar. And his answer worked for me better than the normal svn diff --force. However, if running on a DOS machine (e.g. via Cygwin), you may need to modify his answer slightly. The following diff + patch worked for patching my text + binary files in Cygwin using the --binary arg:

svn diff --force --diff-cmd /usr/bin/diff -x "-au --binary" OLD-URL NEW-URL > mybinarydiff.diff

patch -p0 --binary -i mybinarydiff.diff
Jason Favors