How to remove SVN Properties from SVN Diff

Filed Under: Scripts

I use SVN for my projects version control system. Sometimes I need to see the difference between two tags or two branches but when I run “svn diff” command, it gives a whole bunch of SVN Properties changes in output. I was looking for a way to remove these but built in svn diff options doesn’t provide this feature.

So I wrote a shell script that does this job for me, the idea is to first use SVN Diff summarise option with grep and awk to find out the file names where text changes are present, then iterate over this list to generate SVN diff and append that to a file to generate the final diff.

# Call this script to generate clean svn diff
#If URLs don't end with /, add them
if [ "${url1#${url1%?}}" != "/" ];
if [ "${url2#${url2%?}}" != "/" ];

echo $url1
echo $url2
#Get the length of url1, will be used later on

# Below command will get all the files with text changes and store them in files variable
files=$(svn diff $url1 $url2 --summarize | grep -v '^ ' | awk '{print substr($0,9)}')
#Generate diff for each of the files and save it in a new file
for f in $files
		$(svn diff $f $f2 >> svn_diff_clean.txt)
		echo "processed $f and $f2"
echo "done"

When I execute the above script by passing two URLs, it generates svn_diff_clean.txt having full-text diffs. I used this script to generate diff in my project and the number of lines in output was reduced by almost 50%. However, it depends on project structure and metadata usage.

Tip: If you need to give a password every time while running SVN commands, try to delete the .subversion folder from home directory and then run it, it will ask password only for first time and then use the cached password.

The script doesn’t handle bad URLs or null inputs, but I am too lazy to do that. 馃檪


  1. Sean says:

    svn diff –ignore-properties

  2. Craig Condit says:

    There’s actually a much simpler way:

    $ svn diff … | filterdiff

    filterdiff is included in the patchutils package in most Linux distros (not sure about Mac OS X, but Fink or MacPorts probably has it too). Called with no arguments, it strips invalid markers from patch files. It can also be used to do things like filter a diff based on file patterns, or even line numbers.

    1. Pankaj says:

      Thats a new thing for me. Thanks for the information.

Comments are closed.

Generic selectors
Exact matches only
Search in title
Search in content