torbiak/git-autofixup

"corrupt patch" error re-adding a newline at the end of a file

torbiak opened this issue · 2 comments

@campbellr was adding back a newline at the end of a file that had been removed in a previous commit and received a "corrupt patch" error.

I'm guessing the patch is being represented as a list containing a single empty string, and joining that with newlines produces...an empty string, which is an invalid patch for git.

My guess was way wrong: I was actually parsing hunks incorrectly and stopped collecting lines for a hunk when a "\ No newline at end of file" message was encountered.

Thanks @torbiak!