尾随空白。(trailing whitespace. patch does not apply)

编程入门 行业动态 更新时间:2024-10-27 14:31:01
尾随空白。(trailing whitespace. patch does not apply)

我有3个文件a\test.txt , b\test.txt和c\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

我收到错误:

../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

我在这里阅读了一些帖子,但仍然没有设法让它应用任何想法?

我在mypatch.patch中看不到任何尾随空格

I have 3 files a\test.txt, b\test.txt and c\test.txt:

a\test.txt :

x y z

b\test.txt :

x z p q

c\test.txt :

x y

Now I created a patch between a and b:

git diff --no-prefix --binary a b > mypatch.patch

Resulting in this 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

Next I want to apply mypatch.patch on c\test.txt:

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

I have read a bunch of post here on SO but have still not managed to get it applied any ideas?

I don't see any trailing spaces in mypatch.patch

最满意答案

修补程序不适用的事实与末尾的空白无关。

该修补程序尝试删除y和z行,但z不存在于您要应用它的文件中( c/text.txt )。

类似于以下内容将适用于:

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

The fact that the patch does not apply is not related to the trailing whitespace.

The patch tries to remove the y and z lines, but z does not exist in the file you're trying to apply it to (c/text.txt).

Something like the following would apply :

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

更多推荐

本文发布于:2023-07-23 11:58:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1231601.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:空白   trailing   whitespace   patch   apply

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!