如何获得补丁以忽略回车符?
我正在尝试对 Linux 系统上具有 Windows 行结尾的文件应用补丁,但由于文件中的回车符而出现冲突。
-l
选项(忽略空格)不会忽略 EOL 字符。 是否有补丁可以忽略 Windows 风格的行结尾?
I'm attempting to apply a patch to a file with Windows line endings on a Linux system and I'm getting conflicts due to the carriage returns in the file.
The -l
option (ignore whitespace) isn't ignoring the EOL characters. Is there anyway to get patch to ignore windows style line endings?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
尝试使用联机帮助页中的 --binary 选项(强调我的)
我不完全理解上面的内容,但它对我在 Linux 机器上将 Unix 补丁应用到 DOS 文件有效。
Try using the --binary option, from the manpage (emphasis mine)
I don't fully understand the above, but it worked for me on a Linux machine to apply a Unix patch onto a DOS file.
这是一个链接 http://www.chemie.fu-berlin.de/chemnet /use/info/diff/diff_2.html
运行 diff,如:
diff -w file1.txt file2.txt
Here's a link http://www.chemie.fu-berlin.de/chemnet/use/info/diff/diff_2.html
Run diff like:
diff -w file1.txt file2.txt
我使用以下命令将所有感兴趣的文件转换为 unix 行结尾来解决此问题。
I work around this using the following commands to convert all files of interest to unix line endings.
我遇到了一个 diff 问题,该 diff 是从 git diff 控制台输出手动复制并粘贴到带有 LF 的补丁文件中的。为了让该补丁文件再次工作 - 能够应用于使用 CR 和 LF 的实际文件 - 必须手动完成几件事:
joe
语法突出显示在那里非常有用,因为它着色了我一修好就好好帅哥 他们。I had this problem with a diff that was manually copied and pasted from
git diff
console output, into a patch file with LFs. To get that patch file to work again - to be able to be applied on the actual files that were using CRs and LFs - several things had to be done manually:joe
syntax highlighting was very helpful there, because it colored hunks properly as soon as I fixed them.告诉
patch
忽略空格:这也会忽略EOL的不匹配——至少在FreeBSD上,使用
patch
版本2.0-12u11。Tell
patch
to ignore white space:This ignores mismatches of EOLs too -- at least, on FreeBSD, using
patch
version 2.0-12u11.