From: Elijah Newren <newren@gmail•com>
To: git@vger•kernel.org
Cc: gitster@pobox•com, Elijah Newren <newren@gmail•com>
Subject: [PATCH 02/17] merge-ort: initialize and free new directory rename data structures
Date: Mon, 4 Jan 2021 15:49:51 -0800 [thread overview]
Message-ID: <20210104235006.2867404-3-newren@gmail.com> (raw)
In-Reply-To: <20210104235006.2867404-1-newren@gmail.com>
Signed-off-by: Elijah Newren <newren@gmail•com>
---
merge-ort.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/merge-ort.c b/merge-ort.c
index 719cc1c582..8b190b0ea5 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -311,8 +311,12 @@ static void free_strmap_strings(struct strmap *map)
static void clear_or_reinit_internal_opts(struct merge_options_internal *opti,
int reinitialize)
{
+ struct rename_info *renames = &opti->renames;
+ int i;
void (*strmap_func)(struct strmap *, int) =
reinitialize ? strmap_partial_clear : strmap_clear;
+ void (*strset_func)(struct strset *) =
+ reinitialize ? strset_partial_clear : strset_clear;
/*
* We marked opti->paths with strdup_strings = 0, so that we
@@ -342,6 +346,23 @@ static void clear_or_reinit_internal_opts(struct merge_options_internal *opti,
string_list_clear(&opti->paths_to_free, 0);
opti->paths_to_free.strdup_strings = 0;
+ /* 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);
+
+ strmap_func(&renames->dir_renames[i], 0);
+ }
+
if (!reinitialize) {
struct hashmap_iter iter;
struct strmap_entry *e;
@@ -2447,6 +2468,9 @@ static struct commit *make_virtual_commit(struct repository *repo,
static void merge_start(struct merge_options *opt, struct merge_result *result)
{
+ struct rename_info *renames;
+ int i;
+
/* Sanity checks on opt */
assert(opt->repo);
@@ -2481,6 +2505,17 @@ static void merge_start(struct merge_options *opt, struct merge_result *result)
/* Initialization of opt->priv, our internal merge data */
opt->priv = xcalloc(1, sizeof(*opt->priv));
+ /* Initialization of various renames fields */
+ renames = &opt->priv->renames;
+ for (i = MERGE_SIDE1; i <= MERGE_SIDE2; i++) {
+ strset_init_with_options(&renames->dirs_removed[i],
+ NULL, 0);
+ strmap_init_with_options(&renames->dir_rename_count[i],
+ NULL, 1);
+ strmap_init_with_options(&renames->dir_renames[i],
+ NULL, 0);
+ }
+
/*
* Although we initialize opt->priv->paths with strdup_strings=0,
* that's just to avoid making yet another copy of an allocated
--
2.29.1.106.g3ff750dc32.dirty
next prev parent reply other threads:[~2021-01-04 23:51 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-04 23:49 [PATCH 00/17] Add directory rename detection to merge-ort Elijah Newren
2021-01-04 23:49 ` [PATCH 01/17] merge-ort: add new data structures for directory rename detection Elijah Newren
2021-01-04 23:49 ` Elijah Newren [this message]
2021-01-04 23:49 ` [PATCH 03/17] merge-ort: collect which directories are removed in dirs_removed Elijah Newren
2021-01-04 23:49 ` [PATCH 04/17] merge-ort: add outline for computing directory renames Elijah Newren
2021-01-04 23:49 ` [PATCH 05/17] merge-ort: add outline of get_provisional_directory_renames() Elijah Newren
2021-01-04 23:49 ` [PATCH 06/17] merge-ort: copy get_renamed_dir_portion() from merge-recursive.c Elijah Newren
2021-01-04 23:49 ` [PATCH 07/17] merge-ort: implement compute_rename_counts() Elijah Newren
2021-01-04 23:49 ` [PATCH 08/17] merge-ort: implement handle_directory_level_conflicts() Elijah Newren
2021-01-04 23:49 ` [PATCH 09/17] merge-ort: modify collect_renames() for directory rename handling Elijah Newren
2021-01-04 23:49 ` [PATCH 10/17] merge-ort: implement compute_collisions() Elijah Newren
2021-01-04 23:50 ` [PATCH 11/17] merge-ort: implement apply_dir_rename() and check_dir_renamed() Elijah Newren
2021-01-04 23:50 ` [PATCH 12/17] merge-ort: implement check_for_directory_rename() Elijah Newren
2021-01-04 23:50 ` [PATCH 13/17] merge-ort: implement handle_path_level_conflicts() Elijah Newren
2021-01-04 23:50 ` [PATCH 14/17] merge-ort: add a new toplevel_dir field Elijah Newren
2021-01-04 23:50 ` [PATCH 15/17] merge-ort: implement apply_directory_rename_modifications() Elijah Newren
2021-01-04 23:50 ` [PATCH 16/17] merge-ort: process_renames() now needs more defensiveness Elijah Newren
2021-01-04 23:50 ` [PATCH 17/17] merge-ort: fix a directory rename detection bug Elijah Newren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210104235006.2867404-3-newren@gmail.com \
--to=newren@gmail$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=gitster@pobox$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox