逐行应用补丁

发布于 2024-10-16 18:28:51 字数 89 浏览 0 评论 0原文

因为我当时一直在使用 Subversion 和 shell 工具,所以不可能使用 git-gui 之类的工具。是否有任何 shell 工具可以交互式地逐行应用补丁?

Since I'm stuck with Subversion and shell tools for the time, git-gui and such are out of the question. Are there any shell tools to apply a patch line-by-line interactively?

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

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

发布评论

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

评论(3

萌能量女王 2024-10-23 18:28:51

尝试将 --dry-run 选项传递给 patch。这将使您能够识别问题所在并适当地编辑补丁和/或正在修补的文件。

Try passing the --dry-run option to patch. This will let you identify the problem hunks and edit the patch and/or file being patched appropriately.

爱人如己 2024-10-23 18:28:51

ipatch 为那些在 Darcs 中选择和编辑补丁的人带来了强大和方便的功能不使用 Darcs 版本控制系统。

它允许用户以交互方式将补丁文件拆分为多个补丁文件,以及以交互方式(可能是部分应用)应用补丁。

这里有作者的介绍这里

ipatch brings the power and convenience of selecting and editing patches in Darcs to those who are not using the Darcs version control system.

It allows the user to interactively split a patch file into several patch file, as well as applying a patch interactively and possibly partially.

There's an introduction from the author here.

ι不睡觉的鱼゛ 2024-10-23 18:28:51

查看此答案。

虽然不是交互式的,但另一种选择是手动编辑 .diff 文件并删除您不需要的任何更改。

如果您在 emacs 中打开 diff 文件并将编辑器置于 diff-mode 下,您可以编辑补丁,emacs 将尝试更新块标记。 (Emacs 将自动以 diff-mode 打开 .diff 文件。)

要在进行更改后手动更新标记,请抄送 Cw重新生成大块

要一一申请帅哥,请抄送Ca。要反向应用,请执行Cu Cc Ca。您还可以 Mx diff-tell-file-name 将它们应用到不同的文件。

我发现 patch original patch.diffpatch 更可靠。 patch.diff 和使用 diff -u 创建的补丁文件更易于使用。

此处还记录了信息。

更新 [5.21.21]:
Cc Cs 可让您拆分大块,这对于手动编辑非常有用。有时,Cc Cw (diff-ignore-whitespace-hunk) 不会达到您的预期,因此最安全的选择是拆分 hunk,并让 emacs 自动更新标头。当保持线路不变时,这特别有用;只需分成一个块并删除即可删除更改。

See this answer.

Although not interactive, another option is to manually edit the .diff file and remove any changes you don't want.

If you open a diff file in emacs and put the editor in diff-mode you can edit patches and emacs will try to update the hunk markers. (Emacs will open .diff files in diff-mode automatically.)

To update markers manually after making changes do C-c C-w to regenerate the hunk.

To apply hunks one by one do C-c C-a. To reverse-apply do C-u C-c C-a. You can also M-x diff-tell-file-name to apply them to a different file.

I found patch original patch.diff to be more reliable than patch < patch.diff and patch files created with diff -u to be easier to work with.

Information also documented here.

UPDATE [5.21.21]:
C-c C-s lets you split up hunks which is very useful for manually editing. Sometimes C-c C-w (diff-ignore-whitespace-hunk) does not do what you intended, so the safest bet is to split the hunks and let emacs update the headers automatically. This is especially useful when keeping lines unchanged; just split into a hunk and delete to remove the change.

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