From patchwork Mon Jan 4 23:49:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 11997783 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BEC2C433E0 for ; Mon, 4 Jan 2021 23:51:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3AD9D22519 for ; Mon, 4 Jan 2021 23:51:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727700AbhADXur (ORCPT ); Mon, 4 Jan 2021 18:50:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726168AbhADXur (ORCPT ); Mon, 4 Jan 2021 18:50:47 -0500 Received: from mail-ot1-x32a.google.com (mail-ot1-x32a.google.com [IPv6:2607:f8b0:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 567CFC061794 for ; Mon, 4 Jan 2021 15:50:32 -0800 (PST) Received: by mail-ot1-x32a.google.com with SMTP id a109so27741796otc.1 for ; Mon, 04 Jan 2021 15:50:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2D27MOZCWKJcR+qftRGZM+KbS3IqNa6FfwwOpSLCd/M=; b=s1Lr7IwrltqgOGAQZnLhc8FL0rfeQPg5zpC5lT6FF+SN2AOLiuURpWbuUBwL12a5cz NvQc6mTnACqoAAcSYAeDnKO2D7RS3aNCuixQlpJ4H339eUEeFMbu1VGgoAWim+0GIRCo 3m68QK9JaAZh3vrKheB2sOj6sg4K07bFEosWtIqpg/PLh12wHuamEc/T0lmPHP4ONwKd 40t52BpllbnP7IsHKSNP+5um7KInc03YKJAPygam3loCeLdE12PFV5B7aqJB6DLtm2Xm qsb2RN+iv/0biReQEY4Km27qR9Cx+CsUp/qU96Yn6QMUZCjKNMbhjvEVZWkbpR9TEWSU M9yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2D27MOZCWKJcR+qftRGZM+KbS3IqNa6FfwwOpSLCd/M=; b=tL6KjZZAwuz4fjbTlDFXBJevBxnsNwwuaS9wqBizd64LyWBQrHNvJcRsEADKs9ou8F ZvQewilQfEDK58bpWj+WkYuVuiQIaZL0iD1p4HRDNc15/QHabGcZsDTC1LBoXwHDLxB2 ef7U0KrAPT1D7UNi7/8YmGB/n1mkU5pfLDTI9sF08aYLcC6MRRL4cp2kJ3BWK+ak31PA u/lsDQAB1a4mHlgz1Q321GRxV1cxLD/TmJrX4oPT/2eurivISqsvm/IE9duTFVtUiCN8 LgwRRGlb5ApFn4gmr2udFlm4XjBfuxFSRnFmrIWXYfv2+sg9KNVdaHvIB6cU4K9rii/a BHdw== X-Gm-Message-State: AOAM530QpATQIm8GqRBMh1CvJ/4Mxjbqvw5R22f4ld8Ezh7gVQpUrX/c U9fPPe/Nh/vFJetWhxNn5Qcgg5hR8H4= X-Google-Smtp-Source: ABdhPJxD0dbNGe6ID799sxlNPPNSpMV71oxPYwvel2YwcFpTeSbEW5Aim/EqIqzDLtaPvjGTtYZKIw== X-Received: by 2002:a9d:a61:: with SMTP id 88mr52266393otg.18.1609804231536; Mon, 04 Jan 2021 15:50:31 -0800 (PST) Received: from tiger.attlocal.net ([2600:1700:bae0:2de0::26]) by smtp.gmail.com with ESMTPSA id o135sm13359600ooo.38.2021.01.04.15.50.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Jan 2021 15:50:31 -0800 (PST) From: Elijah Newren To: git@vger.kernel.org Cc: gitster@pobox.com, Elijah Newren Subject: [PATCH 02/17] merge-ort: initialize and free new directory rename data structures Date: Mon, 4 Jan 2021 15:49:51 -0800 Message-Id: <20210104235006.2867404-3-newren@gmail.com> X-Mailer: git-send-email 2.29.1.106.g3ff750dc32.dirty In-Reply-To: <20210104235006.2867404-1-newren@gmail.com> References: <20210104235006.2867404-1-newren@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Elijah Newren --- 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