28

I use SVN as the 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...

2
  • What do you mean by metadata?
    – codelogic
    Dec 31, 2008 at 8:32
  • "SVN properties" is a better word to describe it. I fixed my post to clarify this..
    – driAn
    Dec 31, 2008 at 10:39

10 Answers 10

25

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

2
11

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

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

7

Found this while searching through the svn help docs

svn diff --patch-compatible

It's the same as running

svn diff --show-copies-as-adds --ignore-properties
6

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 the second character on the line.

2
  • 2
    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.
    – Michael Augustin
    Feb 19, 2009 at 21:55
  • 1
    This does not handle cases where file content and properties are both changed, or where something else, like locking, happened to the file and the file is modified.
    – trysis
    Dec 28, 2017 at 20:30
3

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 :/

3

Use svn diff --ignore-properties. That's Subversion's built-in method to do differencing of the content only. It ignores any changes to the properties of the items.

3
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review
    – Ravi Y
    May 24, 2018 at 21:31
  • 1
    Does it not? The author's question asked how to get svn diff to ignore all subversion properties when doing a diff. That's precisely what svn --ignore-properties does. Maybe I should have worded it better as an answer. I'll try to do so in the future.
    – seanahern
    May 29, 2018 at 16:12
  • 1
    @ryadavilli why are stackoverflow reviewers so obtuse? May 2, 2019 at 16:12
2

Here's a single command that does all this. Say you want to find all (non-property) diffs for all files in the currently directory between revision 54833 and 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.

1

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

-1

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

1
  • 1
    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
    Jan 2, 2009 at 17:06
-6

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

1
  • 1
    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
    Dec 31, 2008 at 9:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.