title: git-apply fails mysteriously, how do I troubleshoot/fix?
body: <p>I'm currently trying to to code-style checking on the PRs of a (github) repository, and I want to deliver patches to the submitters with which they can easily fix the codestyle. To this end, I'm pulling down their PR, run our uncrustify script over it to fix any style errors, and want to create a .patch file they can easily apply. However, it consistently breaks on some files.</p>
  
  <p>I do (git version 1.7.10.4 with <code>core.autocrlf=input</code>, <code>core.filemode=false</code>):</p>
  
  <pre><code>$ git checkout pr-branch
  $ git log -1 (shows: commit dbb8d3f)
  $ git status (nothing to commit, working directory clean)
  $ &lt;run the code styler script, which modifies some files&gt;
  $ git diff &gt; ../style.patch (so the patch file lands outside the repo)
  $ git reset --hard HEAD (to simulate the situation at the submitter's end)
  $ git log -1 (shows: commit dbb8d3f)
  $ git status (nothing to commit, working directory clean, so we are where we started)
  $ git apply ../style.patch
  error: patch failed: somefile.cpp:195
  error: somefile.cpp: patch does not apply (same output using the --check option)
  </code></pre>
  
  <p>This only applies to some files, not all of them. I don't know how to troubleshoot this, i.e. how to get git to tell me exactly where it goes wrong - it only tells me a hunk# when I dig, but that's still pretty huge.</p>
  
  <p>What I've tried so far (without success): </p>
  
  <ol>
  <li><code>apply --reverse</code>, <code>apply --whitespace=nowarn</code></li>
  <li><code>diff HEAD</code> instead of <code>diff</code> alone</li>
  <li>make a dummy commit (committing works without problem!), use <code>format-patch</code>, delete the dummy commit, apply patch with <code>git-am</code> with or without <code>-3</code>, or apply with  <code>git-apply</code></li>
  <li>Have the patch file in the local dir instead of one up (grasping at straws, here)</li>
  <li>Check the man-pages of git-diff, -apply, -format-patch, -am for anything useful</li>
  <li>patch with the linux <code>patch</code> command</li>
  <li>....</li>
  </ol>
  
  <p>I don't know what could be wrong with the diff. Whitespace things should only warn, right? In any case, I won't want to ignore them, since it's a style fix which obviously involves whitespace.</p>
  
  <p>How can I fix/diagnose this or even find out where it bails exactly? Would it help if I posted the diff of one of the culprit files? What baffles me also is that the committ works without problem, but the patch created from the commit does not??</p>
  
  <p>After wrestling with this for several hours I'm at the end of my knowledge...</p>