How to exclude some files from svn diff?

I use svn diff -c 789 to show the changes made to the 789 edition of our software, but it shows a lot of files that I don’t need, in particular test files. How can I exclude certain files from diff, for example, all files matching the *Test.java pattern?

I use Cygwin for Windows if this is important.

+7
source share
3 answers

Since svn diff does not allow you to exclude certain files from the output, the following is a BASH script that can be used to achieve this.

Two arguments are required:

  • file with svn diff output
  • pattern files to be excluded (e.g. test/* )

and prints the contents of file unchanged from files matching pattern .

 #!/bin/bash test $# -ne 2 && echo "Usage: $0 svn_diff_file exclude_pattern" && exit 1 ignore=0 while IFS= read -r line; do echo $line | grep -q -e "^Index: " && ignore=0 echo $line | grep -e "^Index: " | grep -q -e "^Index: $2" && ignore=1 test $ignore -eq 0 && echo "$line" done < $1 

Update

I just stumbled upon a tool that does this job: filterdiff . This usage is very similar to the above script:

filterdiff svn_diff_file -x exclude_pattern

+5
source

By the way, remember that svn diff commands work like other commands that follow the Unix modular philosophy, where each command has standard input and output. You can create your own script to list the files in which you want to include redirecting the output of this script to svn diff commands using pipes, and then redirecting the diff output to the desired file that you want to create. To be more clear: follow this example

 svn diff `cat change_list.txt` > patch.diff 

in change_list.txt - files that you want to include in diff, separated by a space. For example, the contents of a file may be as follows:

"domain / model / entity.java"

"web_app / controllers / controller.java"

So, following this approach, the only problem with your problem is to implement the script that Adam wrote above.

Hope this helps!

Vic.

+3
source

This is what I did:

 FILES=$(svn status some_dir|grep ^M|cut -b2-|grep -v dir_to_remove) test -n "$FILES" && svn diff "$FILES" 
+1
source

All Articles