The Universe of Discourse

Wed, 28 Aug 2019

Why didn't git add -p work?

It has sometimes happened that I couldn't get my git add -p to work. I would carefully edit a chunk, and then Git would say

    Your edited hunk does not apply. Edit again (saying "no" discards!) [y/n]? e

or sometimes also

    error: patch fragment without header at line 33: @@ -26,21 +29,20 @@ class Parser():

so I'd do it over, and it still wouldn't work.

Today I learned that at least some of those are because Emacs's diff-mode has some bug. It's getting the @@ lines wrong. When I switched to text-mode and composed the @@ line myself, the patch applied.

[Other articles in category /prog] permanent link