@@ -652,7 +652,10 @@ static int process_renames(struct merge_options *opt,
652
652
653
653
static int compare_pairs (const void * a_ , const void * b_ )
654
654
{
655
- die ("Not yet implemented." );
655
+ const struct diff_filepair * a = * ((const struct diff_filepair * * )a_ );
656
+ const struct diff_filepair * b = * ((const struct diff_filepair * * )b_ );
657
+
658
+ return strcmp (a -> one -> path , b -> one -> path );
656
659
}
657
660
658
661
/* Call diffcore_rename() to compute which files have changed on given side */
@@ -698,7 +701,35 @@ static int collect_renames(struct merge_options *opt,
698
701
struct diff_queue_struct * result ,
699
702
unsigned side_index )
700
703
{
701
- die ("Not yet implemented." );
704
+ int i , clean = 1 ;
705
+ struct diff_queue_struct * side_pairs ;
706
+ struct rename_info * renames = & opt -> priv -> renames ;
707
+
708
+ side_pairs = & renames -> pairs [side_index ];
709
+
710
+ for (i = 0 ; i < side_pairs -> nr ; ++ i ) {
711
+ struct diff_filepair * p = side_pairs -> queue [i ];
712
+
713
+ if (p -> status != 'R' ) {
714
+ diff_free_filepair (p );
715
+ continue ;
716
+ }
717
+
718
+ /*
719
+ * p->score comes back from diffcore_rename_extended() with
720
+ * the similarity of the renamed file. The similarity is
721
+ * was used to determine that the two files were related
722
+ * and are a rename, which we have already used, but beyond
723
+ * that we have no use for the similarity. So p->score is
724
+ * now irrelevant. However, process_renames() will need to
725
+ * know which side of the merge this rename was associated
726
+ * with, so overwrite p->score with that value.
727
+ */
728
+ p -> score = side_index ;
729
+ result -> queue [result -> nr ++ ] = p ;
730
+ }
731
+
732
+ return clean ;
702
733
}
703
734
704
735
static int detect_and_process_renames (struct merge_options * opt ,
0 commit comments