@@ -73,11 +73,10 @@ static struct diff_rename_src {
73
73
} * rename_src ;
74
74
static int rename_src_nr , rename_src_alloc ;
75
75
76
- static struct diff_rename_src * register_rename_src (struct diff_filepair * p )
76
+ static struct diff_rename_src * locate_rename_src (struct diff_filespec * one ,
77
+ int insert_ok )
77
78
{
78
79
int first , last ;
79
- struct diff_filespec * one = p -> one ;
80
- unsigned short score = p -> score ;
81
80
82
81
first = 0 ;
83
82
last = rename_src_nr ;
@@ -94,17 +93,30 @@ static struct diff_rename_src *register_rename_src(struct diff_filepair *p)
94
93
first = next + 1 ;
95
94
}
96
95
96
+ if (!insert_ok )
97
+ return NULL ;
98
+
97
99
/* insert to make it at "first" */
98
100
ALLOC_GROW (rename_src , rename_src_nr + 1 , rename_src_alloc );
99
101
rename_src_nr ++ ;
100
102
if (first < rename_src_nr )
101
103
memmove (rename_src + first + 1 , rename_src + first ,
102
104
(rename_src_nr - first - 1 ) * sizeof (* rename_src ));
103
- rename_src [first ].p = p ;
104
- rename_src [first ].score = score ;
105
105
return & (rename_src [first ]);
106
106
}
107
107
108
+ static struct diff_rename_src * register_rename_src (struct diff_filepair * p )
109
+ {
110
+ struct diff_filespec * one = p -> one ;
111
+ struct diff_rename_src * src ;
112
+
113
+ src = locate_rename_src (one , 1 );
114
+
115
+ src -> p = p ;
116
+ src -> score = p -> score ;
117
+ return src ;
118
+ }
119
+
108
120
static int basename_same (struct diff_filespec * src , struct diff_filespec * dst )
109
121
{
110
122
int src_len = strlen (src -> path ), dst_len = strlen (dst -> path );
@@ -584,9 +596,12 @@ void diffcore_rename(struct diff_options *options)
584
596
free (mx );
585
597
586
598
cleanup :
587
- /* At this point, we have found some renames and copies and they
599
+ /*
600
+ * At this point, we have found some renames and copies and they
588
601
* are recorded in rename_dst. The original list is still in *q.
589
602
*/
603
+ diff_debug_queue ("begin turning a/d into renames" , q );
604
+
590
605
DIFF_QUEUE_CLEAR (& outq );
591
606
for (i = 0 ; i < q -> nr ; i ++ ) {
592
607
struct diff_filepair * p = q -> queue [i ];
@@ -599,8 +614,9 @@ void diffcore_rename(struct diff_options *options)
599
614
/*
600
615
* Creation
601
616
*
602
- * We would output this create record if it has
603
- * not been turned into a rename/copy already.
617
+ * Did the content come from somewhere else?
618
+ * If so, show that as a rename. Otherwise
619
+ * show it as a creation (i.e. as-is).
604
620
*/
605
621
struct diff_rename_dst * dst = locate_rename_dst (p -> two );
606
622
if (dst && dst -> pair ) {
@@ -658,11 +674,10 @@ void diffcore_rename(struct diff_options *options)
658
674
if (pair_to_free )
659
675
diff_free_filepair (pair_to_free );
660
676
}
661
- diff_debug_queue ("done copying original" , & outq );
662
677
663
678
free (q -> queue );
664
679
* q = outq ;
665
- diff_debug_queue ("done collapsing " , q );
680
+ diff_debug_queue ("end turning a/d into renames " , q );
666
681
667
682
for (i = 0 ; i < rename_dst_nr ; i ++ )
668
683
free_filespec (rename_dst [i ].two );
0 commit comments