Skip to content

Commit 3ffbe5a

Browse files
newrengitster
authored andcommitted
merge-ort: shuffle the computation and cleanup of potential collisions
Run compute_collisions() for renames on both sides of history before any calls to collect_renames(), and do not free the computed collisions until after both calls to collect_renames(). This is just a code reorganization at this point that doesn't make sense on its own, but will permit us to use the computed collision info from both sides within each call to collect_renames() in a subsequent commit. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6dd1f0e commit 3ffbe5a

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

merge-ort.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2335,7 +2335,8 @@ static char *check_for_directory_rename(struct merge_options *opt,
23352335
}
23362336

23372337
new_path = handle_path_level_conflicts(opt, path, side_index,
2338-
rename_info, collisions);
2338+
rename_info,
2339+
&collisions[side_index]);
23392340
*clean_merge &= (new_path != NULL);
23402341

23412342
return new_path;
@@ -3044,16 +3045,15 @@ static int detect_regular_renames(struct merge_options *opt,
30443045
static int collect_renames(struct merge_options *opt,
30453046
struct diff_queue_struct *result,
30463047
unsigned side_index,
3048+
struct strmap *collisions,
30473049
struct strmap *dir_renames_for_side,
30483050
struct strmap *rename_exclusions)
30493051
{
30503052
int i, clean = 1;
3051-
struct strmap collisions;
30523053
struct diff_queue_struct *side_pairs;
30533054
struct rename_info *renames = &opt->priv->renames;
30543055

30553056
side_pairs = &renames->pairs[side_index];
3056-
compute_collisions(&collisions, dir_renames_for_side, side_pairs);
30573057

30583058
for (i = 0; i < side_pairs->nr; ++i) {
30593059
struct diff_filepair *p = side_pairs->queue[i];
@@ -3069,7 +3069,7 @@ static int collect_renames(struct merge_options *opt,
30693069
side_index,
30703070
dir_renames_for_side,
30713071
rename_exclusions,
3072-
&collisions,
3072+
collisions,
30733073
&clean);
30743074

30753075
possibly_cache_new_pair(renames, p, side_index, new_path);
@@ -3095,7 +3095,6 @@ static int collect_renames(struct merge_options *opt,
30953095
result->queue[result->nr++] = p;
30963096
}
30973097

3098-
free_collisions(&collisions);
30993098
return clean;
31003099
}
31013100

@@ -3106,6 +3105,7 @@ static int detect_and_process_renames(struct merge_options *opt,
31063105
{
31073106
struct diff_queue_struct combined = { 0 };
31083107
struct rename_info *renames = &opt->priv->renames;
3108+
struct strmap collisions[3];
31093109
int need_dir_renames, s, i, clean = 1;
31103110
unsigned detection_run = 0;
31113111

@@ -3155,12 +3155,22 @@ static int detect_and_process_renames(struct merge_options *opt,
31553155
ALLOC_GROW(combined.queue,
31563156
renames->pairs[1].nr + renames->pairs[2].nr,
31573157
combined.alloc);
3158+
for (i = MERGE_SIDE1; i <= MERGE_SIDE2; i++) {
3159+
int other_side = 3 - i;
3160+
compute_collisions(&collisions[i],
3161+
&renames->dir_renames[other_side],
3162+
&renames->pairs[i]);
3163+
}
31583164
clean &= collect_renames(opt, &combined, MERGE_SIDE1,
3165+
collisions,
31593166
&renames->dir_renames[2],
31603167
&renames->dir_renames[1]);
31613168
clean &= collect_renames(opt, &combined, MERGE_SIDE2,
3169+
collisions,
31623170
&renames->dir_renames[1],
31633171
&renames->dir_renames[2]);
3172+
for (i = MERGE_SIDE1; i <= MERGE_SIDE2; i++)
3173+
free_collisions(&collisions[i]);
31643174
STABLE_QSORT(combined.queue, combined.nr, compare_pairs);
31653175
trace2_region_leave("merge", "directory renames", opt->repo);
31663176

0 commit comments

Comments
 (0)