From patchwork Mon Aug 3 18:41:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain via GitGitGadget X-Patchwork-Id: 11698573 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 10F8414DD for ; Mon, 3 Aug 2020 18:41:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 49C5C22C9F for ; Mon, 3 Aug 2020 18:41:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="vCKUMmI3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728813AbgHCSlZ (ORCPT ); Mon, 3 Aug 2020 14:41:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728741AbgHCSlY (ORCPT ); Mon, 3 Aug 2020 14:41:24 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F4DAC061756 for ; Mon, 3 Aug 2020 11:41:24 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id k8so551726wma.2 for ; Mon, 03 Aug 2020 11:41:24 -0700 (PDT) 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=fvsCY/LQLBO1naRThY5dZ2dM+VjRgURHHXEDtpLNsMI=; b=vCKUMmI3IQTTrw7Y8gAVYIX/3JQbXhPKL4kewmrnN1Sc3DVPas9M8U15562VRZAlEf 2S9sRoBeLvRq8/wZ42pLUHHBBwU/srUbfood3wJ8WWh0Yg4+ZRobGgyXb+oYnXqo+SQq 9dwb+03HSxgA8lsKHdU3fAUqN36bWH29RjFyUMU2DVB/r/tCSq796oy3+EmsqRwTjRaa WkK/Y8Wmax2g/ozeufFyWHs4Y21w7H6jmnn8hwoVZETlqHlbfa0AVPX1y8Jed63VbeT6 s+2sEJlF/2MpvQHnpmE/5ePpww7GlR6ip2RJdSYYMjhZqNTDjDK9noVpDeUWTgznrnzn R6YA== 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=fvsCY/LQLBO1naRThY5dZ2dM+VjRgURHHXEDtpLNsMI=; b=g4eYI+7t1n1kUEYY9BBO6IxU5jGIumgyfgzFvRfLbrbD3l9BH1jv4UCdiQRwbO8bm+ udhHx231dX3vxwr9NFELjhQnPiAo/UQkE0JrQogOR1osW/0BvMXnzQ6ZBnR5Sxd5xIuR OQnn0WYc4T4TqDDGYNjSDSzChCsmFb8VRg42H5gMBRXfsax8Qppg1yuG7aRI7/Xn89wL sNYWFg0kABIIjZb0H/yEb5o+/hZJP3l34BcJyqsVvHtVW4NKs1iqgTi53Sqh3MoQxfSK R8Bt28iEJVVnZPvFkycNsJessmbUA9fwIjv00uB6Tdj4EjxXrF/NEdl1zSZ3BMTkztIp hPFQ== X-Gm-Message-State: AOAM530FbZDHKpcWvORajEZpwRnXMBtG19XsIQ4MDGtnaUJEH3OOFFz+ 5xFw9bvpLsTLxtHGqADcAzHWg77y X-Google-Smtp-Source: ABdhPJyTXRy9FQdaKt4Zb28lpps8HQJ1oXPmPEjGl3g6ikLYkGwPPEg7s82lPsAhKlrEcHMDNraETQ== X-Received: by 2002:a1c:32c3:: with SMTP id y186mr477086wmy.15.1596480082741; Mon, 03 Aug 2020 11:41:22 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id t13sm25274077wru.65.2020.08.03.11.41.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 11:41:22 -0700 (PDT) Message-Id: <21033c4c1455bb1e0bd996a5861cc9414912768f.1596480080.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Elijah Newren via GitGitGadget" Date: Mon, 03 Aug 2020 18:41:17 +0000 Subject: [PATCH v2 1/4] t6038: make tests fail for the right reason Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Elijah Newren , Elijah Newren Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren t6038 had a pair of tests that were expected to fail, but weren't failing for the expected reason. Both were meant to do a merge that could be done cleanly after renormalization, but were supposed to fail for lack of renormalization. Unfortunately, both tests had staged changes, and checkout -m would abort due to the presence of those staged changes before even attempting a merge. Fix this first issue by utilizing git-restore instead of git-checkout, so that the index is left alone and just the working directory gets the changes we want. However, there is a second issue with these tests. Technically, they just wanted to verify that after renormalization, no conflicts would be present. This could have been checked for by grepping for a lack of conflict markers, but the test instead tried to compare the working directory files to an expected result. Unfortunately, the setting of "text=auto" without setting core.eol to any value meant that the content of the file (in particular, the line endings) would be platform-dependent and the tests could only pass on some platforms. Replace the existing comparison with a call to 'git diff --no-index --ignore-cr-at-eol' to verify that the contents, other than possible carriage returns in the file, match the expected results and in particular that the file has no conflicts from the checkout -m operation. Signed-off-by: Elijah Newren --- t/t6038-merge-text-auto.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/t/t6038-merge-text-auto.sh b/t/t6038-merge-text-auto.sh index 5e8d5fa50c..27cea15533 100755 --- a/t/t6038-merge-text-auto.sh +++ b/t/t6038-merge-text-auto.sh @@ -168,9 +168,9 @@ test_expect_failure 'checkout -m after setting text=auto' ' git rm -fr . && rm -f .gitattributes && git reset --hard initial && - git checkout a -- . && + git restore --source=a -- . && git checkout -m b && - compare_files expected file + git diff --no-index --ignore-cr-at-eol expected file ' test_expect_failure 'checkout -m addition of text=auto' ' @@ -183,9 +183,9 @@ test_expect_failure 'checkout -m addition of text=auto' ' git rm -fr . && rm -f .gitattributes file && git reset --hard initial && - git checkout b -- . && + git restore --source=b -- . && git checkout -m a && - compare_files expected file + git diff --no-index --ignore-cr-at-eol expected file ' test_expect_failure 'cherry-pick patch from after text=auto was added' ' From patchwork Mon Aug 3 18:41:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain via GitGitGadget X-Patchwork-Id: 11698579 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 62A3F913 for ; Mon, 3 Aug 2020 18:41:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A43EA20738 for ; Mon, 3 Aug 2020 18:41:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="F+k21TWj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728819AbgHCSl2 (ORCPT ); Mon, 3 Aug 2020 14:41:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728741AbgHCSlZ (ORCPT ); Mon, 3 Aug 2020 14:41:25 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EB34C06174A for ; Mon, 3 Aug 2020 11:41:25 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id y3so35142264wrl.4 for ; Mon, 03 Aug 2020 11:41:24 -0700 (PDT) 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=CF4fAwlJ+8DIgBxeicBGpMmXwcNi7ioibGZ5lOkqXUA=; b=F+k21TWjZOoi9fMrXtQ9b1sP/RwhAS4qftKHIA/IAtLXZIDOOFzwjl9iI/ksWU8EZx Jezso4FSShWggvbafu1Ihwz8WimmlsnVSqV2/xKs7/LOz+8IbrXnK3ccNZ+9p7WK6Lk3 JNCvzmDdei9c85p2EFcoqKjxpxc2oW1h+3A+jQl/Km1HlX512TyupoXBLmX6hcFpE1in fGM72YNrYGgtHSHm3QMJJ6P6EJSUzQfj2Bj5D0iqMubYrrVxybU5i2OZIP9Uu9lrZm/J YV6wbe2snz5x9kocicvhDyg8syq5zWNc7AvfZoBXFkcneJLzqpylscP2TeWrhI4ruxOm zmGw== 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=CF4fAwlJ+8DIgBxeicBGpMmXwcNi7ioibGZ5lOkqXUA=; b=ABZAn0DhijLsqAjIuU3+8ylj7Njk5zAWUk3RFODnNG7MtBKFz9GJiBCXToEVrTRqC5 c9Y5wIM72DR506/RcaMEN8m7EXSl0pjwMrbdwTI2GeLKRr3hLaAm5B7g8o9QyfIqonAT apOZwW6WQJVA2j0Hj80UzlJMOo1qSPdBqFbfGXCP7AZInW5gb8EHtZzsWB8xVmnSRTVM 9Mf0KCMgH1dPfqLSb5YqQM3M46mJcrqb/szegj0hcIxWpv+sXY05xkLwVnhVCCfRYYLl 1EbgB4WMpeRCgJSH9GaMePzxIPOBpyzRvRqvF9zkc7tuYdH4W3XLzQCYJh6Z+42v/eR+ vejw== X-Gm-Message-State: AOAM531N8DxiuEG1BJIlM15Yf+m3GOFZRS7sDzgjdxidI99SjobGQcyl sOkQPH+8w30hAmwDQDEufpkp9txG X-Google-Smtp-Source: ABdhPJzPRLtIIEDbOZibVfAdBBHuNSQDXFWVGHmGiw+tmJw2WbOhlvDiOe5q4LPftc7ftPJgSLSrRg== X-Received: by 2002:adf:ec10:: with SMTP id x16mr15597491wrn.74.1596480083591; Mon, 03 Aug 2020 11:41:23 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id i82sm829236wmi.10.2020.08.03.11.41.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 11:41:23 -0700 (PDT) Message-Id: <305fe534c5543cd71559ed2dca7e1657b0b8554c.1596480080.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Elijah Newren via GitGitGadget" Date: Mon, 03 Aug 2020 18:41:18 +0000 Subject: [PATCH v2 2/4] t6038: remove problematic test Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Elijah Newren , Elijah Newren Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren t6038.11, 'cherry-pick patch from after text=auto' was a test of undefined behavior. To make matters worse, while there are a couple possible correct answers, this test was coded to only check for an obviously incorrect answer. And the final cherry on top is that the test is marked test_expect_failure, meaning it can't provide much value, other than possibly confusing future folks who come along and try to work on attributes and look at existing tests. Because of all these problems, just remove the test. But for any future code spelunkers, here's my understanding of the two possible correct answers: This test was set up so that on a branch with no .gitattributes file, you cherry-picked a patch from a branch that had a .gitattributes file (containing '* text=auto'). Further, the two branches had a file which differed only in line endings. In this situation, correct behavior is not well defined: should the .gitattributes file affect the merge or not? If the .gitattributes file on the other branch should not affect the merge, then we would have a content conflict with all three stages different (the merge base didn't match either side). If the .gitattributes file from the other branch should affect the merge, then we would expect the line endings to be normalized to LF for the version to be recorded in the repository. This would mean that when doing a three-way content merge on the file that differed in line endings, that the three-way content merge would see that the versions on both sides matched and so the cherry-pick has no conflicts and can succeed. The line endings in the file as recorded in the repository will change from CRLF to LF. The version checked out in the working copy will depend on the platform (since there's no eol attribute defined for the file). Also, as a final side note, this test expected an error message that was built assuming cherry-pick was the old scripted version, because cherry-pick no longer uses the error message that was encoded in this test. So it was wrong for yet another reason. Given that the handling of .gitattributes is not well defined and this test was obviously broken and could do nothing but confuse future readers, just remove it. Signed-off-by: Elijah Newren --- t/t6038-merge-text-auto.sh | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/t/t6038-merge-text-auto.sh b/t/t6038-merge-text-auto.sh index 27cea15533..9337745793 100755 --- a/t/t6038-merge-text-auto.sh +++ b/t/t6038-merge-text-auto.sh @@ -188,20 +188,6 @@ test_expect_failure 'checkout -m addition of text=auto' ' git diff --no-index --ignore-cr-at-eol expected file ' -test_expect_failure 'cherry-pick patch from after text=auto was added' ' - append_cr <<-\EOF >expected && - first line - same line - EOF - - git config merge.renormalize true && - git rm -fr . && - git reset --hard b && - test_must_fail git cherry-pick a >err 2>&1 && - grep "[Nn]othing added" err && - compare_files expected file -' - test_expect_success 'Test delete/normalize conflict' ' git checkout -f side && git rm -fr . && From patchwork Mon Aug 3 18:41:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain via GitGitGadget X-Patchwork-Id: 11698581 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ADCB114DD for ; Mon, 3 Aug 2020 18:41:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EEBD922C9F for ; Mon, 3 Aug 2020 18:41:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="H22p+DGs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728817AbgHCSl2 (ORCPT ); Mon, 3 Aug 2020 14:41:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728755AbgHCSl0 (ORCPT ); Mon, 3 Aug 2020 14:41:26 -0400 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 EE291C061756 for ; Mon, 3 Aug 2020 11:41:25 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id p14so497734wmg.1 for ; Mon, 03 Aug 2020 11:41:25 -0700 (PDT) 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=BXeq9ERjQ8KnIWUx5zs0u7S0zhJaOTGrl+bzsPdosG4=; b=H22p+DGsN9XxBJs2TnPvwwIu9qLy7T44jh2hvFfR067bhrgPJEB/3BRGpBHnucUJNj wwRiCkGCwrsq7MQxeEi0x5oK/aEpTCEYZsYYPTeiAg0dUKqFfLX5DF/uYa2iHBI95S2O On5+ibqsz7+JzsE5ENEuNO+8bx9B0pBrkTjTo4SMiZljV8voO8WIL7Eg0pV9UWXBo1Sk 8tiitGOKaekSjS9qQzsDCCBKDX9/INXHltmZaFdQ5M6lu5pBVh2X6bzGFEIivFvrCfjF hOuJCEqbpKmLS/4TiYOlOL3jL0iHl78+ospi1zYqRx0TcOBfnmeqvGGI7RtXvw8nQMIL ClIA== 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=BXeq9ERjQ8KnIWUx5zs0u7S0zhJaOTGrl+bzsPdosG4=; b=aJZCy3B67YLXXMZ8mmfUE7dkk/2SMXCVkmWGT44pSihcHufcpZirqjt4mzzdLhCMBv YbSLgihKBZGZfmM36hH7WdsQmtIQ3mmx7mEARHROO01ITJSuZZ408LbdiED9aIpwvn64 R9Q3pzHx34tz43cGQw4TYGXxrmOGx7BfhSYV0juwXjhDJpYwcfBCO/vQphgLUSVs82ko 10AswRKJtiXnc/UCVaz2azYL9w2Nah7+m4DRLayA0IsnUKIei8b0wdq6eHvH7U4M6HAV ckdTQKCr65mATKKr3BjQD8fkNsHq50QZ1SPDt1TjzTwqcikTzvJC4Sw5QEpml4fqNu7V bx6Q== X-Gm-Message-State: AOAM533vUyl4UmlIOyuyODCoW2D8bnNmkqyo/FCDtF4GE9YZorirDI6o XyoGeQO93VItx8LpLefO9fiDWEE9 X-Google-Smtp-Source: ABdhPJwoiANdTTm+6W+WJhrgHYG6Wc9UQiNwSkkh5+85lrmUymlno0m2E7qJSzc5HZlA0vxHetwVag== X-Received: by 2002:a05:600c:2116:: with SMTP id u22mr478360wml.35.1596480084601; Mon, 03 Aug 2020 11:41:24 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id z7sm748039wmk.6.2020.08.03.11.41.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 11:41:24 -0700 (PDT) Message-Id: <379a87ea825b43645ef35bb0ff880cc3a5e40048.1596480080.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Elijah Newren via GitGitGadget" Date: Mon, 03 Aug 2020 18:41:19 +0000 Subject: [PATCH v2 3/4] merge: make merge.renormalize work for all uses of merge machinery Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Elijah Newren , Elijah Newren Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren The 'merge' command is not the only one that does merges; other commands like checkout -m or rebase do as well. Unfortunately, the only area of the code that checked for the "merge.renormalize" config setting was in builtin/merge.c, meaning it could only affect merges performed by the "merge" command. Move the handling of this config setting to merge_recursive_config() so that other commands can benefit from it as well. Fixes a few tests in t6038. Signed-off-by: Elijah Newren --- builtin/checkout.c | 7 ------- builtin/merge.c | 4 ---- merge-recursive.c | 3 +++ t/t6038-merge-text-auto.sh | 4 ++-- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/builtin/checkout.c b/builtin/checkout.c index af849c644f..18c49034c4 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -771,13 +771,6 @@ static int merge_working_tree(const struct checkout_opts *opts, */ add_files_to_cache(NULL, NULL, 0); - /* - * NEEDSWORK: carrying over local changes - * when branches have different end-of-line - * normalization (or clean+smudge rules) is - * a pain; plumb in an option to set - * o.renormalize? - */ init_merge_options(&o, the_repository); o.verbosity = 0; work = write_in_core_index_as_tree(the_repository); diff --git a/builtin/merge.c b/builtin/merge.c index 7da707bf55..74829a838e 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -72,7 +72,6 @@ static const char **xopts; static size_t xopts_nr, xopts_alloc; static const char *branch; static char *branch_mergeoptions; -static int option_renormalize; static int verbosity; static int allow_rerere_auto; static int abort_current_merge; @@ -621,8 +620,6 @@ static int git_merge_config(const char *k, const char *v, void *cb) return git_config_string(&pull_octopus, k, v); else if (!strcmp(k, "commit.cleanup")) return git_config_string(&cleanup_arg, k, v); - else if (!strcmp(k, "merge.renormalize")) - option_renormalize = git_config_bool(k, v); else if (!strcmp(k, "merge.ff")) { int boolval = git_parse_maybe_bool(v); if (0 <= boolval) { @@ -721,7 +718,6 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common, if (!strcmp(strategy, "subtree")) o.subtree_shift = ""; - o.renormalize = option_renormalize; o.show_rename_progress = show_progress == -1 ? isatty(2) : show_progress; diff --git a/merge-recursive.c b/merge-recursive.c index 36948eafb7..a1c8b36ddb 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -3791,9 +3791,12 @@ int merge_recursive_generic(struct merge_options *opt, static void merge_recursive_config(struct merge_options *opt) { char *value = NULL; + int renormalize = 0; git_config_get_int("merge.verbosity", &opt->verbosity); git_config_get_int("diff.renamelimit", &opt->rename_limit); git_config_get_int("merge.renamelimit", &opt->rename_limit); + git_config_get_bool("merge.renormalize", &renormalize); + opt->renormalize = renormalize; if (!git_config_get_string("diff.renames", &value)) { opt->detect_renames = git_config_rename("diff.renames", value); free(value); diff --git a/t/t6038-merge-text-auto.sh b/t/t6038-merge-text-auto.sh index 9337745793..89c86d4e56 100755 --- a/t/t6038-merge-text-auto.sh +++ b/t/t6038-merge-text-auto.sh @@ -158,7 +158,7 @@ test_expect_success 'Detect LF/CRLF conflict from addition of text=auto' ' compare_files expected file.fuzzy ' -test_expect_failure 'checkout -m after setting text=auto' ' +test_expect_success 'checkout -m after setting text=auto' ' cat <<-\EOF >expected && first line same line @@ -173,7 +173,7 @@ test_expect_failure 'checkout -m after setting text=auto' ' git diff --no-index --ignore-cr-at-eol expected file ' -test_expect_failure 'checkout -m addition of text=auto' ' +test_expect_success 'checkout -m addition of text=auto' ' cat <<-\EOF >expected && first line same line From patchwork Mon Aug 3 18:41:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain via GitGitGadget X-Patchwork-Id: 11698575 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5A09C913 for ; Mon, 3 Aug 2020 18:41:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 99F3F22BF3 for ; Mon, 3 Aug 2020 18:41:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="F+FB/o+H" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728821AbgHCSl2 (ORCPT ); Mon, 3 Aug 2020 14:41:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728814AbgHCSl1 (ORCPT ); Mon, 3 Aug 2020 14:41:27 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C85FDC061757 for ; Mon, 3 Aug 2020 11:41:26 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id y3so35142333wrl.4 for ; Mon, 03 Aug 2020 11:41:26 -0700 (PDT) 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=x7mt8q9mrmBv6ufF03Gh1PR5EdY4MRfFqXa2dOXs0tE=; b=F+FB/o+HIFdvLRon1iM5wyFD13Rhzvbdey0hxjT99MNdTdxkC29jI4CezyIe4x2Xy1 Kd8ZbXvg1obUeapdnz9j2GMQVfsEU5IsKJyQEXdt0q7d7kuZXDs9NlcLFfW98v0jSAX6 ZS8/7AdV6kR2Myzjpg5DLgBV4xdS5zvJhC1ewqGgn2JBGkTURWX/O9y35tS9xCgln2HG 1t5OWhiiB6UAjezINQE1LBzugDwMcfnBL4fRvd1yliVlsN/5rDkRi7/tFl4cSiRRsgof 688tINWfaVNvobMprXWbT1B2artPSWCQDtdVLVOzkNZH8VLUyTqod/sDfnnEBjGrRPhp JI/g== 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=x7mt8q9mrmBv6ufF03Gh1PR5EdY4MRfFqXa2dOXs0tE=; b=VJJG2ceoBuQxdI0dgmJLOIDsNypLEl+nk6jIU/U/ZPfi/CpnBW/++ik0qM/vm/fzmI Qz5WnZ5vULAy25cDHqInreXn9Mtj2HXSu+5gredNnmkEwrrO3bFCw/N18AkHTCYnleWm NMnK3o+hQDgZe4cT+Yd/dud/XOp0CmDgK0c50sYaR/Q9ptcm+tMBH7h+vQUAsKfD9rM4 aOwOhzx7LFC7W5RnlNXXrcoA3gO9Oh4BtMvpGua2LguatVErdCogoUf9xQLNxodcjI5h cOP9IOSgMvS8G69UahTWvn//6RoFxe9+hw11/cxaTLNlxL5c6cPbNPrORMdBCbdYW3BY xsLA== X-Gm-Message-State: AOAM5308Gy9seacjuARIb35pqIIMylurQAqCJAEk0FwuLfPmv6VQMb7v GTBMniOWemsEp4pQKDTggUG7mNNY X-Google-Smtp-Source: ABdhPJxlWJ8Cx63q8g7LbVON609bF3F5Pcr/rf7mFyI2yXSwtSIfRJEVBSebcZl7XXuHiA0p+FY/SQ== X-Received: by 2002:a5d:6a41:: with SMTP id t1mr6772571wrw.388.1596480085364; Mon, 03 Aug 2020 11:41:25 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id j24sm29049007wrb.49.2020.08.03.11.41.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 11:41:24 -0700 (PDT) Message-Id: <36e08a75a3b9fdb0d5ca643f214fe4524578716f.1596480080.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Elijah Newren via GitGitGadget" Date: Mon, 03 Aug 2020 18:41:20 +0000 Subject: [PATCH v2 4/4] checkout: support renormalization with checkout -m Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Elijah Newren , Elijah Newren Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren Signed-off-by: Elijah Newren --- builtin/checkout.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/builtin/checkout.c b/builtin/checkout.c index 18c49034c4..2837195491 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -239,6 +239,8 @@ static int checkout_merged(int pos, const struct checkout *state, int *nr_checko mmbuffer_t result_buf; struct object_id threeway[3]; unsigned mode = 0; + struct ll_merge_options ll_opts; + int renormalize = 0; memset(threeway, 0, sizeof(threeway)); while (pos < active_nr) { @@ -259,13 +261,12 @@ static int checkout_merged(int pos, const struct checkout *state, int *nr_checko read_mmblob(&ours, &threeway[1]); read_mmblob(&theirs, &threeway[2]); - /* - * NEEDSWORK: re-create conflicts from merges with - * merge.renormalize set, too - */ + memset(&ll_opts, 0, sizeof(ll_opts)); + git_config_get_bool("merge.renormalize", &renormalize); + ll_opts.renormalize = renormalize; status = ll_merge(&result_buf, path, &ancestor, "base", &ours, "ours", &theirs, "theirs", - state->istate, NULL); + state->istate, &ll_opts); free(ancestor.ptr); free(ours.ptr); free(theirs.ptr);