尾随空格。补丁不适用。

6
我很乐意为您翻译中文,以下是您需要翻译的内容:

我有三个文件a\test.txtb\test.txtc\test.txt

a\test.txt

x
y
z

b\test.txt :

x
z
p
q

c\test.txt :

x
y

现在我已经创建了一个在a和b之间的补丁:
git diff --no-prefix --binary a b > mypatch.patch

导致此补丁的产生:
diff --git a/test.txt b/test.txt
index 1b2c8f8..e0b3aec 100644
--- a/test.txt
+++ b/test.txt
@@ -1,3 +1,4 @@
 x
-y
-z
\ No newline at end of file
+z
+p
+q
\ No newline at end of file

接下来我想要在c\test.txt上应用mypatch.patch补丁:

cd c:\
git apply --ignore-space-change --ignore-whitespace ../mypatch.patch

I get the error:

../mypatch.patch:10: trailing whitespace.
z
../mypatch.patch:11: trailing whitespace.
p
error: patch failed: test.txt:1
error: test.txt: patch does not apply

我在SO上读了很多帖子,但仍然没有成功应用它的想法。有什么建议吗?

我在mypatch.patch中没有看到任何尾随空格。

2个回答

3

补丁无法应用并不与拖尾空格有关。

该补丁试图删除yz行,但是在您尝试应用它的文件中(c/text.txt)不存在z

应用以下内容可以解决问题:

diff --git a/test.txt b/test.txt
index 66455a1..1a0d96d 100644
--- a/test.txt
+++ b/test.txt
@@ -1,2 +1,4 @@
 x
-y
\ No newline at end of file
+z
+p
+q
\ No newline at end of file

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接