aboutsummaryrefslogtreecommitdiff
path: root/diffcore-rename.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-04-29 14:15:55 -0700
committerJunio C Hamano <gitster@pobox.com>2016-04-29 14:15:55 -0700
commitb96c396cce05c9559f335d5ed6856687036e01ba (patch)
treedad57c5104b24d24e2d42c9a161af46cd5e408ed /diffcore-rename.c
parent3bb56a91be7d136f5f03902ea900185e01a2cdcb (diff)
parentca4e3ca029def86b7b29451d4ba77ef76574949e (diff)
downloadgit-b96c396cce05c9559f335d5ed6856687036e01ba.tar.gz
git-b96c396cce05c9559f335d5ed6856687036e01ba.tar.xz
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
Diffstat (limited to 'diffcore-rename.c')
-rw-r--r--diffcore-rename.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/diffcore-rename.c b/diffcore-rename.c
index 3b3c1ed53..7f03eb5a0 100644
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -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 */