Doing a 'diff/st' and ignoring the first line if it matches a specific criterion

a 夏天 提交于 2019-12-11 04:57:09

问题


In a repository for a well known open source project, all files contain a version string with a timestamp as their first line:

<?php  // $Id: index.php,v 1.201.2.10 2009-04-25 21:18:24 stronk7 Exp $

Even if I don't really understand why they do this - since the files are already under version control -, I have to live with this.

The main problem is that if I try to 'st' or 'diff' a release to get an idea of what was changed from the previous one, every single file contained in the repository is obviously marked as modified and the diffs become unreadable and unmanageable.

I'm wondering if there's a way to ignoring the first lines doing a diff/st when they match a regexp.

The project is under cvs - cvs, yes, you've read correctly - and included in a bigger mercurial repository.


回答1:


If you try

man diff

you'll find

--ignore-matching-lines=RE Ignore changes whose lines all match RE.

search "ignore matching lines" on the web gives examples :

diff --unified --recursive --new-file --ignore-matching-lines='[$]Author.[$]' --ignore-matching-lines='[$]Date.[$]' ...

(http://www.cygwin.com/ml/cygwin-apps/2005-01/msg00000.html)

Thus try :

diff --ignore-matching-lines='[<][?]php  [/][/] [$]Id:'



回答2:


I don't know about cvs, but with hg you can use any external diff tool with the bundled extdiff extension, and any modern tool should have the ability to let you ignore diffs that match certain patterns.

I swear by Beyond Compare, which allows arbitrary syntax definition.

kdiff3 has preprocessor commands that you can pipe the input through.



来源:https://stackoverflow.com/questions/3862329/doing-a-diff-st-and-ignoring-the-first-line-if-it-matches-a-specific-criterion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!