"fatal: corrupt patch at line XX" when staging single line

Kirill Kulakov picture Kirill Kulakov · Aug 27, 2012 · Viewed 25.6k times · Source

I'm getting the following error when I'm trying to stage a single line or multiple lines using the git gui (right click -> stage lines for commit). It's not the first time it occure to me, and I've found others facing it.However I couldn't find how to solve it.

Did any one ever encountered this problem? is there something I can do (staging all the file is not a real solution)

Update: Here is a file which gives me the following error when I try to stage the deleted line.

@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android" 
    android:src="@drawable/texture"
    android:tileMode="repeat"
-   android:dither="true"
    >
</bitmap>
\ No newline at end of file

Here is the error message:

fatal: corrupt patch at line 14

strangely the following fine doesn't even have 14 line!? note ending file with a new line didn't solve the problem

Answer

Kyle picture Kyle · Sep 23, 2012

Apparently Git GUI requires that files end with a newline when staging individual lines.

I'm pretty sure that at at least one point in time, staging individual lines was ok even without a newline at the end of the file, but apparently that's no longer possible. Just ran into this problem myself, having newlines at the end of the file fixes it, and removing them causes it.