如何从svn差异中排除某些文件? [英] How do I exclude certain files from a svn diff?
问题描述
我正在使用 svn diff -c 789
来显示对软件789版的更改,但是它显示了很多我不在乎的文件,尤其是测试文件。如何从差异中排除某些文件,例如与模式 * Test.java
匹配的所有文件?
I'm using svn diff -c 789
to show the changes made in revision 789 of our software, but it's showing a lot of files I don't care about, in particular test files. How can I exclude certain files from the diff, for example all files which match the pattern *Test.java
?
如果要紧,我在Windows上使用Cygwin。
I'm using Cygwin on Windows, if that's important.
推荐答案
以 svn diff
不允许从输出中排除特定文件,下面是一个BASH脚本,可以用来实现这一目的。
As svn diff
does not allow to exclude specific files from the output, below is a BASH script that can be used to achieve that.
它带有两个参数:
-
文件
和svn diff
输出 -
模式
要排除的文件(例如test / *
)
file
with ansvn diff
outputpattern
of the files to be excluded (e.g.test/*
)
并打印文件
的内容,而无需更改匹配模式
的文件。
and prints the content of the file
without the changes from the 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
更新
我刚遇到一个可以完成此任务的工具: filterdiff 。它的用法与上面的脚本非常相似:
I just came across a tool that does this job: filterdiff. It's usage is very similar to the above script:
filterdiff svn_diff_file -x exclude_pattern
这篇关于如何从svn差异中排除某些文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!