Context: I'm doing a merge, and fixed the conflicts manually. Now I'm trying to stage changes hunk-by-hunk and make a commit.

Issue: some hunks are not getting staged.

Here's the output from magit-process buffer

git … apply --cached -p0 --ignore-space-change -

error: patch failed: filename.cpp:1302

error: filename.cpp: patch does not apply

I was wondering what can be done to fix or investigate the issue. This is happening on Spacemacs on Fedora.

With some experimentation, I've found that this issue only happens when the flag --ignore-all-space is set, i.e., if I unset this, then I can stage the same hunk.

edit: This could be a possible bug since I could reproduce it on a smaller issue. I've made a bug-report here

  • Does the hunk in question have non-space differences?
    – Willy Lee
    Oct 1, 2018 at 22:22
  • @WillyLee. The hunk in question does have non-space differences. I'll try to see if I can form a minimal example. I suspect this could be a bug.
    – hrkrshnn
    Oct 2, 2018 at 10:07

1 Answer 1


Magit now automatically uses git apply -C0 ... when appropriate. That causes the context lines to be ignored and as a result patches that ignore some whitespace changes apply again.

2.92.0 will be the first release to support this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.