我正在尝试使用命令创建补丁
git diff sourcefile >/var/lib/laymab/overlay/category/ebuild/files/thepatch.patch
当我应用补丁时,它给了我
$ patch -v
GNU patch 2.7.5
$ /usr/bin/patch -p1 </var/lib/laymab/overlay/category/ebuild/files/thepatch.patch
patching file sourcefile
Hunk #1 FAILED at 1 (different line endings).
Hunk #2 FAILED at 23 (different line endings).
Hunk #3 FAILED at 47 (different line endings).
Hunk #4 FAILED at 65 (different line endings).
Hunk #5 FAILED at 361 (different line endings).
5 out of 5 hunks FAILED -- saving rejects to file sourcefile.rej
我试图将dos2unix应用于src文件和补丁文件,但消息没有消失...
UPD:--ignore-whitespace也无济于事
PATCH COMMAND: patch -p1 -g0 -E --no-backup-if-mismatch --ignore-whitespace --dry-run -f < '/var/lib/layman/dotnet/dev-dotnet/slntools/files/remove-wix-project-from-sln-file-v2.patch'
=====================================================
checking file Main/SLNTools.sln
Hunk #1 FAILED at 14 (different line endings).
Hunk #2 FAILED at 49 (different line endings).
Hunk #3 FAILED at 69 (different line endings).
Hunk #4 FAILED at 102 (different line endings).
4 out of 4 hunks FAILED
UPD:找到了一篇很好的文章:https : //stackoverflow.com/a/4425433/1709408
sed -i.bak -e 's/\r$//g' something
。我认为dos2unix不会像您想要的那样积极地处理混合行尾。