From patchwork Sun Aug 2 06:33:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jean-No=C3=ABl_Avila_via_GitGitGadget?= X-Patchwork-Id: 11696267 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 9FA1813B1 for ; Sun, 2 Aug 2020 06:33:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 83384207FB for ; Sun, 2 Aug 2020 06:33:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="l08UUrp1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726370AbgHBGdL (ORCPT ); Sun, 2 Aug 2020 02:33:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725882AbgHBGdK (ORCPT ); Sun, 2 Aug 2020 02:33:10 -0400 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 2E025C06174A for ; Sat, 1 Aug 2020 23:33:10 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id t14so7452322wmi.3 for ; Sat, 01 Aug 2020 23:33:10 -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=QSqIS22JH6HGyeIdne1x4lI2cgyJOLuB1JQ3W5nl7/Y=; b=l08UUrp1ddehBiT72F5t7jcOaaAE+/GRtltbeVMfWfTxXWntegCxbSShOWM952z8j6 +3Mfwp9ypOnwr0FfgSH7Tuw6DLYNOFs4yWyfCvavLL7bP7YL5BO87h2IAcijRV72bnAH RQcsOP/tH6ZCEmJ+f4+y6QrNqdzsrxsyGk2xG9jUvSY1vKUwlprxLILoZ5321LR6Oizj XavTX6RUDzYmXelJ4p1l3nNcmRZ6TZ74NQ0qzVXweHqmqNqOAXg5JQ72BuQmLrgZZAZt Xe5h3ERqOTnTr0O/sd7tK3ahqupMWEGLT6RL/ob4BxfMjhYrkDAbgG4ttXlZhQAvc5km e/4Q== 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=QSqIS22JH6HGyeIdne1x4lI2cgyJOLuB1JQ3W5nl7/Y=; b=QtGKrL8CeTgndEypmMMFRQr3CZOHJ45U9zrytMOlnjTp/Y8ds8Vn07cgzyvEI8SyKB nDXiMWXye97ofi45tQE1/eNNBtxPwJuwI8ceerPDIOaa4AVxPqJmjvtulXdwTqYDwfvJ qWjUw1xc1VjIQiySjgiSwQHfqFD42YE646Ve7i4nxW2yyYZo0DyCozVEg+8QPcQ0I6Qd 0Xvwn1BAx/hsrBa/jLnTZjo+CACeLACaN5bQKw1QOXqA2IKsmM/y2y8OsVfko8qVtjOd LZiRo+la84q1eEt96H2XB1E4Gz7NJHCCFPGlHINEYIE60GfjsAIMHWkF5k4CpFxvlTTU vbIQ== X-Gm-Message-State: AOAM533TV/sPEx+LXIh0O5S/UA7KvXqlInFxPyySNFcce/4Dx1I5jtg1 yhNre1MzB1aU5GjIlvEm8Vnm8j3X X-Google-Smtp-Source: ABdhPJwWFaUEY05sJUt+QddSPaRl/kbuliqXEoCPcVoRNk0PD+XNWdSVO0pwEAUYsSb0/dXGusqDiw== X-Received: by 2002:a1c:7702:: with SMTP id t2mr4858664wmi.169.1596349988743; Sat, 01 Aug 2020 23:33:08 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id h14sm17513285wml.30.2020.08.01.23.33.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2020 23:33:08 -0700 (PDT) Message-Id: <361911817559104672d273e199221e8367e8d595.1596349986.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Elijah Newren via GitGitGadget" Date: Sun, 02 Aug 2020 06:33:03 +0000 Subject: [PATCH 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 has 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 Sun Aug 2 06:33:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jean-No=C3=ABl_Avila_via_GitGitGadget?= X-Patchwork-Id: 11696273 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 92D3514E3 for ; Sun, 2 Aug 2020 06:33:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7AA0E207DF for ; Sun, 2 Aug 2020 06:33:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DEVkMRSq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726709AbgHBGdN (ORCPT ); Sun, 2 Aug 2020 02:33:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725882AbgHBGdM (ORCPT ); Sun, 2 Aug 2020 02:33:12 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A456FC06174A for ; Sat, 1 Aug 2020 23:33:11 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id z18so27778015wrm.12 for ; Sat, 01 Aug 2020 23:33:11 -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=2AZQUN6wp1aycp+qZzVmMt6E6FNqbqAGtu9qSoEB2T8=; b=DEVkMRSqypzl3Bm+y9fje8HiMKqh9AxSz1blQGXiX9St+jLAj0G9t2q6k12eSFsPXZ CwwkgujTLL6ojrhZX8XXZjRmhf23jqChtuCXIweBvyFiXBopFywslh5AVOpCfLbQ3cFo T/ANu3amAb4k9qaRqyeGf7Os20CmcJs7n6rSMWXO9enKxi3hyoyXBfyAIP7TaCprNDPJ nf8Ea5M3JeEHRT8Dai4RtQ7NiM39CfCvOv84BLC1n1EuWuWQ5nFuSp/WST4VBKmcfvb7 VkERRwIKUrtFs6N3cmm7LPq6QF7+bixYvBo/5s5W/0XJ0L8qV8VeMECdxJNeUTGbGWWQ s4LA== 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=2AZQUN6wp1aycp+qZzVmMt6E6FNqbqAGtu9qSoEB2T8=; b=BWr7L+uKQs1ODBhxGjlcKIWMsK6XOYt6BdFaVZTUDW5EaqSINl6YLVfhbg5ichq69j Fk4OcdRhoTCIoAjWO457h8X+ofk01gIR4S7P1O1vkXV1mrzLiGsLYJ7Uoht38JYyo6m6 tRsudVGOovUZ66QO6n3cbdyHZWQxGP0eV1tKiRa+EHdYbG3yqDo0+/WDvy8DoleWE7o9 RwQpD6yehCsDAbX/Zcdbnf+D0acq/mDhP6tnWdEHEj6u3/xw/CN31LqoGavjKk88/2bL xs/C2gO+OIArzayXwK4ihwf3Y81VT1Ag3CnG+kN9KwQZ6NHlUx9mUWOgPskM18a7IfoZ jqvQ== X-Gm-Message-State: AOAM531M6DVOzyY2SJZCx52F0fSq0AEWOiaQTCosZUoDr1z6Z/m6HtIs aq8A+87XAgCKrt8Mnh43P0R08rWK X-Google-Smtp-Source: ABdhPJwLg9tuzwiYx51EQ2pKcmpIlar0sVNuJA+r/F8cr4kc3ppTHlzIViwvXghr2zx7GAQVviAZ1Q== X-Received: by 2002:adf:d092:: with SMTP id y18mr9445570wrh.145.1596349989490; Sat, 01 Aug 2020 23:33:09 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id 31sm18977701wrj.94.2020.08.01.23.33.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2020 23:33:09 -0700 (PDT) Message-Id: <83a50f7e0bbfd19cffc5cffb9f17484e86443d0a.1596349986.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Elijah Newren via GitGitGadget" Date: Sun, 02 Aug 2020 06:33:04 +0000 Subject: [PATCH 2/4] t6038: fix test with obviously incorrect expectations 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 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 so that the versions from both sides match, and then the cherry-pick has no conflicts and can succeed. After the cherry-pick, the line endings in the file will change from CRLF to LF. This test had an expectation that the line endings would remain CRLF. Further, it 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, although I don't know what correct behavior for this test is, I know that this test was not testing for it. Since I have no idea which of the two cases above provides correct behavior, let's just assume for now it's the case where we assume that .gitattributes affects the merge and update it accordingly. 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 27cea15533..39413d5b48 100755 --- a/t/t6038-merge-text-auto.sh +++ b/t/t6038-merge-text-auto.sh @@ -189,7 +189,7 @@ test_expect_failure 'checkout -m addition of text=auto' ' ' test_expect_failure 'cherry-pick patch from after text=auto was added' ' - append_cr <<-\EOF >expected && + cat <<-\EOF >expected && first line same line EOF @@ -197,9 +197,9 @@ test_expect_failure 'cherry-pick patch from after text=auto was added' ' 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 + git cherry-pick a && + git cat-file -p HEAD:file >actual && + compare_files expected actual ' test_expect_success 'Test delete/normalize conflict' ' From patchwork Sun Aug 2 06:33:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jean-No=C3=ABl_Avila_via_GitGitGadget?= X-Patchwork-Id: 11696269 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 4A03413B1 for ; Sun, 2 Aug 2020 06:33:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 31344207FB for ; Sun, 2 Aug 2020 06:33:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="B6+bqWIv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726752AbgHBGdN (ORCPT ); Sun, 2 Aug 2020 02:33:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726376AbgHBGdM (ORCPT ); Sun, 2 Aug 2020 02:33:12 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7C6AC061756 for ; Sat, 1 Aug 2020 23:33:11 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id f18so31351275wrs.0 for ; Sat, 01 Aug 2020 23:33:11 -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=pstogkd3TviULbOdAJhgLbBOSB6LkNvy1gUwC4s5pss=; b=B6+bqWIvY5PLTzHuvFKyGR2KhEHf2nDSmujEb5TiA/wuF1MYt6SrB2/LbDTwbGuY6r alb5CEuaVtotfyLgtvISGFkqwyM/fQJy53Ai1RfuGqv5uwQ4/7iD5YAEgLoCn+/lFWYH Uz/dbymJx9st5g2fvdrDJFKivjZJPGSCVLyHERthhF3gWHrbkJmNt8SlQff+HXlqVCvP EVCiwBl90eLbJg3yEGp3CRHMPFjMD05mQWBYemerFG8W991UJJh52PouWeZ/DmTo3I1Y wnglWyQye1J0UgUmSDjFSSs+PkU7Ffkg8ovocxaimrH8091wTbwMivBqinq5OYTb7kKG HCmQ== 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=pstogkd3TviULbOdAJhgLbBOSB6LkNvy1gUwC4s5pss=; b=CKVeUwYbhlf523KT5sOwZl9oBYTCxjdndS3LacrBBte1rE0WvgKsebarKPblsfpoI9 CRCMyZuly7CXfc9BXbi4OthhLT/f6zoqkPTU0LQh5gDvGqn/bfPeEVw5N0gwmL+NYUJ4 UqGsfP+rKqTgbO29pHVFA7NWI8/SXiuFnQeDBNC9ee+r6qmLkmi5737YDrQtRD1PEtfD fOQl7QwyjiBcYiQU0nZwCuhzWvv3H9Maav0tsMIFbmOiICn8zo/yNS5oOEwAO2+7dR3k xt5krwUJQcsV6GlKfaJbpxiXL0ZZiCIcz5Jyp24KBizt9yPOjlF1TExG/iq4/HQGEUf1 PNfw== X-Gm-Message-State: AOAM533Zt/06EVqCvkrYEQY8J0JU0mECHf0o1YYki4yB51qcX98KX0tR FF7tfAd27L2IsTroGDdFQeM71KTb X-Google-Smtp-Source: ABdhPJw1l1YH1UWWMfq9ZO2HRX+4H5cAMKSbvHRDFUEMrwR6DS/B9uCvCgJt7Jcvk8bYaey8nLbYHQ== X-Received: by 2002:a5d:5151:: with SMTP id u17mr10009188wrt.154.1596349990277; Sat, 01 Aug 2020 23:33:10 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id h5sm20559384wrc.97.2020.08.01.23.33.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2020 23:33:09 -0700 (PDT) Message-Id: <08c8080b3196a1bd09bbf20ce705ec5ed5180c34.1596349986.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Elijah Newren via GitGitGadget" Date: Sun, 02 Aug 2020 06:33:05 +0000 Subject: [PATCH 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 | 7 +++---- merge-recursive.c | 3 +++ t/t6038-merge-text-auto.sh | 4 ++-- 4 files changed, 8 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..52f03ea715 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -72,7 +72,7 @@ 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 option_renormalize = -1; static int verbosity; static int allow_rerere_auto; static int abort_current_merge; @@ -621,8 +621,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 +719,8 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common, if (!strcmp(strategy, "subtree")) o.subtree_shift = ""; - o.renormalize = option_renormalize; + if (option_renormalize != -1) + 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 39413d5b48..8cff0d45a1 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 Sun Aug 2 06:33:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jean-No=C3=ABl_Avila_via_GitGitGadget?= X-Patchwork-Id: 11696271 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 EEC7813B1 for ; Sun, 2 Aug 2020 06:33:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D4C9D207FB for ; Sun, 2 Aug 2020 06:33:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LjThClTH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726767AbgHBGdO (ORCPT ); Sun, 2 Aug 2020 02:33:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726409AbgHBGdM (ORCPT ); Sun, 2 Aug 2020 02:33:12 -0400 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 5835AC061757 for ; Sat, 1 Aug 2020 23:33:12 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id b6so31325123wrs.11 for ; Sat, 01 Aug 2020 23:33:12 -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=LjThClTHRSK4IBFaHnjtKOmTOCP80GdJKbvg5e2gO4sodwjhRJ9Mj85hGPyWKUeGfo YolMaXAwcUPAxFrLD2xYUaOq921PuS5wBVdvnftzquOHmuFE2eQv4nyIilnxSgBMOnfl poskf+lVU8DERAWeTwmXhdnRrrmSM93yCCEdpuFKQhbTHve4vQzF+DTGARGjpCiLtqTp PEbx7jnCh2/GZDTz3eF/mRFpcli5gJRs0TxGziveBeZplMQ4l1NzhLWZnDXdmzMA/ZIj 9g2HENHlkuI1MHvMVcfGeytj3XzUJgCFZlmXNOFcKLzfVo4QyQdyAsQGU6ErqAQ7aQCX xpuA== 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=GQaAyUTSnCwwYuaNWXyejDNiMQM8GQfi39bvmxx1ZXsLr4Fv3zxkX2LaWxm3q5c6Kk z8VfH/abaDGuiMUUdxmZwcvt0JSjLaeuX8ctVen6JBcsq3rWlyhSJfCL5iMlMivkBCyf +Gkbv4/ANfZIfJHLC0iQzq1l3YM5oYGtirHa/PDobA1uxZs8UjBG484vnaTEkdGWWDql onWxjwQ2vG0/y3PW1M6cZL7YAj5w3iutYIz1RL48wyoeaC4eUTl2DVCqAmMTebPNpTxT aNFX7YmnTwIvgyAoOmPF7PY9J3jYrUvbdz05MRxcVH2JpMOan5cvFjCYoNYiIZGRBWzM vThA== X-Gm-Message-State: AOAM533zrR9QpIK5yOFEhSEUQ+J0zF0GwmM13/vxNYzfD5fRBinVQQeO l7SPBN3PKLT7yx2MYOVikGbrLdRf X-Google-Smtp-Source: ABdhPJzLl7cr8MYB2i9F+uF7x1PbrS/ed7zgCjXRKw0Ln3UshyLdoGnWqHQMuGz78++O+DmAVCgUKQ== X-Received: by 2002:adf:e712:: with SMTP id c18mr10437676wrm.92.1596349991010; Sat, 01 Aug 2020 23:33:11 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id z6sm19482367wrs.36.2020.08.01.23.33.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2020 23:33:10 -0700 (PDT) Message-Id: In-Reply-To: References: From: "Elijah Newren via GitGitGadget" Date: Sun, 02 Aug 2020 06:33:06 +0000 Subject: [PATCH 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);