diffcore-rename: compute dir_rename_counts in stages
Compute dir_rename_counts based just on exact renames to start, as that
can provide us useful information in find_basename_matches(). This is
done by moving the code from compute_dir_rename_counts() into
initialize_dir_rename_info(), resulting in it being computed earlier and
based just on exact renames. Since that's an incomplete result, we
augment the counts via calling update_dir_rename_counts() after each
basename-guide and inexact rename detection match is found.
Reviewed-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Elijah Newren4 years agocommitted byJunio C Hamano
static int find_basename_matches(struct diff_options *options,
int minimum_score,
struct dir_rename_info *info)
struct dir_rename_info *info,
struct strset *dirs_removed)
{
/*
* When I checked in early 2020, over 76% of file renames in linux
@ -810,6 +830,8 @@ static int find_basename_matches(struct diff_options *options,
@@ -810,6 +830,8 @@ static int find_basename_matches(struct diff_options *options,
continue;
record_rename_pair(dst_index, src_index, score);
renames++;
update_dir_rename_counts(info, dirs_removed,
one->path, two->path);
/*
* Found a rename so don't need text anymore; if we
@ -893,7 +915,12 @@ static int too_many_rename_candidates(int num_destinations, int num_sources,
@@ -893,7 +915,12 @@ static int too_many_rename_candidates(int num_destinations, int num_sources,
return 1;
}
static int find_renames(struct diff_score *mx, int dst_cnt, int minimum_score, int copies)
static int find_renames(struct diff_score *mx,
int dst_cnt,
int minimum_score,
int copies,
struct dir_rename_info *info,
struct strset *dirs_removed)
{
int count = 0, i;
@ -910,6 +937,9 @@ static int find_renames(struct diff_score *mx, int dst_cnt, int minimum_score, i
@@ -910,6 +937,9 @@ static int find_renames(struct diff_score *mx, int dst_cnt, int minimum_score, i