Trailing space patch does not apply

I have 3 files a\test.txt, b\test.txtand 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

The result of 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 to c\test.txt:

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

I get an error message:

../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 read a bunch of posts here on SO, but still failed to get him to apply any ideas?

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

+4
source share
1 answer

The fact that the patch is not applied is not associated with a trailing space.

The patch tries to delete the lines yand z, but zdoes not exist in the file to which you are trying to apply it ( c/text.txt).

Something like the following:

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
+2
source

Source: https://habr.com/ru/post/1606398/


All Articles