"fatal: corrupt patch at line XX" when staging single line
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.
Actually, this often happens when you edit '-' lines.
When you remove '-' and forget to add ' ' (space) instead of it
Or, by mistake, you add two spaces and you use 'tabs' as identation
Open your patch and check that all lines you want to leave untouched are started with ' ' (one space)
I have saw that some people use --ignore-space-change
--ignore-whitespace
--whitespace=fix
as workaround but this is another thing you must not mix into.
Open your patch and check that all lines you want to leave untouched are started with ' ' (space)
UPD
it also possible your editor has option: "Delete spaces at end line"So, when you in your editor save patch:
-Line with space at end <--- NOTICE: Here one space at the end+Line with no space at end<--- Here no space
Your editor remove trailing space and patch become like this:
-Line with space at end<--- Here no space. Patch will FAIL!!!+Line with no space at end<--- Here no space also
This patch will FAIL because origin file has no line:
-Line with space at end<---
it has:
-Line with space at end <---
UPD2
So if in your patch in next line
android:tileMode="repeat"
Your editor remove trainling space. Patch will FAIL
Git GUI fails to add/remove lines from the index when the chunk you are working with is too big (i.e. too many successive lines modified).
My workaround : if the changes are not a "wall of pink" (if there are some unmodified lines in the middle of the chunk), go to edit > options and reduce the number of lines in the context of diffs. If this doesn't work, you are screwed ; use an other tool (like the command line for instance).