libgit2/libgit2 — pull request #2096 by ethomson (2014-02-01 21:13:38+00:00)
Title: Corrections for merge working directory validation

`git_merge` validates the working directory status before returning - changes *may* exist in the working directory provided they are to files that are not affected by the merge. (Those changes would be overrwitten.) We were previously comparing `HEAD` to the working directory, which is incorrect because:

1. Bypassing the index's cache implies that we will compare the filtered contents out of `HEAD` to the contents of the working directory. If (our) filter disagreed with the filter implementation that placed the contents on disk, then we would erroneously report those files as changed. Using the timestamp/file size contents of the cache means that we will trust the other implementation's filter.
2. We would erroneously report staged changes as having changes in the working directory. (One can have staged changes when performing a merge when the staged change matches the merge result.)
3. It's slow.

We should have been comparing the index to the working directory all along. This PR also adds tests around merging with a dirty working directory or a dirty index.