From: Junio C Hamano Date: Fri, 29 Apr 2016 21:15:55 +0000 (-0700) Subject: Merge branch 'sg/diff-multiple-identical-renames' into maint X-Git-Tag: v2.8.2~7 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/b96c396cce05c9559f335d5ed6856687036e01ba?hp=-c Merge branch 'sg/diff-multiple-identical-renames' into maint "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 --- b96c396cce05c9559f335d5ed6856687036e01ba diff --combined diffcore-rename.c index 3b3c1ed535,69fcf77be0..7f03eb5a04 --- a/diffcore-rename.c +++ b/diffcore-rename.c @@@ -340,9 -340,11 +340,11 @@@ static int find_exact_renames(struct di 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 */ @@@ -537,7 -539,7 +539,7 @@@ void diffcore_rename(struct diff_option rename_dst_nr * rename_src_nr, 50, 1); } - mx = xcalloc(num_create * NUM_CANDIDATE_PER_DST, sizeof(*mx)); + mx = xcalloc(st_mult(num_create, NUM_CANDIDATE_PER_DST), sizeof(*mx)); for (dst_cnt = i = 0; i < rename_dst_nr; i++) { struct diff_filespec *two = rename_dst[i].two; struct diff_score *m;