做一个“diff/st”并忽略第一行(如果它符合特定条件)

发布于 2024-09-26 03:02:50 字数 408 浏览 2 评论 0原文

在一个众所周知的开源项目的存储库中,所有文件都包含一个带有时间戳的版本字符串作为其第一行:

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

即使我真的不明白他们为什么这样做 - 因为文件已经在版本控制之下 - 我有忍受这个。

主要问题是,如果我尝试“st”或“diff”一个版本以了解与前一个版本相比发生了什么更改,那么存储库中包含的每个文件显然都被标记为已修改,并且差异变得不可读且难以管理。

我想知道是否有一种方法可以在匹配正则表达式时忽略执行 diff/st 的第一行。

该项目位于 cvs 下 - cvs,是的,您没有看错 - 并且包含在更大的 Mercurial 存储库中。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

海螺姑娘 2024-10-03 03:02:50

我不知道 cvs,但使用 hg,您可以使用任何外部 diff 工具与捆绑的 extdiff 扩展,任何现代工具都应该能够让您忽略与某些模式匹配的差异。

我发誓Beyond Compare,它允许任意语法定义。

kdiff3 有预处理器命令,您可以通过它们管道输入。

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.

葮薆情 2024-10-03 03:02:50

如果您尝试,

man diff

您会发现

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

网络上的搜索“忽略匹配行”给出了示例:

diff --unified --recursive --new-file
--ignore-matching-lines='[$]作者。[$]'
--ignore-matching-lines='[$]日期。
[$]' ...

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

因此尝试:

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

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:'
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文