gpt4 book ai didi

vim - 如何干净地编辑差异/补丁文件?有补丁文件编辑器吗?

转载 作者:行者123 更新时间:2023-12-02 08:12:33 24 4
gpt4 key购买 nike

场景:我有一个完全适用于我的工作文件的补丁文件,但我不希望补丁中的所有更改。

通常,我会执行vim example.patch,删除不需要的更改并应用patch -p0 -i example.patch,但有时补丁应用不干净,我必须重新开始。

是否有一个补丁文件编辑器,允许用户编辑和删除部分补丁,并且仍然可以干净地应用?

最佳答案

如果您正在寻找非交互式解决方案,patchutils 中的 rediff 会有所帮助。

这是它的 man 描述:

You can use rediff to correct a hand-edited unified diff. Take a copy of the diff you want to edit, and edit it without changing any offsets or counts (the lines that begin “@@”). Then run rediff, telling it the name of the original diff file and the name of the one you have edited, and it will output the edited diff file but withcorrected offsets and counts.

A small script, editdiff, is provided for editing a diff file in-place.

The types of changes that are currently handled are:

  • Modifying the text of any file content line (of course).
  • Adding new line insertions or deletions.
  • Adding, changing or removing context lines. Lines at the context horizon are dealt with by adjusting the offset and/or count.
  • Adding a single hunk (@@-prefixed section).
  • Removing multiple hunk (@@-prefixed sections).

根据其描述,recountdiff 也可能是修复统一差异的潜在候选者。

关于vim - 如何干净地编辑差异/补丁文件?有补丁文件编辑器吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7485714/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com