Skip to content

Commit ce2a341

Browse files
author
Junio C Hamano
committed
Merge jc/diff leftover bits.
2 parents ba23bbc + 1706306 commit ce2a341

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

diffcore-rename.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -170,19 +170,15 @@ static int estimate_similarity(struct diff_filespec *src,
170170
&src_copied, &literal_added))
171171
return 0;
172172

173-
/* Extent of damage */
174-
if (src->size + literal_added < src_copied)
175-
delta_size = 0;
176-
else
177-
delta_size = (src->size - src_copied) + literal_added;
178-
179-
/*
180-
* Now we will give some score to it. 100% edit gets 0 points
181-
* and 0% edit gets MAX_SCORE points.
173+
/* How similar are they?
174+
* what percentage of material in dst are from source?
182175
*/
183-
score = MAX_SCORE - (MAX_SCORE * delta_size / base_size);
184-
if (score < 0) return 0;
185-
if (MAX_SCORE < score) return MAX_SCORE;
176+
if (dst->size < src_copied)
177+
score = MAX_SCORE;
178+
else if (!dst->size)
179+
score = 0; /* should not happen */
180+
else
181+
score = src_copied * MAX_SCORE / dst->size;
186182
return score;
187183
}
188184

0 commit comments

Comments
 (0)