libgit2/libgit2 — pull request #1764 by ethomson (2013-08-05 20:16:53+00:00)
Title: Add rename from rewrites to status

Add rename from rewrites to status; core git enables this by default. eg:

% git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD ..." to unstage)
#
# renamed: b.txt -> a.txt
# renamed: a.txt -> b.txt
#

This adds a flag `GIT_STATUS_OPT_RENAMES_FROM_REWRITES` that causes diffs to break rewrites and perform rename detection on it.

Some new test cases indicate another bug: paired foreach was not joining deltas when there was a rename in the index->workdir diff. We always sorted index to rename deltas on new name, which will cause these deltas not to get paired because we sort head->index by the new (index) path and index->workdir by the new (workdir) path.

This change temporarily resorts the index->workdir diff list by the index (old) path so that we can track a rename in the workdir from head->index->workdir.