- ri->head_renames = get_renames(o, head, common, head, merge, entries);
- ri->merge_renames = get_renames(o, merge, common, head, merge, entries);
- return process_renames(o, ri->head_renames, ri->merge_renames);
+ head_pairs = get_diffpairs(o, common, head);
+ merge_pairs = get_diffpairs(o, common, merge);
+
+ ri->head_renames = get_renames(o, head_pairs, head,
+ common, head, merge, entries);
+ ri->merge_renames = get_renames(o, merge_pairs, merge,
+ common, head, merge, entries);
+ clean = process_renames(o, ri->head_renames, ri->merge_renames);
+
+ /*
+ * Some cleanup is deferred until cleanup_renames() because the
+ * data structures are still needed and referenced in
+ * process_entry(). But there are a few things we can free now.
+ */
+
+ free(head_pairs->queue);
+ free(head_pairs);
+ free(merge_pairs->queue);
+ free(merge_pairs);
+
+ return clean;