Skip to content

Commit d509802

Browse files
newrengitster
authored andcommitted
merge-ort: preserve cached renames for the appropriate side
Previous commits created an in-memory cache of the results of rename detection, and added logic to detect when that cache could appropriately be used in a subsequent merge operation -- but we were still unconditionally clearing the cache with each new merge operation anyway. If it is valid to reuse the cache from one of the two sides of history, preserve that side. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 19ceb48 commit d509802

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

merge-ort.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -486,17 +486,18 @@ static void clear_or_reinit_internal_opts(struct merge_options_internal *opti,
486486
/* Free memory used by various renames maps */
487487
for (i = MERGE_SIDE1; i <= MERGE_SIDE2; ++i) {
488488
strintmap_func(&renames->dirs_removed[i]);
489-
490-
partial_clear_dir_rename_count(&renames->dir_rename_count[i]);
491-
if (!reinitialize)
492-
strmap_clear(&renames->dir_rename_count[i], 1);
493-
494489
strmap_func(&renames->dir_renames[i], 0);
495-
496490
strintmap_func(&renames->relevant_sources[i]);
497-
strset_func(&renames->cached_target_names[i]);
498-
strmap_func(&renames->cached_pairs[i], 1);
499-
strset_func(&renames->cached_irrelevant[i]);
491+
if (!reinitialize)
492+
assert(renames->cached_pairs_valid_side == 0);
493+
if (i != renames->cached_pairs_valid_side) {
494+
strset_func(&renames->cached_target_names[i]);
495+
strmap_func(&renames->cached_pairs[i], 1);
496+
strset_func(&renames->cached_irrelevant[i]);
497+
partial_clear_dir_rename_count(&renames->dir_rename_count[i]);
498+
if (!reinitialize)
499+
strmap_clear(&renames->dir_rename_count[i], 1);
500+
}
500501
}
501502
renames->cached_pairs_valid_side = 0;
502503
renames->dir_rename_mask = 0;
@@ -2456,6 +2457,7 @@ static void detect_regular_renames(struct merge_options *opt,
24562457
return;
24572458
}
24582459

2460+
partial_clear_dir_rename_count(&renames->dir_rename_count[side_index]);
24592461
repo_diff_setup(opt->repo, &diff_opts);
24602462
diff_opts.flags.recursive = 1;
24612463
diff_opts.flags.rename_empty = 0;

0 commit comments

Comments
 (0)