应用 .patch 文件

发布于 2024-11-28 04:10:43 字数 673 浏览 2 评论 0原文

我想将 .patch 文件应用到一个文件。 我将两者放在同一个文件夹中,并尝试了此操作

trinity@Zion ~/Desktop $ patch -i lalala.patch 
patching file install.sub
patch unexpectedly ends in middle of line
Hunk #1 FAILED at 1562.
1 out of 1 hunk FAILED -- saving rejects to file install.sub.rej

,但正如您在输出中看到的那样,它失败了。 install.sub.rej的内容基本上是lalala.patch中的全部代码 我尝试了类似的命令,但得到了相同的结果。我想我做错了什么。

我知道应用补丁只是 1 个命令,但我对此很迷茫。如果有人告诉我命令或直接修补文件(并且还告诉我命令)感谢

原始文件 http://pastebin.com/raw.php?i=PKru8m5r 修补: http://pastebin.com/raw.php?i=kkMUHtj8

I want to apply a .patch file to one file.
I placed both in the same folder and I tried this

trinity@Zion ~/Desktop $ patch -i lalala.patch 
patching file install.sub
patch unexpectedly ends in middle of line
Hunk #1 FAILED at 1562.
1 out of 1 hunk FAILED -- saving rejects to file install.sub.rej

But as you see in the output, it failed. The content of install.sub.rej is basically all the code from lalala.patch
I tried similar commands but I got the same results. I guess I'm doing something wrong.

I know applying a patch is just 1 command but I'm so lost at this. If someone tells me the command or directly patches the file (and also tells me the command) thanks

original file
http://pastebin.com/raw.php?i=PKru8m5r
patch:
http://pastebin.com/raw.php?i=kkMUHtj8

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

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

发布评论

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

评论(2

嘴硬脾气大 2024-12-05 04:10:44

你的补丁命令没问题。补丁文件本身给出了问题(至少对我来说(Kubuntu 11.04),查看您在评论中给出的链接,所有补丁文件都包含相同的错误......?!)

为我解决问题,在补丁文件中找到这一行:

@@ -1562,6 +1562,8 @@ set_timezone() {

并删除 set_timezone() { 部分,您描述的错误就消失了。

这部分显示了进行更改的函数。当查看您在评论中给出的页面上的补丁时,它表明所有补丁都包含这些额外的信息。据我所知(但我不是补丁专家,所以请纠正我)这是默认补丁命令不接受的。

(不幸的是,您的补丁仍然失败,并且补丁文件中的预期行与原始文件相比不匹配......)

Your patch command is fine. It is the patch file itself that gives the problem (at least for me (Kubuntu 11.04), as looking at the link you gave in the comment, all patch files contain the same error...?!)

To solve the problem for me, find this line in the patch file:

@@ -1562,6 +1562,8 @@ set_timezone() {

and remove the set_timezone() { part and the error you describe is gone.

This part is showing the function where the changes are made. When looking at the patches on the page you gave in your comment, it shows that all of them contain this extra information. As far as I know (but I am not a patch guru, so please correct me) is this not accepted by the default patch command.

(Unfortunately enough, your patch still fails and the expected lines in the patch file compared to the original file do not match...)

花伊自在美 2024-12-05 04:10:44

生成的补丁很可能是“正确的”,但请仔细检查它的编码并确保它是 UTF-8。

Quite likely, the generated patch is "correct" but double-check the encode of it and be sure it's UTF-8.

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