views:

1190

answers:

8

I use SVN as source control system and I wonder how to compare directories while ignoring any metadata differences. Is there a way to tell svn diff to compare only the actual content and ignore any metadata?

I mean metadata like SVN properties, etc, that don't affect the file content. Assume file X has an additional property in branch B compared to trunk T. Unfortunately it will show up in 'svn diff T B' even though the actual content of file X is the same.

I look for something like this:

svn diff https://example.org/tags/v1 https://example.org/tags/v2 -x -ignore-metadata --summarize

Update: I partially solved this by diff'ing directly on the filesystem instead of using the svn tools, see my own answer below..

A: 

I'm not sure but a simple 'svn diff | grep -iv "stuff to ignore"' would be a work around.

Rob Elsner
The whole diff comes only as a huge amount of text, I would have to manually parse it to filter out all 'svn property added'-like changes. No easy task I can get done using grep unfortunately.
driAn
A: 

You can set the svn:ignore property on files and directories you want svn diff to ignore.

Yuval F
I don't want to ignore specific directories or files, it's about ignoring differing properties (aka metadata) of the same files. Assume file X has an additional property in branch B compared to trunk T. It will show up in svn diff even though the actual content is the same.
driAn
A: 

There seems to be no way to get this done using the svn built-in tools. How I solved it: Export both trees and diff them diretly on the filesystem using your favourite diff tool. That's somehow the only way to get this done :/

driAn
+2  A: 

If you use the --summarize option, then property changes are indicated in the second rather than the first column.

i.e.

M  url  -- indicates content change
 M url  -- property change
MM url  -- content and property change

a bit easier to grep, I guess you could have a two stage process if you want full diff - first use summarize to find files with content change, then diff them

Joe Watkins
A: 

Nice tip from JosephWatkins.

Here is the command for the grep-junior-users:

svn diff A B --summarize | grep '^. '

The grep looks for a space as second character on the line.

Sorry. It must be svn diff A B --summarize | grep -v '^ 'All Lines starting with a space must be hidden, because there where only property changes on files.
A: 

I wrote a script to do this, after I couldn't find one online.

The script removes the data based on an array of regular expressions entered at the top of the script. Currently, it is set up to filter out the properties changes, but it can remove any change that matches a series of regular expressions.

Just pipe the output of svn diff to the script, after you set the script. I put the filters in the script instead of parameters because I always run the same filters.

I released it as GPLv2.

clean_svn_diff.bash

+2  A: 

You can pass the svn diff output through 'filterdiff --clean' to remove any extraneous lines including property changes.

David Claughton
A: 

Here's a single command that does all this. Say you want to find all (non-property) diffs for all files in the currently dir between revision 54833 & 57215. This command should do it:

svn diff -r 54833:57215 --summarize | egrep -v '^ |^D|^A' | awk '{ print $2 }' | xargs svn diff -r 54833:57215

NB: it only diffs modified files - not added or deleted files.

Brian Kirwan