Merge branch 'sg/diff-multiple-identical-renames'

"git diff -M" used to work better when two originally identical
files A and B got renamed to X/A and X/B by pairing A to X/A and B
to X/B, but this was broken in the 2.0 timeframe.

* sg/diff-multiple-identical-renames:
  diffcore: fix iteration order of identical files during rename detection
This commit is contained in:
Junio C Hamano
2016-04-13 14:12:32 -07:00
2 changed files with 15 additions and 2 deletions

View File

@ -340,9 +340,11 @@ static int find_exact_renames(struct diff_options *options)
int i, renames = 0;
struct hashmap file_table;
/* Add all sources to the hash table */
/* Add all sources to the hash table in reverse order, because
* later on they will be retrieved in LIFO order.
*/
hashmap_init(&file_table, NULL, rename_src_nr);
for (i = 0; i < rename_src_nr; i++)
for (i = rename_src_nr-1; i >= 0; i--)
insert_file_table(&file_table, i, rename_src[i].p->one);
/* Walk the destinations and find best source match */