From: Elijah Newren <newren@xxxxxxxxx> As we adjust the usage of dir_rename_count we want to have functions for clearing, or partially clearing it out. Add such functions. Signed-off-by: Elijah Newren <newren@xxxxxxxxx> --- diffcore-rename.c | 19 +++++++++++++++++++ diffcore.h | 2 ++ merge-ort.c | 12 +++--------- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/diffcore-rename.c b/diffcore-rename.c index 33cfc5848611..614a8d63012d 100644 --- a/diffcore-rename.c +++ b/diffcore-rename.c @@ -486,6 +486,25 @@ static void compute_dir_rename_counts(struct strmap *dir_rename_count, } } +void partial_clear_dir_rename_count(struct strmap *dir_rename_count) +{ + struct hashmap_iter iter; + struct strmap_entry *entry; + + strmap_for_each_entry(dir_rename_count, &iter, entry) { + struct strintmap *counts = entry->value; + strintmap_clear(counts); + } + strmap_partial_clear(dir_rename_count, 1); +} + +MAYBE_UNUSED +static void clear_dir_rename_count(struct strmap *dir_rename_count) +{ + partial_clear_dir_rename_count(dir_rename_count); + strmap_clear(dir_rename_count, 1); +} + static const char *get_basename(const char *filename) { /* diff --git a/diffcore.h b/diffcore.h index db55d3853071..c6ba64abd198 100644 --- a/diffcore.h +++ b/diffcore.h @@ -161,6 +161,8 @@ struct diff_filepair *diff_queue(struct diff_queue_struct *, struct diff_filespec *); void diff_q(struct diff_queue_struct *, struct diff_filepair *); +void partial_clear_dir_rename_count(struct strmap *dir_rename_count); + void diffcore_break(struct repository *, int); void diffcore_rename(struct diff_options *); void diffcore_rename_extended(struct diff_options *options, diff --git a/merge-ort.c b/merge-ort.c index c4467e073b45..467404cc0a35 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -351,17 +351,11 @@ static void clear_or_reinit_internal_opts(struct merge_options_internal *opti, /* Free memory used by various renames maps */ for (i = MERGE_SIDE1; i <= MERGE_SIDE2; ++i) { - struct hashmap_iter iter; - struct strmap_entry *entry; - strset_func(&renames->dirs_removed[i]); - strmap_for_each_entry(&renames->dir_rename_count[i], - &iter, entry) { - struct strintmap *counts = entry->value; - strintmap_clear(counts); - } - strmap_func(&renames->dir_rename_count[i], 1); + partial_clear_dir_rename_count(&renames->dir_rename_count[i]); + if (!reinitialize) + strmap_clear(&renames->dir_rename_count[i], 1); strmap_func(&renames->dir_renames[i], 0); } -- gitgitgadget