Skip to content

Commit cd52e00

Browse files
newrengitster
authored andcommitted
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 <[email protected]> Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0c4fd73 commit cd52e00

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

diffcore-rename.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,18 @@ static void initialize_dir_rename_info(struct dir_rename_info *info)
528528
}
529529
}
530530

531+
void partial_clear_dir_rename_count(struct strmap *dir_rename_count)
532+
{
533+
struct hashmap_iter iter;
534+
struct strmap_entry *entry;
535+
536+
strmap_for_each_entry(dir_rename_count, &iter, entry) {
537+
struct strintmap *counts = entry->value;
538+
strintmap_clear(counts);
539+
}
540+
strmap_partial_clear(dir_rename_count, 1);
541+
}
542+
531543
static void cleanup_dir_rename_info(struct dir_rename_info *info)
532544
{
533545
if (!info->setup)

diffcore.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ struct diff_filepair *diff_queue(struct diff_queue_struct *,
161161
struct diff_filespec *);
162162
void diff_q(struct diff_queue_struct *, struct diff_filepair *);
163163

164+
void partial_clear_dir_rename_count(struct strmap *dir_rename_count);
165+
164166
void diffcore_break(struct repository *, int);
165167
void diffcore_rename(struct diff_options *);
166168
void diffcore_rename_extended(struct diff_options *options,

merge-ort.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -351,17 +351,11 @@ static void clear_or_reinit_internal_opts(struct merge_options_internal *opti,
351351

352352
/* Free memory used by various renames maps */
353353
for (i = MERGE_SIDE1; i <= MERGE_SIDE2; ++i) {
354-
struct hashmap_iter iter;
355-
struct strmap_entry *entry;
356-
357354
strset_func(&renames->dirs_removed[i]);
358355

359-
strmap_for_each_entry(&renames->dir_rename_count[i],
360-
&iter, entry) {
361-
struct strintmap *counts = entry->value;
362-
strintmap_clear(counts);
363-
}
364-
strmap_func(&renames->dir_rename_count[i], 1);
356+
partial_clear_dir_rename_count(&renames->dir_rename_count[i]);
357+
if (!reinitialize)
358+
strmap_clear(&renames->dir_rename_count[i], 1);
365359

366360
strmap_func(&renames->dir_renames[i], 0);
367361
}

0 commit comments

Comments
 (0)