]> git.ipfire.org Git - thirdparty/git.git/commitdiff
diffcore-rename: add function for clearing dir_rename_count
authorElijah Newren <newren@gmail.com>
Sat, 27 Feb 2021 00:30:43 +0000 (00:30 +0000)
committerJunio C Hamano <gitster@pobox.com>
Sat, 27 Feb 2021 01:53:11 +0000 (17:53 -0800)
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>
diffcore-rename.c
diffcore.h
merge-ort.c

index 39e23d57e7bcc844ae2d42bc5127ff3b0335cdb1..7dd475ff9a9f8e8dda8421cf52950e88bf1446ec 100644 (file)
@@ -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)
index db55d3853071790884ed7b8cbde440c96f7373b9..c6ba64abd198ac239069fa7c0fba5d42d0961604 100644 (file)
@@ -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,
index c4467e073b45da0c261bd9d297aee99400c9efd3..467404cc0a358c4187c7c8587b1c877c56aacbd2 100644 (file)
@@ -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);
        }