From patchwork Sat Dec 25 07:59:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12699205 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11F2CC433F5 for ; Sat, 25 Dec 2021 07:59:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231124AbhLYH7e (ORCPT ); Sat, 25 Dec 2021 02:59:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230462AbhLYH71 (ORCPT ); Sat, 25 Dec 2021 02:59:27 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A566CC061757 for ; Fri, 24 Dec 2021 23:59:26 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id j18so21355907wrd.2 for ; Fri, 24 Dec 2021 23:59:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=obkKWvubyxcsBWBqodq9GjqtIG2fyoJpZDBmj1ztp44=; b=ndIGkA1FYHXmx096r3EiWcHU8QuzrvrMmMKA/SaDlATFqJviJACmklbxuNrR89wsCw lYU9fF6tHWx2fC26Y3AIzn4U67cK4IKmvkXEAhQmzhFsyQ6P2KETgP/zbUvlyXRjpC4g eWUmqX+N3IpUH9AAfVDKh8MxKHC71gZNOPqnU/R1Am052a6wb7PHDITWz+wOh3pwjYWk tIRb5fusOOLpGSu1lD3DqJsXfeH+EY/f4cnzASQrYocW1w5CZtBTkRz7zreZEHCA8O7i 0IFrg7l6sKlexSlmyLVCzDo5hI2j0rx1NIiANH3Mt912TUd3+Ek6/KbS6mAO5mmeqibe Wngg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=obkKWvubyxcsBWBqodq9GjqtIG2fyoJpZDBmj1ztp44=; b=sblWChmQRfUwZ/+3nrO68qLeE3rbk5UP9nQWjHw27BvIVlOZ4lAXMY720kNd21WyHa 8gPc9xveQZioj4DPvlKGmh4NHktriiiPV1ljjCEUlifvC9iCM14kRwxAq4yKJx9Vtq4M WqC2FDmHCigBJO/RhKRDEA16tL9qSV4QCVjSMtlG8wYwLevpiDrDOxF/lsvA5FLVBazZ BQ7dZesL22W/hp6EOSJleCWZQ7JfVW7PBa2ruqIDxlpHbMOy49LLM0/Y4/hbEkEwoATg TZlx4MsggSlQuGxi6FfVxoEPSj2aKXQgjqBQP25CNmnn5rKzubZ0+OF6bFZLIoBlus1S AvEQ== X-Gm-Message-State: AOAM532my6IqjkELw8lCUSuWC7zlyXyBGDJBHlMACzW8fGb2cN8Q1b8q imiJBN7+PFW61glPh0+g3N1oo9c0V64= X-Google-Smtp-Source: ABdhPJwGlgjjCsbPShYTQr5Bpp8kOXJq5OKR8zh5VTIDjZ+YQM7pMJT1reWWjhxoRUOvHaNO/Uri3A== X-Received: by 2002:a5d:540f:: with SMTP id g15mr6756558wrv.126.1640419165137; Fri, 24 Dec 2021 23:59:25 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id bd8sm9419520wmb.44.2021.12.24.23.59.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Dec 2021 23:59:24 -0800 (PST) Message-Id: In-Reply-To: References: Date: Sat, 25 Dec 2021 07:59:15 +0000 Subject: [PATCH v2 4/8] merge-ort: capture and print ll-merge warnings in our preferred fashion Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Jeff King , Jonathan Nieder , Sergey Organov , Bagas Sanjaya , Elijah Newren , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Neeraj Singh , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren Instead of immediately printing ll-merge warnings to stderr, we save them in our output strbuf. Besides allowing us to move these warnings to a special file for --remerge-diff, this has two other benefits for regular merges done by merge-ort: * The deferral of messages ensures we can print all messages about any given path together (merge-recursive was known to sometimes intersperse messages about other paths, particularly when renames were involved). * The deferral of messages means we can avoid printing spurious conflict messages when we just end up aborting due to local user modifications in the way. (In contrast to merge-recursive.c which prematurely checks for local modifications in the way via unpack_trees() and gets the check wrong both in terms of false positives and false negatives relative to renames, merge-ort does not perform the local modifications in the way check until the checkout() step after the full merge has been computed.) Signed-off-by: Elijah Newren --- merge-ort.c | 5 +++-- t/t6404-recursive-merge.sh | 9 +++++++-- t/t6406-merge-attr.sh | 9 +++++++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/merge-ort.c b/merge-ort.c index c24da2ba3cb..a18f47e23c5 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -1788,8 +1788,9 @@ static int merge_3way(struct merge_options *opt, &src1, name1, &src2, name2, &opt->priv->attr_index, &ll_opts); if (merge_status == LL_MERGE_BINARY_CONFLICT) - warning("Cannot merge binary files: %s (%s vs. %s)", - path, name1, name2); + path_msg(opt, path, 0, + "warning: Cannot merge binary files: %s (%s vs. %s)", + path, name1, name2); free(base); free(name1); diff --git a/t/t6404-recursive-merge.sh b/t/t6404-recursive-merge.sh index eaf48e941e2..b8735c6db4d 100755 --- a/t/t6404-recursive-merge.sh +++ b/t/t6404-recursive-merge.sh @@ -108,8 +108,13 @@ test_expect_success 'refuse to merge binary files' ' printf "\0\0" >binary-file && git add binary-file && git commit -m binary2 && - test_must_fail git merge F >merge.out 2>merge.err && - grep "Cannot merge binary files: binary-file (HEAD vs. F)" merge.err + if test "$GIT_TEST_MERGE_ALGORITHM" = ort + then + test_must_fail git merge F >merge_output + else + test_must_fail git merge F 2>merge_output + fi && + grep "Cannot merge binary files: binary-file (HEAD vs. F)" merge_output ' test_expect_success 'mark rename/delete as unmerged' ' diff --git a/t/t6406-merge-attr.sh b/t/t6406-merge-attr.sh index 84946458371..c41584eb33e 100755 --- a/t/t6406-merge-attr.sh +++ b/t/t6406-merge-attr.sh @@ -221,8 +221,13 @@ test_expect_success 'binary files with union attribute' ' printf "two\0" >bin.txt && git commit -am two && - test_must_fail git merge bin-main 2>stderr && - grep -i "warning.*cannot merge.*HEAD vs. bin-main" stderr + if test "$GIT_TEST_MERGE_ALGORITHM" = ort + then + test_must_fail git merge bin-main >output + else + test_must_fail git merge bin-main 2>output + fi && + grep -i "warning.*cannot merge.*HEAD vs. bin-main" output ' test_done