Merge branch 'jk/diff-rename'
* jk/diff-rename: diffcore-rename: cache file deltas
This commit is contained in:
commit
ff08c373dc
7
diff.c
7
diff.c
@ -1675,7 +1675,7 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void diff_free_filespec_data(struct diff_filespec *s)
|
||||
void diff_free_filespec_data_large(struct diff_filespec *s)
|
||||
{
|
||||
if (s->should_free)
|
||||
free(s->data);
|
||||
@ -1686,6 +1686,11 @@ void diff_free_filespec_data(struct diff_filespec *s)
|
||||
s->should_free = s->should_munmap = 0;
|
||||
s->data = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void diff_free_filespec_data(struct diff_filespec *s)
|
||||
{
|
||||
diff_free_filespec_data_large(s);
|
||||
free(s->cnt_data);
|
||||
s->cnt_data = NULL;
|
||||
}
|
||||
|
@ -184,7 +184,8 @@ static int estimate_similarity(struct diff_filespec *src,
|
||||
if (base_size * (MAX_SCORE-minimum_score) < delta_size * MAX_SCORE)
|
||||
return 0;
|
||||
|
||||
if (diff_populate_filespec(src, 0) || diff_populate_filespec(dst, 0))
|
||||
if ((!src->cnt_data && diff_populate_filespec(src, 0))
|
||||
|| (!dst->cnt_data && diff_populate_filespec(dst, 0)))
|
||||
return 0; /* error but caught downstream */
|
||||
|
||||
|
||||
@ -377,10 +378,10 @@ void diffcore_rename(struct diff_options *options)
|
||||
m->score = estimate_similarity(one, two,
|
||||
minimum_score);
|
||||
m->name_score = basename_same(one, two);
|
||||
diff_free_filespec_data(one);
|
||||
diff_free_filespec_data_large(one);
|
||||
}
|
||||
/* We do not need the text anymore */
|
||||
diff_free_filespec_data(two);
|
||||
diff_free_filespec_data_large(two);
|
||||
dst_cnt++;
|
||||
}
|
||||
/* cost matrix sorted by most to least similar pair */
|
||||
|
@ -48,6 +48,7 @@ extern void fill_filespec(struct diff_filespec *, const unsigned char *,
|
||||
|
||||
extern int diff_populate_filespec(struct diff_filespec *, int);
|
||||
extern void diff_free_filespec_data(struct diff_filespec *);
|
||||
extern void diff_free_filespec_data_large(struct diff_filespec *);
|
||||
extern int diff_filespec_is_binary(struct diff_filespec *);
|
||||
|
||||
struct diff_filepair {
|
||||
|
Loading…
Reference in New Issue
Block a user