如何在linux上应用windows SVN制作的diff?

发布于 2024-09-07 18:41:15 字数 1555 浏览 5 评论 0原文

在 Windows 上,我创建了一个多文件差异:

svn diff > mydiff.diff

然后将其移动到 Linux 机器(使用相同版本的相同存储库,没有更改)。我该如何应用它?执行后,

 patch -p0 < mydiff.diff

我得到以下输出:

patching file licstat/test/unittest/test_licstatactioncontainers.cpp
File licstat/test/unittest/test_licstatactioncontainers.cpp is not empty after patch, as expected
patching file licstat/test/unittest/test_licstatactions.cpp
Hunk #1 FAILED at 99.
1 out of 1 hunk FAILED -- saving rejects to file licstat/test/unittest/test_licstatactions.cpp.rej
can't find file to patch at input line 295
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|Index: licstat/test/unittest/test_licenseserverusagemap.cpp
|===================================================================
|--- licstat/test/unittest/test_licenseserverusagemap.cpp       (revision 6767)
|+++ licstat/test/unittest/test_licenseserverusagemap.cpp       (working copy)
--------------------------
File to patch: 

最后一行提示等待我的操作。

我应该如何创建/应用补丁才能使其正常工作?

(编辑)现在我明白了,该文件丢失了,并且 diff 没有创建它。手动创建文件后,我收到如下错误:

patching file licstat/misc/generic/mysql/stored_procedures.sql
Hunk #1 FAILED at 220.
Hunk #2 FAILED at 245.
Hunk #3 FAILED at 622.
Hunk #4 FAILED at 661.
Hunk #5 FAILED at 810.
Hunk #6 FAILED at 822.
Hunk #7 FAILED at 868.
Hunk #8 FAILED at 999.
8 out of 8 hunks FAILED -- saving rejects to file licstat/misc/generic/mysql/stored_procedures.sql.rej

On windows i created a multi-file diff with:

svn diff > mydiff.diff

Then moved it to linux machine (with the same version of the same repo, no changes). How cai i apply it? After executing

 patch -p0 < mydiff.diff

I get the following output:

patching file licstat/test/unittest/test_licstatactioncontainers.cpp
File licstat/test/unittest/test_licstatactioncontainers.cpp is not empty after patch, as expected
patching file licstat/test/unittest/test_licstatactions.cpp
Hunk #1 FAILED at 99.
1 out of 1 hunk FAILED -- saving rejects to file licstat/test/unittest/test_licstatactions.cpp.rej
can't find file to patch at input line 295
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|Index: licstat/test/unittest/test_licenseserverusagemap.cpp
|===================================================================
|--- licstat/test/unittest/test_licenseserverusagemap.cpp       (revision 6767)
|+++ licstat/test/unittest/test_licenseserverusagemap.cpp       (working copy)
--------------------------
File to patch: 

And the last line is prompt waiting for my action.

How should I create/apply the patch to make it work?

(edit) Now I see, that the file was missing and diff didn't create it. After creating the file manually I get errors like this:

patching file licstat/misc/generic/mysql/stored_procedures.sql
Hunk #1 FAILED at 220.
Hunk #2 FAILED at 245.
Hunk #3 FAILED at 622.
Hunk #4 FAILED at 661.
Hunk #5 FAILED at 810.
Hunk #6 FAILED at 822.
Hunk #7 FAILED at 868.
Hunk #8 FAILED at 999.
8 out of 8 hunks FAILED -- saving rejects to file licstat/misc/generic/mysql/stored_procedures.sql.rej

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

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

发布评论

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

评论(4

乖乖公主 2024-09-14 18:41:15

如果 Linux 上的文件中有 CR+LF 换行符,那么使用“dos2unix”将无济于事。

该命令应该使用任何换行符组合来完成这项工作:

patch -p0 -l --binary < patch.diff

Using "dos2unix" will not help if you have CR+LF line feed in your files on Linux.

This command should do the job with any combination of line feeds:

patch -p0 -l --binary < patch.diff
满地尘埃落定 2024-09-14 18:41:15

我经常在 Windows 和 Mac 系统之间修补文件,并且 patch 似乎确实可以正确处理换行符,所以我认为这不是问题所在。看起来您可能已经删除了 test_licstatactioncontainers.cpp 并且第一个警告就是关于此的。第二个似乎是在抱怨找不到文件本身。

这可能是文件名大小写问题吗? Windows 对文件名大小写不敏感,但 Linux 则不然。该文件实际上在 Linux 上名为 Test_LicenceServerUsageMap.cpp 吗?或者目录 LicStat/Test ?

I quite regularly patch files between a windows and mac system and patch does seem to deal with the newlines correctly so I don't think that's the issue. It looks like may you've deleted test_licstatactioncontainers.cpp and the first warning is about that. The second appears to be complaining about not finding the file itself.

Could this be a filename case issue? Windows is insensitive to filename case, but linux isn't. Is the file actually called Test_LicenceServerUsageMap.cpp on linux perchance? Or the directory LicStat/Test ?

一口甜 2024-09-14 18:41:15

尝试使用 dos2unix 命令将补丁文件中的行结尾从 DOS 转换为 Unix。

Try converting the line endings in the patch file from DOS to Unix, using the dos2unix command.

洋洋洒洒 2024-09-14 18:41:15

当您在 Unix 系统上时,当本地文件格式为 CRLF 而不是 LF 时,可能会发生此类错误。

patch 尝试使 svn diff 补丁适应 unix 文件格式,但当本地文件处于 dos 模式时会出错,当您在 dos 和 unix 环境之间共享代码库时可能会发生这种情况。

对我有用的是首先转换所有受影响的文件,例如:

grep ^+++ patchfile.patch | awk '{print $2}' | dos2unix

然后应用补丁:

patch -p0 < patchfile.patch

That type of error can occur when the local file format is CRLF instead of LF when you're on a unix system.

patch tries to adapt the svn diff patch to the unix file format but trips up when the local files are in dos mode, which can happen when you share code bases between dos and unix environments.

What works for me is to first convert all the files about to be affected, for example:

grep ^+++ patchfile.patch | awk '{print $2}' | dos2unix

And then to apply the patch:

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