Skip to content

Commit 0532a5e

Browse files
author
Junio C Hamano
committed
diffcore-break: do not break too small filepair.
Somehow we checked only one side and not the other. By checking the filesize upfront, we can bypass generating delta unnecessarily. Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 86c9523 commit 0532a5e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

diffcore-break.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ static int should_break(struct diff_filespec *src,
6262
return 0; /* error but caught downstream */
6363

6464
base_size = ((src->size < dst->size) ? src->size : dst->size);
65+
if (base_size < MINIMUM_BREAK_SIZE)
66+
return 0; /* we do not break too small filepair */
6567

6668
delta = diff_delta(src->data, src->size,
6769
dst->data, dst->size,
@@ -170,8 +172,7 @@ void diffcore_break(int break_score)
170172
!S_ISDIR(p->one->mode) && !S_ISDIR(p->two->mode) &&
171173
!strcmp(p->one->path, p->two->path)) {
172174
if (should_break(p->one, p->two,
173-
break_score, &score) &&
174-
MINIMUM_BREAK_SIZE <= p->one->size) {
175+
break_score, &score)) {
175176
/* Split this into delete and create */
176177
struct diff_filespec *null_one, *null_two;
177178
struct diff_filepair *dp;

0 commit comments

Comments
 (0)