libgit2/libgit2 — pull request #1929 by arrbee (2013-10-31 21:57:09+00:00)
Title: Fix some observed problems with incorrect diffs

A couple of circumstances where incorrect diffs are being generated have come up.

1. The `GIT_DIFF_REVERSE` flag has been broken for a long time when it came to generating actual text diffs. The list of deltas was largely correct, but the logic for loading data was wrong and led to the incorrect text diff being generated. The fix for this caused the `git_diff_merge()` API to work incorrectly. I've also taken a stab at fixing that here, but it probably needs more thorough testing.
2. It is very easy to inadvertently diff with stale index data in the real world. This was compounded by the fact that I've told people that `git_index_read()` does a soft reload the index data (i.e. only reloads the data if the file on disk has changed), but that's not actually true - it always reloaded the data and discards in-memory changes. This PR addresses this problem via three changes:
* Add a parameter to `git_index_read()` to control if the read should be done always or only when the index file was externally modified outside of libgit2
* Make the diff functions that use the index automatically do a soft reload if they are not given an explicit index and are calling `git_repository_index` themselves internally
* Add a flag to status that can prevent this soft reload from being done if preferred