简体   繁体   中英

subversion diff including new files

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
 $

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 (eg 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

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.

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).

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM