Merge branch 'jk/test-send-sh-x-trace-elsewhere'
[gitweb.git] / diffcore-rename.c
index 3b3c1ed535e7c8b17947d69dbe0bd5c8f115cf2d..7f03eb5a0404d4b44f292fba76433dfec74dcd44 100644 (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 */