编辑差异文件
我有一个通过比较两个目录生成的 .diff 文件。但是,.diff
中出现了一些文件夹和文件,我想从中删除它们,这样我就可以获得更干净的 .diff
。
是否有任何编辑器可以让我执行此操作(例如 Kompare,但它必须允许从差异中删除文件)?如何指定排除特定目录?
I have a .diff
file generated from comparing two directories. However, there are some folders and files that appear in the .diff
that I want to remove from it, so I can get a cleaner .diff
.
Is there any editor that lets me do this (something like Kompare, but it must allow to remove files from the diff)? How can I specify to exclude specific directories?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
它不是编辑器,但看起来 patchutils 的 filterdiff 可以满足您的需求:
您可以在此处找到有关 patchutils 的更多信息,它在 Debian / Ubuntu 中打包为“patchutils”。
It's not an editor, but it looks as if filterdiff from patchutils does what you're after:
You can find out more about patchutils here and it's packaged in Debian / Ubuntu as "patchutils".
如果您最终需要对补丁(diff)文件进行“真正的编辑”,例如添加和删除差异、添加和删除差异中的行等,那么您可能会考虑运行 Emacs 具有差异编辑模式,当您更改差异文件时,它会做“正确的事情”。它具有用于“杀死当前块”和类似操作的菜单操作和键绑定。
If you end up needing to do "real editing" of patch (diff) files, like adding and removing diffs, adding and removing lines from a diff, etc then you might consider running Emacs which has a diff-editing mode that does the "right thing" when you go changing a diff file. It has menu actions and key bindings for "kill current chunk" and similar actions.
您尝试过 Meld 吗?您可以在那里定义过滤器来过滤您的比较。否则它是一个完美的 diff GUI。
Have you tried Meld? There you can define filters to filer your comparisons. Otherwise it's a perfect GUI for diff.
如果您可以控制
.diff
文件的创建,我认为最好的方法是首先不包含您以后想要忽略的内容。 Diff 有一个--exclude-from=FILE
命令行选项,您可以在其中为其提供要排除的所有文件的列表。或者,您可以使用--exclude=PATTERN
根据文件名匹配进行排除。If you have control over the creation of the
.diff
file, I think the best approach is to in the first place not include what you later want to ignore. Diff have a--exclude-from=FILE
command line option where you can give it a list of all files you want to have excluded. Alternatively you can use--exclude=PATTERN
to exclude based on file name matching.