summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2021-02-27 01:30:43 +0100
committerJunio C Hamano <gitster@pobox.com>2021-02-27 02:53:11 +0100
commitcd52e0050f0aa18bb35cda08f2dcbe94943df2cf (patch)
treec891379e2d92daad57fffaa88209685e735cde8f
parentMove computation of dir_rename_count from merge-ort to diffcore-rename (diff)
downloadgit-cd52e0050f0aa18bb35cda08f2dcbe94943df2cf.tar.xz
git-cd52e0050f0aa18bb35cda08f2dcbe94943df2cf.zip
diffcore-rename: add function for clearing dir_rename_count
As we adjust the usage of dir_rename_count we want to have a function for clearing, or partially clearing it out. Add a partial_clear_dir_rename_count() function for this purpose. Reviewed-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--diffcore-rename.c12
-rw-r--r--diffcore.h2
-rw-r--r--merge-ort.c12
3 files changed, 17 insertions, 9 deletions
diff --git a/diffcore-rename.c b/diffcore-rename.c
index 39e23d57e7..7dd475ff9a 100644
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -528,6 +528,18 @@ static void initialize_dir_rename_info(struct dir_rename_info *info)
}
}
+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);
+}
+
static void cleanup_dir_rename_info(struct dir_rename_info *info)
{
if (!info->setup)
diff --git a/diffcore.h b/diffcore.h
index db55d38530..c6ba64abd1 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 c4467e073b..467404cc0a 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);
}