From patchwork Mon Dec 14 16:21:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 11972469 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=-12.7 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 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 98349C4361B for ; Mon, 14 Dec 2020 16:23:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4B59B22795 for ; Mon, 14 Dec 2020 16:23:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440133AbgLNQWl (ORCPT ); Mon, 14 Dec 2020 11:22:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2440250AbgLNQWZ (ORCPT ); Mon, 14 Dec 2020 11:22:25 -0500 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6445C0613D6 for ; Mon, 14 Dec 2020 08:21:44 -0800 (PST) Received: by mail-wr1-x444.google.com with SMTP id a11so9273027wrr.13 for ; Mon, 14 Dec 2020 08:21:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=bjCZpoR7X/4iQp728JJIq89yo2vC+dnNlcpJ/DFfq80=; b=YKVvh/Yz958gnFaEz4FQVP7m1kRHO7iLyu5iMFICTrnppEpqsSipbVkj5mJfNGl2f2 wmOnckvSmUdNGXV0eQzDZ7mkpJMijVSLPnH4CrvRfNxhEJ9v9+dJnTsi+7mhZS5OgKXH vyWgpj9ad5u2f1g1C68o8ngRFDk8zynyIDndXfZa+bkzFPPR9QJwmxThjKD55A6KvsYV KCesenxecha0UCVA1e9gloYSkan51wsBtC/zE7KFM1UTGkV9DQtE9YYpE2beXpw18qE5 egrcsa0/d8SNkYBoDREP/N+AImU+tHgl84n6FhztGBMxwwCse8Ebs+lyID8a600J+7x5 pjOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=bjCZpoR7X/4iQp728JJIq89yo2vC+dnNlcpJ/DFfq80=; b=qPh5LGLvMwsM3KLsGtRbuhfWGNpLHYp9jUwGHFpxE5PJxYGpFIScK5++F9uok4HLY0 iI/I7E0SW6p7cSfj+lamFRcrHPdgwtxzi7gZGIVyL2qm1ZX7q12XiGKMVm04LYjbgb6k Prk1Typ7KF3H3YYzO6Ax0FjkdQFBiGO1IMKFhDyIUa34EgdEcR1wDpwsniZ+nrrJncAU m2wJWmXDE1ROo5HioZ/MI2MIHiDKtaPvPnsGdp1UvcdtzbFUxn9dEuHnWmVA5dioi0DT ztogl5DyWSXKO6CqWwYPO/YxwxigmiCSa21cGFj/q/uH6259D2xZeqzwtgCVQ5Xtukx6 GxXg== X-Gm-Message-State: AOAM530Gr+fvEj4h6IBLi5GnGnZoEsfK7f39CyuTBEQEldQtbhsyh6jI qO/wwheA06kvuBI9YBPp8pM7m+qv9Pk= X-Google-Smtp-Source: ABdhPJw6AwSUE5dcEowyErQQtopVqGKjPjSuc6OBXdjRwKjRreiGpP9FLupAk1CuiNm7WuE3RdQm5w== X-Received: by 2002:adf:9e4d:: with SMTP id v13mr29171114wre.135.1607962903302; Mon, 14 Dec 2020 08:21:43 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id s25sm15117662wrs.49.2020.12.14.08.21.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 08:21:42 -0800 (PST) Message-Id: <78621ca07887e39a41ad9cff7b8dd5dcc9b33fbc.1607962900.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 14 Dec 2020 16:21:30 +0000 Subject: [PATCH v2 01/11] merge-ort: add basic data structures for handling renames Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Elijah Newren , Johannes Schindelin , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren This will grow later, but we only need a few fields for basic rename handling. Signed-off-by: Elijah Newren --- merge-ort.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/merge-ort.c b/merge-ort.c index 414e7b7eeac..1c1a7fa4bf1 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -46,6 +46,25 @@ enum merge_side { MERGE_SIDE2 = 2 }; +struct rename_info { + /* + * pairs: pairing of filenames from diffcore_rename() + * + * Index 1 and 2 correspond to sides 1 & 2 as used in + * conflict_info.stages. Index 0 unused. + */ + struct diff_queue_struct pairs[3]; + + /* + * needed_limit: value needed for inexact rename detection to run + * + * If the current rename limit wasn't high enough for inexact + * rename detection to run, this records the limit needed. Otherwise, + * this value remains 0. + */ + int needed_limit; +}; + struct merge_options_internal { /* * paths: primary data structure in all of merge ort. @@ -113,6 +132,11 @@ struct merge_options_internal { */ struct strmap output; + /* + * renames: various data relating to rename detection + */ + struct rename_info renames; + /* * current_dir_name: temporary var used in collect_merge_info_callback() * From patchwork Mon Dec 14 16:21:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 11972475 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=-12.7 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 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 00800C4361B for ; Mon, 14 Dec 2020 16:23:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BB8C7225AC for ; Mon, 14 Dec 2020 16:23:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440187AbgLNQW7 (ORCPT ); Mon, 14 Dec 2020 11:22:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2440248AbgLNQW0 (ORCPT ); Mon, 14 Dec 2020 11:22:26 -0500 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B67E6C061793 for ; Mon, 14 Dec 2020 08:21:45 -0800 (PST) Received: by mail-wm1-x344.google.com with SMTP id a3so15796923wmb.5 for ; Mon, 14 Dec 2020 08:21:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=SI+l5g9wGTUq3i9Ft6Oc+PNP4QnKTKBpBnZ3lsTnHgU=; b=sbN8yoZJaZT+ZWdWqqKjojNQAmUMz/quicad2l9zKLzFGHu6QEzID+y4o7VpBr5OIJ 4gLhTUOhwnYWGzKvqrH8NYbWIqneQaau+d+Z0w3z3Dd3CwJRZh7FhUASKHhcBuUmNzkH My84IygZ1LkL5bDTxPEcac9pPKFbGnsCz6lZCfAPxQ5Y3x1RbrVzKBSKBxGOgqwPVtm3 cNzTtOFn+PymuNtjeAdelmyTRsU5pIOQE5PLJ+3XIEqtFMaDoevJrhlxSpBBzDVS++hZ 1BwhXAr+N4yPpCvdb41wPL/X3J2NssLGY9gqF2/zb/oHAzkx6405w+Eak7Oq0Ernuak8 qogw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=SI+l5g9wGTUq3i9Ft6Oc+PNP4QnKTKBpBnZ3lsTnHgU=; b=InZc0bNcdBuxnkstt9eZsANt0RLm0wv5Hx0Dbc7MMSeT7MLMxREfr655IqSjGObQcc puV7ZO6Kh1UO4h+cv/iBm+R1syph2gqF/dyMHnZickav5yRpCou8zcQKUSzTpVcyFnPm NJfmCHulfgwvxSlQjI9PfEfu0MQHqtzEpmITlxibSsAOIQ84E5/gIZ1mFP+1gDAjgMHP 1Byua/3JDS3e7naC7t2/Z5u899cUV+t4Mnvmvggrkl4EZL5xw3O3hLId3zDNDNOKrHN1 SB4S8j/I5TzJt3UN272LNmwDyb7r4ttSnmFi9i+T4fklUoO5uCHYd5xrjw6OisiqBYIs +zXQ== X-Gm-Message-State: AOAM532NZCtD9VHNj5RLVDyyEenAYJAcDCPUCisbB5jP18vrjWG5rp/s 3ViDHR7dat/rt+Q88TEL0S3XctE6tCk= X-Google-Smtp-Source: ABdhPJyZ+zIAkd4CrZpFOJLdoM4rgpIYBEJZkc5DNg5e+P2dUFfNCtJRRzU4ypxOMZ4KlSE9r3rgzg== X-Received: by 2002:a1c:3987:: with SMTP id g129mr28072044wma.86.1607962904290; Mon, 14 Dec 2020 08:21:44 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id w21sm14424181wmi.45.2020.12.14.08.21.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 08:21:43 -0800 (PST) Message-Id: In-Reply-To: References: Date: Mon, 14 Dec 2020 16:21:31 +0000 Subject: [PATCH v2 02/11] merge-ort: add initial outline for basic rename detection Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Elijah Newren , Johannes Schindelin , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren Signed-off-by: Elijah Newren --- merge-ort.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 60 insertions(+), 8 deletions(-) diff --git a/merge-ort.c b/merge-ort.c index 1c1a7fa4bf1..8552f5e2318 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -644,20 +644,72 @@ static int handle_content_merge(struct merge_options *opt, /*** Function Grouping: functions related to regular rename detection ***/ +static int process_renames(struct merge_options *opt, + struct diff_queue_struct *renames) +{ + die("Not yet implemented."); +} + +static int compare_pairs(const void *a_, const void *b_) +{ + die("Not yet implemented."); +} + +/* Call diffcore_rename() to compute which files have changed on given side */ +static void detect_regular_renames(struct merge_options *opt, + struct tree *merge_base, + struct tree *side, + unsigned side_index) +{ + die("Not yet implemented."); +} + +/* + * Get information of all renames which occurred in 'side_pairs', discarding + * non-renames. + */ +static int collect_renames(struct merge_options *opt, + struct diff_queue_struct *result, + unsigned side_index) +{ + die("Not yet implemented."); +} + static int detect_and_process_renames(struct merge_options *opt, struct tree *merge_base, struct tree *side1, struct tree *side2) { - int clean = 1; + struct diff_queue_struct combined; + struct rename_info *renames = &opt->priv->renames; + int s, clean = 1; + + memset(&combined, 0, sizeof(combined)); + + detect_regular_renames(opt, merge_base, side1, MERGE_SIDE1); + detect_regular_renames(opt, merge_base, side2, MERGE_SIDE2); + + ALLOC_GROW(combined.queue, + renames->pairs[1].nr + renames->pairs[2].nr, + combined.alloc); + clean &= collect_renames(opt, &combined, MERGE_SIDE1); + clean &= collect_renames(opt, &combined, MERGE_SIDE2); + QSORT(combined.queue, combined.nr, compare_pairs); + + clean &= process_renames(opt, &combined); + + /* Free memory for renames->pairs[] and combined */ + for (s = MERGE_SIDE1; s <= MERGE_SIDE2; s++) { + free(renames->pairs[s].queue); + DIFF_QUEUE_CLEAR(&renames->pairs[s]); + } + if (combined.nr) { + int i; + for (i = 0; i < combined.nr; i++) + diff_free_filepair(combined.queue[i]); + free(combined.queue); + } - /* - * Rename detection works by detecting file similarity. Here we use - * a really easy-to-implement scheme: files are similar IFF they have - * the same filename. Therefore, by this scheme, there are no renames. - * - * TODO: Actually implement a real rename detection scheme. - */ return clean; } From patchwork Mon Dec 14 16:21:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 11972471 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=-12.7 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,URIBL_BLOCKED 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 E4404C2BB9A for ; Mon, 14 Dec 2020 16:23:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9C756225AC for ; Mon, 14 Dec 2020 16:23:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440171AbgLNQWv (ORCPT ); Mon, 14 Dec 2020 11:22:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2440252AbgLNQW1 (ORCPT ); Mon, 14 Dec 2020 11:22:27 -0500 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84F22C061794 for ; Mon, 14 Dec 2020 08:21:46 -0800 (PST) Received: by mail-wr1-x442.google.com with SMTP id m5so17003687wrx.9 for ; Mon, 14 Dec 2020 08:21:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=2EJEhCVyrWEW/1Rsba7YQOxkLZkc7V5Ocg8faa9cQT0=; b=Ojr7hyV3zeAasjE3zivKH4+GF1QDyf8egGMX3QNY8WgNR8DW6dcFaWPHJNyhUfdAVL LSMevhwteQaxGP3cu5PhArOdtsf2wBEUOcSzofvkosZt1i0CJHa7qRBlKLPTuqLiLjPX 4k5NNYE2BAJALTDCMCqixQ5AmJqkkoNItRmUydY/8JfaOP95OQVsWfNBUBeLo22Vst1w gPMTklvKzlGzd3t32yvSw3s11olCEMzyGJ3jWDY6nkyYsBGIbcrXFdq3y2SkDNq3EmhY 1zVEFmjSaxzOpotZSqk2H/pQP5VwsvtoHFAKPDnmNJYgYDn6vWla14ZmojReIHuTjMfd bs9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=2EJEhCVyrWEW/1Rsba7YQOxkLZkc7V5Ocg8faa9cQT0=; b=fODV3bhRFxYTmjasidrSl0UHXx59MZ2vtCA3Yc1Hat/TwAJI6+gZPwUjTTKbSu6mz3 VdJGtzNM4xfbri19UOwfndBm1rqifV/44/lvAuoXqIJa/oHjXnyKqiYAPquAc4d0dD0F KkqgaqjToJ8ujDogoOi6KH2+7oLe9WdZnmeKfoapAQUmpTmoPI4ZAL+5WkfE9rKKP0hL 9v5rUjNSH64ic5dnFQyz4sFtTOQW1SkUdtCf3L08W7opm4dRbT9gAYzoZq7wboUEu4Vq 2bgs2bRBZHmwBs1vuTCVszGAQxdnnHJ3VnIdKRUEcEq1m5tEnd3oSz8OiOHnZRguKsNK dkZA== X-Gm-Message-State: AOAM530fvb3Zhw72T4w/l6GogJRKF6oP7Qnwp2tFZVE6HViFa07AjavL J9/89DBoVFSzgl3fSOxNuSAeUcujbyU= X-Google-Smtp-Source: ABdhPJzOkaVtGO/d95N8NUgIw10C/y9skAQ9ZFbNiIgy2muqTQAvmDtqcG+VRjqP1vF0Ut+sU4Pkgw== X-Received: by 2002:adf:8b5a:: with SMTP id v26mr21931122wra.138.1607962905155; Mon, 14 Dec 2020 08:21:45 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id l11sm21994724wrt.23.2020.12.14.08.21.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 08:21:44 -0800 (PST) Message-Id: <620fc64032d26e374b2fb52a044564725e023f0f.1607962900.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 14 Dec 2020 16:21:32 +0000 Subject: [PATCH v2 03/11] merge-ort: implement detect_regular_renames() Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Elijah Newren , Johannes Schindelin , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren Based heavily on merge-recursive's get_diffpairs() function, and also includes the necessary paired call to diff_warn_rename_limit() so that users will be warned if merge.renameLimit is not sufficiently large for rename detection to run. Signed-off-by: Elijah Newren --- merge-ort.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/merge-ort.c b/merge-ort.c index 8552f5e2318..66f84d39b43 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -661,7 +661,33 @@ static void detect_regular_renames(struct merge_options *opt, struct tree *side, unsigned side_index) { - die("Not yet implemented."); + struct diff_options diff_opts; + struct rename_info *renames = &opt->priv->renames; + + repo_diff_setup(opt->repo, &diff_opts); + diff_opts.flags.recursive = 1; + diff_opts.flags.rename_empty = 0; + diff_opts.detect_rename = DIFF_DETECT_RENAME; + diff_opts.rename_limit = opt->rename_limit; + if (opt->rename_limit <= 0) + diff_opts.rename_limit = 1000; + diff_opts.rename_score = opt->rename_score; + diff_opts.show_rename_progress = opt->show_rename_progress; + diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT; + diff_setup_done(&diff_opts); + diff_tree_oid(&merge_base->object.oid, &side->object.oid, "", + &diff_opts); + diffcore_std(&diff_opts); + + if (diff_opts.needed_rename_limit > renames->needed_limit) + renames->needed_limit = diff_opts.needed_rename_limit; + + renames->pairs[side_index] = diff_queued_diff; + + diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT; + diff_queued_diff.nr = 0; + diff_queued_diff.queue = NULL; + diff_flush(&diff_opts); } /* @@ -1406,6 +1432,10 @@ void merge_switch_to_result(struct merge_options *opt, printf("%s", sb->buf); } string_list_clear(&olist, 0); + + /* Also include needed rename limit adjustment now */ + diff_warn_rename_limit("merge.renamelimit", + opti->renames.needed_limit, 0); } merge_finalize(opt, result); From patchwork Mon Dec 14 16:21:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 11972477 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=-12.7 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 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 16368C4361B for ; Mon, 14 Dec 2020 16:23:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BA3EF227C3 for ; Mon, 14 Dec 2020 16:23:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440276AbgLNQX2 (ORCPT ); Mon, 14 Dec 2020 11:23:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729598AbgLNQXG (ORCPT ); Mon, 14 Dec 2020 11:23:06 -0500 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59B25C06179C for ; Mon, 14 Dec 2020 08:21:47 -0800 (PST) Received: by mail-wr1-x444.google.com with SMTP id y17so16995179wrr.10 for ; Mon, 14 Dec 2020 08:21:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=lTMgcVB6vgszaz4Tdvquin0z9C4VpWH2bLbPz0t6/YU=; b=pAHsLTsSKOWcgvyqt4rJWiBgrZQZ7Q3O7iQDJgSu17Qfqyy6cfhQLdZB7gzrZzy/wV 4q/PHsAro7X96oV3ktwN+zng/XT9YMprzPDgvHATNjS7FG2rNsAvfQ4rPZf71zlQi4m/ q/O+QoPNkHeIoCPAA1Q6gLJ2vRVlAdMjzjKd6Z1/Z5WJckjVn9kebPeyBSrEGngFxNWq kFYOHQfkU3OozYDaQGPCxRBVHzFk2g2yHfK+SA77R3XCLp6uJE+b6KKWOES6kpStxvul Anxr6tVrdajCgECXzVdarSgrQhaBQj7wxaW+UrsR57JyPYp4kWvLULoGCKjiufJ8br71 ho4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=lTMgcVB6vgszaz4Tdvquin0z9C4VpWH2bLbPz0t6/YU=; b=NR2JqbnliCL8MdZuvCUMzZx0ru6uf/BTuxKH+RE+yxDu4m/GAQtPdfuKfP7aiq0Zz+ Goe0f5k4ZNrfTnBV4OpHg1veujSh7wGUgcJ3e+Vrw/WqFoN7USnPdV6+jPNhXkKik7kW iE+93A8NArHlRCYsFtc/xUDjvobmi/SW4Xa0XCHXDMdawH5rZC2lzUmLvhHdGwPRNIwU VlB5vwR0A03f22TNgvlE73sMu9Fk28H7suNN6UXBBMFIKMpa4pluICS9blujgl5JqQq1 hUX8RDbroAL0l0GusCvzjB5eL8bc1dYkh4DK2lnXwMg2h5UODNT2MGhxCKCItFy4dcuK xQiw== X-Gm-Message-State: AOAM531dtJOKWnilnzVhlHxF8n+fLTL1XyrXXb99RuY+q20tZL6JjyR7 mY4iwoQ3RFYPBt7jEqsYNRqFXms3tmY= X-Google-Smtp-Source: ABdhPJyg128KYtjvs6hYFZH8AMvW1WNpMhm2ZU4CsI4YAmGa/xZBWhZavSxoLUJ/hqCLtfyETpZaow== X-Received: by 2002:a5d:674b:: with SMTP id l11mr11282121wrw.247.1607962905973; Mon, 14 Dec 2020 08:21:45 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id a144sm31704058wmd.47.2020.12.14.08.21.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 08:21:45 -0800 (PST) Message-Id: <9382dc4d50b3cf675d607cf5d39be08542d8147e.1607962900.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 14 Dec 2020 16:21:33 +0000 Subject: [PATCH v2 04/11] merge-ort: implement compare_pairs() and collect_renames() Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Elijah Newren , Johannes Schindelin , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren Signed-off-by: Elijah Newren --- merge-ort.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/merge-ort.c b/merge-ort.c index 66f84d39b43..10550c542b8 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -652,7 +652,10 @@ static int process_renames(struct merge_options *opt, static int compare_pairs(const void *a_, const void *b_) { - die("Not yet implemented."); + const struct diff_filepair *a = *((const struct diff_filepair **)a_); + const struct diff_filepair *b = *((const struct diff_filepair **)b_); + + return strcmp(a->one->path, b->one->path); } /* Call diffcore_rename() to compute which files have changed on given side */ @@ -698,7 +701,35 @@ static int collect_renames(struct merge_options *opt, struct diff_queue_struct *result, unsigned side_index) { - die("Not yet implemented."); + int i, clean = 1; + struct diff_queue_struct *side_pairs; + struct rename_info *renames = &opt->priv->renames; + + side_pairs = &renames->pairs[side_index]; + + for (i = 0; i < side_pairs->nr; ++i) { + struct diff_filepair *p = side_pairs->queue[i]; + + if (p->status != 'R') { + diff_free_filepair(p); + continue; + } + + /* + * p->score comes back from diffcore_rename_extended() with + * the similarity of the renamed file. The similarity is + * was used to determine that the two files were related + * and are a rename, which we have already used, but beyond + * that we have no use for the similarity. So p->score is + * now irrelevant. However, process_renames() will need to + * know which side of the merge this rename was associated + * with, so overwrite p->score with that value. + */ + p->score = side_index; + result->queue[result->nr++] = p; + } + + return clean; } static int detect_and_process_renames(struct merge_options *opt, From patchwork Mon Dec 14 16:21:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 11972485 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=-12.7 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 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 797EBC2BB40 for ; Mon, 14 Dec 2020 16:25:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 439CC225AB for ; Mon, 14 Dec 2020 16:25:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440272AbgLNQX1 (ORCPT ); Mon, 14 Dec 2020 11:23:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2440248AbgLNQXG (ORCPT ); Mon, 14 Dec 2020 11:23:06 -0500 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58CEEC0617B0 for ; Mon, 14 Dec 2020 08:21:48 -0800 (PST) Received: by mail-wm1-x32d.google.com with SMTP id a6so14283167wmc.2 for ; Mon, 14 Dec 2020 08:21:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=ZmaFFlhRcNBXHdv7esqe3Jf3vYqKLnuvVwTH5JzTLmk=; b=jGq9WWQ4ug+jTNzMdiy6rNmSS7QBfZwV+46Skhw0Ela9fpXnxD2tbLpSSPZP9iAd3w ZQR44zgkZivlw0ieB3e4pHwP0U3DWD4mYrsJVXW/tGBM6svSvapnzkSTF4RvNz92OTYo aPeegslEzaU5IFw8AexSP5nzz3hEsg+jIehvtm56L6+oa+AU+iTacYs6Zf5Pei2isbvx lKNm7I5ZV4kFopV/ebYxm0Y01Cf8ULLtKAsAU053sRUlc8uYC1ORE1JUx+HnAnZ8qH6Y admUbP5pVJw+4RJkLFrSNhYih7snaW79/sBEedyDqvp1wOZAVUiJvT79nzEG2k2S9KYf bO4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=ZmaFFlhRcNBXHdv7esqe3Jf3vYqKLnuvVwTH5JzTLmk=; b=aOOyncsoBYQjFwQT+xq4+E7Z8rW44x4YVaJqswBU3HTM4DZsj7iRgcjI9joi82S2XG g2q5YwjeehKeNJ2pKwXUfQ0nRfOxdlsWjv6vypGUn0g3MgUiINOatTjBMbTbu73k5GuZ inlES6bJWaRtrnYo1vEVZFruilQRGPlJ1L39bJlFKIcQXryghw6r3b0bHEeQrwFAiPmH bxncxuuMzRkBTBgD8it+gdnJ4FA0Xo/X4qAzkCEB3wxI70rG+PTd4YVmN5Q02B6sPWxx mAVOC55yD4/vB1diCjtQBP3GefuLYOxuvB1dXHFtIm7eLS1AqmWMumc9CX68QdaQPjb9 JqQg== X-Gm-Message-State: AOAM5322VDFuWCdckfWJb0BlWJyBcBTCSt7sSvVK7JLq8gkgg1ZfCTvd ze+dW2DqFvfNzfCcokfxv5Dzt9WkLhM= X-Google-Smtp-Source: ABdhPJz+jfM/rYAY9zXv3NSB9vYIF25V22oaquAo4H4Wx4wPyojyX/N6BOzgpgp2rlzz9JXj8BaiWg== X-Received: by 2002:a05:600c:2246:: with SMTP id a6mr28699292wmm.80.1607962906865; Mon, 14 Dec 2020 08:21:46 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id t1sm33856791wro.27.2020.12.14.08.21.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 08:21:46 -0800 (PST) Message-Id: In-Reply-To: References: Date: Mon, 14 Dec 2020 16:21:34 +0000 Subject: [PATCH v2 05/11] merge-ort: add basic outline for process_renames() Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Elijah Newren , Johannes Schindelin , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren Add code which determines which kind of special rename case each rename corresponds to, but leave the handling of each type unimplemented for now. Future commits will implement each one. There is some tenuous resemblance to merge-recursive's process_renames(), but comparing the two is very unlikely to yield any insights. merge-ort's process_renames() is a bit complex and I would prefer if I could simplify it more, but it is far easier to grok than merge-recursive's function of the same name in my opinion. Plus, merge-ort handles more rename conflict types than merge-recursive does. Signed-off-by: Elijah Newren --- merge-ort.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 97 insertions(+), 1 deletion(-) diff --git a/merge-ort.c b/merge-ort.c index 10550c542b8..ebe275ef73c 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -647,7 +647,103 @@ static int handle_content_merge(struct merge_options *opt, static int process_renames(struct merge_options *opt, struct diff_queue_struct *renames) { - die("Not yet implemented."); + int clean_merge = 1, i; + + for (i = 0; i < renames->nr; ++i) { + const char *oldpath = NULL, *newpath; + struct diff_filepair *pair = renames->queue[i]; + struct conflict_info *oldinfo = NULL, *newinfo = NULL; + struct strmap_entry *old_ent, *new_ent; + unsigned int old_sidemask; + int target_index, other_source_index; + int source_deleted, collision, type_changed; + + old_ent = strmap_get_entry(&opt->priv->paths, pair->one->path); + oldpath = old_ent->key; + oldinfo = old_ent->value; + + new_ent = strmap_get_entry(&opt->priv->paths, pair->two->path); + newpath = new_ent->key; + newinfo = new_ent->value; + + /* + * diff_filepairs have copies of pathnames, thus we have to + * use standard 'strcmp()' (negated) instead of '=='. + */ + if (i + 1 < renames->nr && + !strcmp(oldpath, renames->queue[i+1]->one->path)) { + /* Handle rename/rename(1to2) or rename/rename(1to1) */ + const char *pathnames[3]; + + pathnames[0] = oldpath; + pathnames[1] = newpath; + pathnames[2] = renames->queue[i+1]->two->path; + + if (!strcmp(pathnames[1], pathnames[2])) { + /* Both sides renamed the same way. */ + die("Not yet implemented"); + + /* We handled both renames, i.e. i+1 handled */ + i++; + /* Move to next rename */ + continue; + } + + /* This is a rename/rename(1to2) */ + die("Not yet implemented"); + + i++; /* We handled both renames, i.e. i+1 handled */ + continue; + } + + VERIFY_CI(oldinfo); + VERIFY_CI(newinfo); + target_index = pair->score; /* from collect_renames() */ + assert(target_index == 1 || target_index == 2); + other_source_index = 3 - target_index; + old_sidemask = (1 << other_source_index); /* 2 or 4 */ + source_deleted = (oldinfo->filemask == 1); + collision = ((newinfo->filemask & old_sidemask) != 0); + type_changed = !source_deleted && + (S_ISREG(oldinfo->stages[other_source_index].mode) != + S_ISREG(newinfo->stages[target_index].mode)); + if (type_changed && collision) { + /* special handling so later blocks can handle this */ + die("Not yet implemented"); + } + + assert(source_deleted || oldinfo->filemask & old_sidemask); + + /* Need to check for special types of rename conflicts... */ + if (collision && !source_deleted) { + /* collision: rename/add or rename/rename(2to1) */ + die("Not yet implemented"); + } else if (collision && source_deleted) { + /* rename/add/delete or rename/rename(2to1)/delete */ + die("Not yet implemented"); + } else { + /* a few different cases... */ + if (type_changed) { + /* rename vs. typechange */ + die("Not yet implemented"); + } else if (source_deleted) { + /* rename/delete */ + die("Not yet implemented"); + } else { + /* normal rename */ + die("Not yet implemented"); + } + } + + if (!type_changed) { + /* Mark the original as resolved by removal */ + oldinfo->merged.is_null = 1; + oldinfo->merged.clean = 1; + } + + } + + return clean_merge; } static int compare_pairs(const void *a_, const void *b_) From patchwork Mon Dec 14 16:21:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 11972483 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=-12.7 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 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 962C8C2BB9A for ; Mon, 14 Dec 2020 16:25:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6448122795 for ; Mon, 14 Dec 2020 16:25:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439900AbgLNQXV (ORCPT ); Mon, 14 Dec 2020 11:23:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2440195AbgLNQXG (ORCPT ); Mon, 14 Dec 2020 11:23:06 -0500 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35775C06138C for ; Mon, 14 Dec 2020 08:21:49 -0800 (PST) Received: by mail-wm1-x341.google.com with SMTP id v14so14284193wml.1 for ; Mon, 14 Dec 2020 08:21:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=7v3XyS7wFDYvaHnBwPBHVVEgN/vtjPftIMXATY8yNR8=; b=k/hGyWAhFZ4IKshh43z4wTLqkLgS+EykMm9Cv9UurfaQ3U/rRWvgznNjASjDB6BpfZ gm5Ft959hTnKRjNV9CvGffEW5jJaZwgKg0dmuU5rLTHlAjaZ9W0j97vLtOihaNGF3haI BkBMZqrs3vtyxNCHda9DrNxE3MdqSQYgUJIYMdhJ4erht7I6q25NjJlaIHRXeJ7rWfQ6 EULCLFZp6+E66OHLSY0gYgEJQiXZgIEI+AhghyNQWrqfjSRCf0CoKutNuV6GoeH2mMQH ymKmoczGOpxvFzvFxzrRT8rTC2S6S26PF+2voxzFzchj4M2jehS8TT7SzfrrDH/cM0Zi Eaxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=7v3XyS7wFDYvaHnBwPBHVVEgN/vtjPftIMXATY8yNR8=; b=shkx66Ur1oZzjpWu+lPyDHewKhJqtO95G3ViezPdwEDjnN2tg0oDQzyFYL7jTXVG3Q RMtzJj8PlrwvSCnn/OqXMqhGx6BcxzDRs5OT1Lc9NYpCYI6NuIytU4Qr4O365RZyHRtJ OdX3gtp9wqFonMlIfpU0CjjZZF7XorAseu/hpBNSMbbprKAe50CvrcND4K9FUntOEcvE yFaqJwZHYu8Rq2Q7VsOPJVDQ8G9ePSVmLhDaR7Oe//8DmTyYpTHL9ZpABxto8R327Fwz GmGwzKJvGTct72fK1UpYCOLjlEv1YHXiN/MkJAaETr1a4kSFe8iWJckPPCZDIQ2vdgxA 4w6w== X-Gm-Message-State: AOAM532e7DMdoZps+RLuxtHLs7N1lBLkYhwiWgH8EtRw+Dx2faxj2vD9 aCpY4U8UmixL5S4+SEJNGum6gsbCOb4= X-Google-Smtp-Source: ABdhPJyWMakOkCPgDdHyyiWNJctZi2ZIlMaOwmirsVQeJKtoNbYgQthINF9sT2RGvU4RY6kEYk+QZg== X-Received: by 2002:a1c:4c0a:: with SMTP id z10mr133730wmf.95.1607962907750; Mon, 14 Dec 2020 08:21:47 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id w189sm20214115wmg.31.2020.12.14.08.21.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 08:21:47 -0800 (PST) Message-Id: <15fff3dd0c48c301bfcb7fe335fa02fad1c686ab.1607962900.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 14 Dec 2020 16:21:35 +0000 Subject: [PATCH v2 06/11] merge-ort: add implementation of both sides renaming identically Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Elijah Newren , Johannes Schindelin , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren Implement rename/rename(1to1) handling, i.e. both sides of history renaming a file but renaming the same way. This code replaces the following from merge-recurisve.c: * all the 1to1 code in process_renames() * the RENAME_ONE_FILE_TO_ONE case of process_entry() Also, there is some shared code from merge-recursive.c for multiple different rename cases which we will no longer need for this case (or other rename cases): * handle_rename_normal() * setup_rename_conflict_info() The consolidation of four separate codepaths into one is made possible by a change in design: process_renames() tweaks the conflict_info entries within opt->priv->paths such that process_entry() can then handle all the non-rename conflict types (directory/file, modify/delete, etc.) orthogonally. This means we're much less likely to miss special implementation of some kind of combination of conflict types (see commits brought in by 66c62eaec6 ("Merge branch 'en/merge-tests'", 2020-11-18), especially commit ef52778708 ("merge tests: expect improved directory/file conflict handling in ort", 2020-10-26) for more details). That, together with letting worktree/index updating be handled orthogonally in the merge_switch_to_result() function, dramatically simplifies the code for various special rename cases. Signed-off-by: Elijah Newren --- merge-ort.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/merge-ort.c b/merge-ort.c index ebe275ef73c..4034ffcf501 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -674,14 +674,31 @@ static int process_renames(struct merge_options *opt, !strcmp(oldpath, renames->queue[i+1]->one->path)) { /* Handle rename/rename(1to2) or rename/rename(1to1) */ const char *pathnames[3]; + struct version_info merged; + struct conflict_info *base, *side1, *side2; + unsigned was_binary_blob = 0; pathnames[0] = oldpath; pathnames[1] = newpath; pathnames[2] = renames->queue[i+1]->two->path; + base = strmap_get(&opt->priv->paths, pathnames[0]); + side1 = strmap_get(&opt->priv->paths, pathnames[1]); + side2 = strmap_get(&opt->priv->paths, pathnames[2]); + + VERIFY_CI(base); + VERIFY_CI(side1); + VERIFY_CI(side2); + if (!strcmp(pathnames[1], pathnames[2])) { - /* Both sides renamed the same way. */ - die("Not yet implemented"); + /* Both sides renamed the same way */ + assert(side1 == side2); + memcpy(&side1->stages[0], &base->stages[0], + sizeof(merged)); + side1->filemask |= (1 << MERGE_BASE); + /* Mark base as resolved by removal */ + base->merged.is_null = 1; + base->merged.clean = 1; /* We handled both renames, i.e. i+1 handled */ i++; From patchwork Mon Dec 14 16:21:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 11972491 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=-12.7 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 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 5CBB8C2BB48 for ; Mon, 14 Dec 2020 16:26:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1F6E422A99 for ; Mon, 14 Dec 2020 16:26:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440093AbgLNQZv (ORCPT ); Mon, 14 Dec 2020 11:25:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727624AbgLNQXL (ORCPT ); Mon, 14 Dec 2020 11:23:11 -0500 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 722B2C061282 for ; Mon, 14 Dec 2020 08:21:50 -0800 (PST) Received: by mail-wm1-x342.google.com with SMTP id a3so15797238wmb.5 for ; Mon, 14 Dec 2020 08:21:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=3wvkdW5XE1G4uCvT4fhJgWOMCaldDUb3UyHgtne7vvg=; b=UXFeTWcPBK8C//Y5CBimTV79+qphhQY4S26vDvH10pOI9S/RVenz3/IyfQcBM3bfhO Mu/IYLjrwR11qgHLmD1gfXjfMyyIMKTZJrUwZrR67P9DBPD1kSfBt3NAI9dj6fJwxG5F +pjPMb0Fw1P+13agtesc69X++Si9fJtEvnli74UhWTewrU6s9Bl5jJPlPbRnLuAINCHK 8sxVBAXMEpDJpPONgLSRUKm5DkEBt3+1a9qzznmouD+hfWXKGaC6mOzcAFaao2HzcOPy 5Ji+lLFEny5qEhtCwSOcIEkmVnBH90Yg7aBSlWpeWUQSBGUH3mfLnZZGwRIg5KcLf+o4 fa+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=3wvkdW5XE1G4uCvT4fhJgWOMCaldDUb3UyHgtne7vvg=; b=BNQMXjPYwRyW5x6pvVxzwcYZJSw74od8MbZmzkVTyVUy8XFaxOlEJ2nmyQJZiTVpcp pQXWTzxiEHFTCcAsQ3X2GldXKbkBZxDcpN71dvczgrsiO0UwBWJ4IPRQRusAnM8AmcB1 IlAadrAbhjcq9Lt4Xy+dk3/v0nyj903a/3OQwFSTV0HiqULqnde4gmcf5ADmafKu3Y6s uA73ZxacNRHlhEFUqZNinuaV3E2HB3AlUoVtgc6sAx32Uw7CVYp4W8bXyoOJ94xSM0Je IvZoUdiYVqvWW7VVXm6rxw5O493klzg88PGmEQorp+zO7X4AawcZ5OwjpuX6xsJCY12Y NbxA== X-Gm-Message-State: AOAM531OK7z9JRY6VfBBixgiZrJmIj6ouPVvrBJAIgD14DOcEMqvptUS IKvLXbmTxlqRwww+gdASLFOy7eYh0jE= X-Google-Smtp-Source: ABdhPJyZ38AlbB42SG2+/WUdK0ZsfVsX114z9Vj2D4QOtgmjjmlKBjVmPkMAOBxqaZwsPfjj52KpcA== X-Received: by 2002:a1c:7ec9:: with SMTP id z192mr28159109wmc.126.1607962908896; Mon, 14 Dec 2020 08:21:48 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id z6sm9402438wmi.15.2020.12.14.08.21.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 08:21:48 -0800 (PST) Message-Id: In-Reply-To: References: Date: Mon, 14 Dec 2020 16:21:36 +0000 Subject: [PATCH v2 07/11] merge-ort: add implementation of both sides renaming differently Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Elijah Newren , Johannes Schindelin , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren Implement rename/rename(1to2) handling, i.e. both sides of history renaming a file and rename it differently. This code replaces the following from merge-recurisve.c: * all the 1to2 code in process_renames() * the RENAME_ONE_FILE_TO_TWO case of process_entry() * handle_rename_rename_1to2() Also, there is some shared code from merge-recursive.c for multiple different rename cases which we will no longer need for this case (or other rename cases): * handle_file_collision() * setup_rename_conflict_info() The consolidation of five separate codepaths into one is made possible by a change in design: process_renames() tweaks the conflict_info entries within opt->priv->paths such that process_entry() can then handle all the non-rename conflict types (directory/file, modify/delete, etc.) orthogonally. This means we're much less likely to miss special implementation of some kind of combination of conflict types (see commits brought in by 66c62eaec6 ("Merge branch 'en/merge-tests'", 2020-11-18), especially commit ef52778708 ("merge tests: expect improved directory/file conflict handling in ort", 2020-10-26) for more details). That, together with letting worktree/index updating be handled orthogonally in the merge_switch_to_result() function, dramatically simplifies the code for various special rename cases. To be fair, there is a _slight_ tweak to process_entry() here to make sure that the two different paths aren't marked as clean but are left in a conflicted state. So process_renames() and process_entry() aren't quite entirely orthogonal, but they are pretty close. Signed-off-by: Elijah Newren --- merge-ort.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 3 deletions(-) diff --git a/merge-ort.c b/merge-ort.c index 4034ffcf501..19477cfae60 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -707,7 +707,58 @@ static int process_renames(struct merge_options *opt, } /* This is a rename/rename(1to2) */ - die("Not yet implemented"); + clean_merge = handle_content_merge(opt, + pair->one->path, + &base->stages[0], + &side1->stages[1], + &side2->stages[2], + pathnames, + 1 + 2 * opt->priv->call_depth, + &merged); + if (!clean_merge && + merged.mode == side1->stages[1].mode && + oideq(&merged.oid, &side1->stages[1].oid)) + was_binary_blob = 1; + memcpy(&side1->stages[1], &merged, sizeof(merged)); + if (was_binary_blob) { + /* + * Getting here means we were attempting to + * merge a binary blob. + * + * Since we can't merge binaries, + * handle_content_merge() just takes one + * side. But we don't want to copy the + * contents of one side to both paths. We + * used the contents of side1 above for + * side1->stages, let's use the contents of + * side2 for side2->stages below. + */ + oidcpy(&merged.oid, &side2->stages[2].oid); + merged.mode = side2->stages[2].mode; + } + memcpy(&side2->stages[2], &merged, sizeof(merged)); + + side1->path_conflict = 1; + side2->path_conflict = 1; + /* + * TODO: For renames we normally remove the path at the + * old name. It would thus seem consistent to do the + * same for rename/rename(1to2) cases, but we haven't + * done so traditionally and a number of the regression + * tests now encode an expectation that the file is + * left there at stage 1. If we ever decide to change + * this, add the following two lines here: + * base->merged.is_null = 1; + * base->merged.clean = 1; + * and remove the setting of base->path_conflict to 1. + */ + base->path_conflict = 1; + path_msg(opt, oldpath, 0, + _("CONFLICT (rename/rename): %s renamed to " + "%s in %s and to %s in %s."), + pathnames[0], + pathnames[1], opt->branch1, + pathnames[2], opt->branch2); i++; /* We handled both renames, i.e. i+1 handled */ continue; @@ -1292,13 +1343,13 @@ static void process_entry(struct merge_options *opt, int side = (ci->filemask == 4) ? 2 : 1; ci->merged.result.mode = ci->stages[side].mode; oidcpy(&ci->merged.result.oid, &ci->stages[side].oid); - ci->merged.clean = !ci->df_conflict; + ci->merged.clean = !ci->df_conflict && !ci->path_conflict; } else if (ci->filemask == 1) { /* Deleted on both sides */ ci->merged.is_null = 1; ci->merged.result.mode = 0; oidcpy(&ci->merged.result.oid, &null_oid); - ci->merged.clean = 1; + ci->merged.clean = !ci->path_conflict; } /* From patchwork Mon Dec 14 16:21:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 11972479 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=-12.7 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 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 6F9E4C4361B for ; Mon, 14 Dec 2020 16:23:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3C09D227C3 for ; Mon, 14 Dec 2020 16:23:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440278AbgLNQX2 (ORCPT ); Mon, 14 Dec 2020 11:23:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2440259AbgLNQXL (ORCPT ); Mon, 14 Dec 2020 11:23:11 -0500 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CD4EC061285 for ; Mon, 14 Dec 2020 08:21:51 -0800 (PST) Received: by mail-wm1-x32e.google.com with SMTP id v14so14284296wml.1 for ; Mon, 14 Dec 2020 08:21:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=AnzqRRRy1g2L+onWadSEE6xu1o46r+kbeVuvHKawzo4=; b=p6Q6Y3QUUcp5sAdkT56lhNAkQypkpze0BZnFl/fQHYgV0WIPBeTVsM+wvadOr4amO/ HRprUyUqzpvwq3u9qvgSxOx4kxKj4DX1yLpehBSpX7vDWpkt16CuoDVmQX5YBDpcSdFe JIaMVSM6wmgogTqFZLUvjRwyJkX4rFhhA2w9o/ybmomxFf1sElWeUQmOVF1KlsLgGJM2 cJGm5MfEEWjwdlEg6R3JYnuLaNgim41PbrmorMWMrvbodTNqDWYr34XjgWuMdEkPVWop v6499Y6h6hataRPYZ6huhdxs2AcXoEM85zmMLtWZq5IlFH+qLovOWMM/j44uqDZFq8dy B8qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=AnzqRRRy1g2L+onWadSEE6xu1o46r+kbeVuvHKawzo4=; b=JYmVw4IuGx9fD7P1Z5vNLeawoSHrzDbLDPXgRsT1c3BNilG8tnuYtcTd4o1nFQKrsm k+z28nL2adMqju1MJ2qUWuy+0V3Qb2XFFcikd7Zz4qNjjFd4n3hVl+acP96JHxOf89T1 /TJMqc7rrnWDnD2dOQwz5Q1G8kVhquPLj01tafy0LnqiEZ87rmcH+XildcL+d2QUhg/W 9v2aEmQUnv13eI0k05CMT4BMjhJXvWovAzg8F1PRYvRmqYRqUsPip0SDKK1Clmcdb0YL 7YvbcmeUbYsWFkp424YGvsUG3xqr/ZBAmzhPiVXUu0xRdPYU74mp7OksPfoQyWkg48Bb 9eBA== X-Gm-Message-State: AOAM533bETA3oBKDm+z7/ZLzkX/k0/htVM2zFueBC98Ya3N/eiLakPM8 5GbFJLLwOlJ4p9+GPFjIX9UmcNSEgoo= X-Google-Smtp-Source: ABdhPJw8/j9TlwrbcSkCgJ9sWIvNYD5HcC71viPtviWx8nVu/Q9MXZ7fuOPMlieAqRuYROvjHxK/jQ== X-Received: by 2002:a1c:2783:: with SMTP id n125mr24518213wmn.74.1607962909900; Mon, 14 Dec 2020 08:21:49 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id q143sm32579274wme.28.2020.12.14.08.21.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 08:21:49 -0800 (PST) Message-Id: In-Reply-To: References: Date: Mon, 14 Dec 2020 16:21:37 +0000 Subject: [PATCH v2 08/11] merge-ort: add implementation of rename collisions Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Elijah Newren , Johannes Schindelin , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren Implement rename/rename(2to1) and rename/add handling, i.e. a file is renamed into a location where another file is added (with that other file either being a plain add or itself coming from a rename). Note that rename collisions can also have a special case stacked on top: the file being renamed on one side of history is deleted on the other (yielding either a rename/add/delete conflict or perhaps a rename/rename(2to1)/delete[/delete]) conflict. One thing to note here is that when there is a double rename, the code in question only handles one of them at a time; a later iteration through the loop will handle the other. After they've both been handled, process_entry()'s normal add/add code can handle the collision. This code replaces the following from merge-recurisve.c: * all the 2to1 code in process_renames() * the RENAME_TWO_FILES_TO_ONE case of process_entry() * handle_rename_rename_2to1() * handle_rename_add() Also, there is some shared code from merge-recursive.c for multiple different rename cases which we will no longer need for this case (or other rename cases): * handle_file_collision() * setup_rename_conflict_info() The consolidation of six separate codepaths into one is made possible by a change in design: process_renames() tweaks the conflict_info entries within opt->priv->paths such that process_entry() can then handle all the non-rename conflict types (directory/file, modify/delete, etc.) orthogonally. This means we're much less likely to miss special implementation of some kind of combination of conflict types (see commits brought in by 66c62eaec6 ("Merge branch 'en/merge-tests'", 2020-11-18), especially commit ef52778708 ("merge tests: expect improved directory/file conflict handling in ort", 2020-10-26) for more details). That, together with letting worktree/index updating be handled orthogonally in the merge_switch_to_result() function, dramatically simplifies the code for various special rename cases. Signed-off-by: Elijah Newren --- merge-ort.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/merge-ort.c b/merge-ort.c index 19477cfae60..04a16837849 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -785,10 +785,58 @@ static int process_renames(struct merge_options *opt, /* Need to check for special types of rename conflicts... */ if (collision && !source_deleted) { /* collision: rename/add or rename/rename(2to1) */ - die("Not yet implemented"); + const char *pathnames[3]; + struct version_info merged; + + struct conflict_info *base, *side1, *side2; + unsigned clean; + + pathnames[0] = oldpath; + pathnames[other_source_index] = oldpath; + pathnames[target_index] = newpath; + + base = strmap_get(&opt->priv->paths, pathnames[0]); + side1 = strmap_get(&opt->priv->paths, pathnames[1]); + side2 = strmap_get(&opt->priv->paths, pathnames[2]); + + VERIFY_CI(base); + VERIFY_CI(side1); + VERIFY_CI(side2); + + clean = handle_content_merge(opt, pair->one->path, + &base->stages[0], + &side1->stages[1], + &side2->stages[2], + pathnames, + 1 + 2*opt->priv->call_depth, + &merged); + + memcpy(&newinfo->stages[target_index], &merged, + sizeof(merged)); + if (!clean) { + path_msg(opt, newpath, 0, + _("CONFLICT (rename involved in " + "collision): rename of %s -> %s has " + "content conflicts AND collides " + "with another path; this may result " + "in nested conflict markers."), + oldpath, newpath); + } } else if (collision && source_deleted) { - /* rename/add/delete or rename/rename(2to1)/delete */ - die("Not yet implemented"); + /* + * rename/add/delete or rename/rename(2to1)/delete: + * since oldpath was deleted on the side that didn't + * do the rename, there's not much of a content merge + * we can do for the rename. oldinfo->merged.is_null + * was already set, so we just leave things as-is so + * they look like an add/add conflict. + */ + + newinfo->path_conflict = 1; + path_msg(opt, newpath, 0, + _("CONFLICT (rename/delete): %s renamed " + "to %s in %s, but deleted in %s."), + oldpath, newpath, rename_branch, delete_branch); } else { /* a few different cases... */ if (type_changed) { From patchwork Mon Dec 14 16:21:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 11972487 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=-12.7 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 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 036F3C4361B for ; Mon, 14 Dec 2020 16:25:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 989A7225AC for ; Mon, 14 Dec 2020 16:25:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440030AbgLNQZe (ORCPT ); Mon, 14 Dec 2020 11:25:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2440258AbgLNQXL (ORCPT ); Mon, 14 Dec 2020 11:23:11 -0500 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F7DCC061248 for ; Mon, 14 Dec 2020 08:21:52 -0800 (PST) Received: by mail-wm1-x32d.google.com with SMTP id 190so4048163wmz.0 for ; Mon, 14 Dec 2020 08:21:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=grralITenGTZVsTOMW4aRwob8S5Jq4wbK6k0GPuEJpc=; b=QR+P9/AGj+VWg9iMs0xC4gMAU9RGa+gorb2XHxhwzVyLII9RemVfhig3ui9txNe34s Kek7Jw4GS8PlRtXLoslflNARKiTPFu/YQrWuMRSl0LI+N0u6VftMuXDA++tSGIdlUTzt HAhnsUOPalJEqYC64t8jSiWv4u7XpE4DyuKh1erphqWJNkSt1/YsaQZUt/glXpanlRul ElPD1GpV6VfSifPmhMOQmYdVK8vf1o11n3IQ6CrrbjskNnjUhkvHvQncNIXBxgjufmMe 0K7kLj4Y30nTfG94wW+Z5jJdkHVU1D9ANR5Hlh+oJVWNm4qkeBxztkKD/ZrwnWzejVwK PFRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=grralITenGTZVsTOMW4aRwob8S5Jq4wbK6k0GPuEJpc=; b=kaoaujvxxJy4NB803piuHH8yIODQ9f+KL4GFWv3ocVOoyDaOisz/7xd1lgsusdP8V5 bRxhWCEe0feXYEPQXx0WZ6olmwTp6I5hKa/KqRYnfBFaV1Ds2PQc3aHdxrxKH76qINs3 OrTzmIivZ59mnoUgEd+T0XMSve15djsPOdw9VNiqsjDn+9tHUx6Ih8A6s9Wi1L9QoceH S8t00gvDiRhQpOwBvPVkbsiF5rnQQcOx+C+lc28G9SYTpI1qsa6e2Q7BCIz+Xict4LO5 YagTCF71nbH+h2s5hSMUGnSTIdHL49eqKqodoZXTwu74pgxoDJFj8X1svH4IqFEI8Iuh ZIdw== X-Gm-Message-State: AOAM532vJrn2D9RxvEXZOnG7MKPm3K3TfbeAzTFvLR0mzbjqJv9L5C76 Jl5N0B+TJ+g+zZ5/QGZC7/kgju1zT4E= X-Google-Smtp-Source: ABdhPJw402uArOhk+2e0cHwtOIRPrJXkiVietwiMJlKIVUGkXswxLMUFMZ/9JjCmVClBXhAevrJYoA== X-Received: by 2002:a7b:c406:: with SMTP id k6mr28628303wmi.90.1607962910905; Mon, 14 Dec 2020 08:21:50 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id j7sm31368897wmb.40.2020.12.14.08.21.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 08:21:50 -0800 (PST) Message-Id: In-Reply-To: References: Date: Mon, 14 Dec 2020 16:21:38 +0000 Subject: [PATCH v2 09/11] merge-ort: add implementation of rename/delete conflicts Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Elijah Newren , Johannes Schindelin , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren Implement rename/delete conflicts, i.e. one side renames a file and the other deletes the file. This code replaces the following from merge-recurisve.c: * the code relevant to RENAME_DELETE in process_renames() * the RENAME_DELETE case of process_entry() * handle_rename_delete() Also, there is some shared code from merge-recursive.c for multiple different rename cases which we will no longer need for this case (or other rename cases): * handle_change_delete() * setup_rename_conflict_info() The consolidation of five separate codepaths into one is made possible by a change in design: process_renames() tweaks the conflict_info entries within opt->priv->paths such that process_entry() can then handle all the non-rename conflict types (directory/file, modify/delete, etc.) orthogonally. This means we're much less likely to miss special implementation of some kind of combination of conflict types (see commits brought in by 66c62eaec6 ("Merge branch 'en/merge-tests'", 2020-11-18), especially commit ef52778708 ("merge tests: expect improved directory/file conflict handling in ort", 2020-10-26) for more details). That, together with letting worktree/index updating be handled orthogonally in the merge_switch_to_result() function, dramatically simplifies the code for various special rename cases. To be fair, there is a _slight_ tweak to process_entry() here, because rename/delete cases will also trigger the modify/delete codepath. However, we only want a modify/delete message to be printed for a rename/delete conflict if there is a content change in the renamed file in addition to the rename. So process_renames() and process_entry() aren't quite fully orthogonal, but they are pretty close. Signed-off-by: Elijah Newren --- merge-ort.c | 47 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/merge-ort.c b/merge-ort.c index 04a16837849..4150ccc35e1 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -657,6 +657,7 @@ static int process_renames(struct merge_options *opt, unsigned int old_sidemask; int target_index, other_source_index; int source_deleted, collision, type_changed; + const char *rename_branch = NULL, *delete_branch = NULL; old_ent = strmap_get_entry(&opt->priv->paths, pair->one->path); oldpath = old_ent->key; @@ -778,6 +779,14 @@ static int process_renames(struct merge_options *opt, if (type_changed && collision) { /* special handling so later blocks can handle this */ die("Not yet implemented"); + if (source_deleted) { + if (target_index == 1) { + rename_branch = opt->branch1; + delete_branch = opt->branch2; + } else { + rename_branch = opt->branch2; + delete_branch = opt->branch1; + } } assert(source_deleted || oldinfo->filemask & old_sidemask); @@ -838,13 +847,26 @@ static int process_renames(struct merge_options *opt, "to %s in %s, but deleted in %s."), oldpath, newpath, rename_branch, delete_branch); } else { - /* a few different cases... */ + /* + * a few different cases...start by copying the + * existing stage(s) from oldinfo over the newinfo + * and update the pathname(s). + */ + memcpy(&newinfo->stages[0], &oldinfo->stages[0], + sizeof(newinfo->stages[0])); + newinfo->filemask |= (1 << MERGE_BASE); + newinfo->pathnames[0] = oldpath; if (type_changed) { /* rename vs. typechange */ die("Not yet implemented"); } else if (source_deleted) { /* rename/delete */ - die("Not yet implemented"); + newinfo->path_conflict = 1; + path_msg(opt, newpath, 0, + _("CONFLICT (rename/delete): %s renamed" + " to %s in %s, but deleted in %s."), + oldpath, newpath, + rename_branch, delete_branch); } else { /* normal rename */ die("Not yet implemented"); @@ -1380,12 +1402,21 @@ static void process_entry(struct merge_options *opt, modify_branch = (side == 1) ? opt->branch1 : opt->branch2; delete_branch = (side == 1) ? opt->branch2 : opt->branch1; - path_msg(opt, path, 0, - _("CONFLICT (modify/delete): %s deleted in %s " - "and modified in %s. Version %s of %s left " - "in tree."), - path, delete_branch, modify_branch, - modify_branch, path); + if (ci->path_conflict && + oideq(&ci->stages[0].oid, &ci->stages[side].oid)) { + /* + * This came from a rename/delete; no action to take, + * but avoid printing "modify/delete" conflict notice + * since the contents were not modified. + */ + } else { + path_msg(opt, path, 0, + _("CONFLICT (modify/delete): %s deleted in %s " + "and modified in %s. Version %s of %s left " + "in tree."), + path, delete_branch, modify_branch, + modify_branch, path); + } } else if (ci->filemask == 2 || ci->filemask == 4) { /* Added on one side */ int side = (ci->filemask == 4) ? 2 : 1; From patchwork Mon Dec 14 16:21:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 11972481 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=-12.7 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 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 8BB9FC4361B for ; Mon, 14 Dec 2020 16:23:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4C260227C3 for ; Mon, 14 Dec 2020 16:23:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2501907AbgLNQXb (ORCPT ); Mon, 14 Dec 2020 11:23:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2440260AbgLNQXL (ORCPT ); Mon, 14 Dec 2020 11:23:11 -0500 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 980C3C061257 for ; Mon, 14 Dec 2020 08:21:53 -0800 (PST) Received: by mail-wr1-x444.google.com with SMTP id m5so17004093wrx.9 for ; Mon, 14 Dec 2020 08:21:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=xM7IreNxcob2fMrsIvxPnMHYtLgjhQjp5pSGZ4CVHAI=; b=tSi9wEPdP6lrj+J3aQIo1pTjfjfZ2X/GXaVGV5up1X6sYxBrMj4uptj/k3A9KG2O6a QRAMjcghmin5nAXj+xgWhmYMvgBkDO/2YLBYLr9HdlJI1yZkWFlf+S8TqE978P0ONjuE wrKib14o+yvxR6RnyDgzeqm9JiyjqrBtT6GIh9ky+KHRMR+2qrzcRPkYQt2Kzqmqk6Ax OLfNceT7cCir8puc8ZLOqPRBvKY36Cat3A2KpCcsMW0qdE2wZ1KQzqBjGyMXHiD11QW+ LeWhVJYn0aCsM2NXI4QMEXiFO5j0O/TfDzNpyqI0VtaDUhbJWFU1Cl9fAO4hDkKo2UbY 3UxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=xM7IreNxcob2fMrsIvxPnMHYtLgjhQjp5pSGZ4CVHAI=; b=pibEcZPgPqs2owoJxsktWZyxr3VCSBkCU61U8XIMPeP1Kng+FAHKT6IZzT3AKAf72q AfJ6QX07PJxTme8oZmgf4hqEZEFqJfEOnX5WhTTiCnxBlAjfz/0ULiUoHwd73ei01SoV zMKkHto75gve6RF9DWO4dqNuHuhvnnfSOylbUUVtjIBB+MhS9LaNA00prjDh8iJsY6Pd jBEU36QU/BTo9B089P7W0o9LMzVu3hdQl9IgyTbGNxTL0eBYt/SNCrKGvwn6NbrmZMxe s9jtwdfqJZYWke6mZzHXit2Q1FUaVRFNbbid1lhQ2PAi++zakTZFHU53tzxHZEbAxzDK NTfg== X-Gm-Message-State: AOAM531ApCn5Dh0g+ckYFMYTGVk3mTjJ+D522vcoCCzbKJj17pK0SJ8M Lm3rA+Ow5a/VudAeSdLpD73rYohawPY= X-Google-Smtp-Source: ABdhPJycRGOsebt9YcoGKQnRXEo1urth5AtfYlrbRmubChJ43CmHvOVoMsYy3wQdsnma9J2fgxzS+w== X-Received: by 2002:adf:8184:: with SMTP id 4mr30776075wra.63.1607962912199; Mon, 14 Dec 2020 08:21:52 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id c4sm32387659wmf.19.2020.12.14.08.21.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 08:21:51 -0800 (PST) Message-Id: <22cb71102614f9d1fdd41a4b9524f11e08afa241.1607962900.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 14 Dec 2020 16:21:39 +0000 Subject: [PATCH v2 10/11] merge-ort: add implementation of normal rename handling Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Elijah Newren , Johannes Schindelin , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren Implement handling of normal renames. This code replaces the following from merge-recurisve.c: * the code relevant to RENAME_NORMAL in process_renames() * the RENAME_NORMAL case of process_entry() Also, there is some shared code from merge-recursive.c for multiple different rename cases which we will no longer need for this case (or other rename cases): * handle_rename_normal() * setup_rename_conflict_info() The consolidation of four separate codepaths into one is made possible by a change in design: process_renames() tweaks the conflict_info entries within opt->priv->paths such that process_entry() can then handle all the non-rename conflict types (directory/file, modify/delete, etc.) orthogonally. This means we're much less likely to miss special implementation of some kind of combination of conflict types (see commits brought in by 66c62eaec6 ("Merge branch 'en/merge-tests'", 2020-11-18), especially commit ef52778708 ("merge tests: expect improved directory/file conflict handling in ort", 2020-10-26) for more details). That, together with letting worktree/index updating be handled orthogonally in the merge_switch_to_result() function, dramatically simplifies the code for various special rename cases. (To be fair, the code for handling normal renames wasn't all that complicated beforehand, but it's still much simpler now.) Signed-off-by: Elijah Newren --- merge-ort.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/merge-ort.c b/merge-ort.c index 4150ccc35e1..9aac33c8e31 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -869,7 +869,11 @@ static int process_renames(struct merge_options *opt, rename_branch, delete_branch); } else { /* normal rename */ - die("Not yet implemented"); + memcpy(&newinfo->stages[other_source_index], + &oldinfo->stages[other_source_index], + sizeof(newinfo->stages[0])); + newinfo->filemask |= (1 << other_source_index); + newinfo->pathnames[other_source_index] = oldpath; } } From patchwork Mon Dec 14 16:21:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 11972489 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=-12.7 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 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 2CE53C4361B for ; Mon, 14 Dec 2020 16:25:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D1025225AC for ; Mon, 14 Dec 2020 16:25:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440137AbgLNQZo (ORCPT ); Mon, 14 Dec 2020 11:25:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2440261AbgLNQXL (ORCPT ); Mon, 14 Dec 2020 11:23:11 -0500 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4FFEC0611C5 for ; Mon, 14 Dec 2020 08:21:54 -0800 (PST) Received: by mail-wr1-x434.google.com with SMTP id r7so17015525wrc.5 for ; Mon, 14 Dec 2020 08:21:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=HKfFEAEP56e8cli3HrU4PsQz5b6i5gxzOGNKStkT99I=; b=lY5PxzGs6Xcongk2q0NWls/XW6vM2KeE9cRuoS9PfDQnta3quL+E6j6NnkqXYj9PiI zaPPNIhcQAnvBtz4fp6EwloBuWT+aWzmI43ZIvJ7KH5fjYAYGmzOiOZQTwoLAFcWDdEM 06ntDaOe+wvOfAH+EyU2DV6GV8+uiQUWhrQbfRQXd6RM0l0NoTka3arB8piXYByceDrv dOPVgacFK31sStpjwW7a39/fxVgKsfcChY5SIs9nudh6Nx5TJdTkp3mGj1Z7BQ3hgVFu w70eeY+8F3mUGSvssnZYrRPng30F/jSqLJbnzWDyHjE4HlC/8wJSinmqqDrayzg5i9Vr SrPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=HKfFEAEP56e8cli3HrU4PsQz5b6i5gxzOGNKStkT99I=; b=BasqMahXAZnRd/5SM3cSKUs79B8/OVUKbOkTKFRLQCNYoOY/JJgRkZ+1BGaM1qT0MV WDV3qF4/lMglmkkyhCR5gwbHM+9MeBneJJmrDFy42gb+jAqqfrKowQHtyU0bpczDT34v uZwsB9AyM65YVZ5zGCxESSG5DlqMSwZe6Y6jPaeQBaXJRvd0wLlVPqrfAwwP8SEDJdtv tf7GLmylbHdZ9Ie0s/nHIVnVAjKDQ8eSZZnJi5OHDaOK7h40AasR99saFdSXUlwF17mC jIUlN0u1KjQ1/ZXNRNBlyKVmD9z+FHxR8p8KpSL7hZyErNPne5IBFnzcrG0cOE4OwYlR j+/w== X-Gm-Message-State: AOAM530fmAxYBR781hRTrL0+tCRjoLDeIzc1G1ns8pXPxDyoL5ye0tAK yhx7LCv3+RYmeQmpGZqaclxXGaVQSNo= X-Google-Smtp-Source: ABdhPJzaiva9DaAFSOypgan9wsSUaVgccwDzOiP1KHBnbHJ6mD7XBAL7GZzbGUeqVCIFOcxdZlvULw== X-Received: by 2002:adf:e705:: with SMTP id c5mr28961515wrm.303.1607962913111; Mon, 14 Dec 2020 08:21:53 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id a18sm31982919wrr.20.2020.12.14.08.21.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 08:21:52 -0800 (PST) Message-Id: In-Reply-To: References: Date: Mon, 14 Dec 2020 16:21:40 +0000 Subject: [PATCH v2 11/11] merge-ort: add implementation of type-changed rename handling Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Elijah Newren , Johannes Schindelin , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren Implement cases where renames are involved in type changes (i.e. the side of history that didn't rename the file changed its type from a regular file to a symlink or submodule). There was some code to handle this in merge-recursive but only in the special case when the renamed file had no content changes. The code here works differently -- it knows process_entry() can handle mode conflicts, so it does a few minimal tweaks to ensure process_entry() can just finish the job as needed. Signed-off-by: Elijah Newren --- merge-ort.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/merge-ort.c b/merge-ort.c index 9aac33c8e31..11e33f56edf 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -778,7 +778,32 @@ static int process_renames(struct merge_options *opt, S_ISREG(newinfo->stages[target_index].mode)); if (type_changed && collision) { /* special handling so later blocks can handle this */ - die("Not yet implemented"); + /* + * if type_changed && collision are both true, then this + * was really a double rename, but one side wasn't + * detected due to lack of break detection. I.e. + * something like + * orig: has normal file 'foo' + * side1: renames 'foo' to 'bar', adds 'foo' symlink + * side2: renames 'foo' to 'bar' + * In this case, the foo->bar rename on side1 won't be + * detected because the new symlink named 'foo' is + * there and we don't do break detection. But we detect + * this here because we don't want to merge the content + * of the foo symlink with the foo->bar file, so we + * have some logic to handle this special case. The + * easiest way to do that is make 'bar' on side1 not + * be considered a colliding file but the other part + * of a normal rename. If the file is very different, + * well we're going to get content merge conflicts + * anyway so it doesn't hurt. And if the colliding + * file also has a different type, that'll be handled + * by the content merge logic in process_entry() too. + * + * See also t6430, 'rename vs. rename/symlink' + */ + collision = 0; + } if (source_deleted) { if (target_index == 1) { rename_branch = opt->branch1; @@ -858,7 +883,11 @@ static int process_renames(struct merge_options *opt, newinfo->pathnames[0] = oldpath; if (type_changed) { /* rename vs. typechange */ - die("Not yet implemented"); + /* Mark the original as resolved by removal */ + memcpy(&oldinfo->stages[0].oid, &null_oid, + sizeof(oldinfo->stages[0].oid)); + oldinfo->stages[0].mode = 0; + oldinfo->filemask &= 0x06; } else if (source_deleted) { /* rename/delete */ newinfo->path_conflict = 1;