From patchwork Wed Oct 23 12:03:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11206461 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 82533112C for ; Wed, 23 Oct 2019 12:03:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5FF092064A for ; Wed, 23 Oct 2019 12:03:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="COOGTVOd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405185AbfJWMDw (ORCPT ); Wed, 23 Oct 2019 08:03:52 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:47069 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731954AbfJWMDw (ORCPT ); Wed, 23 Oct 2019 08:03:52 -0400 Received: by mail-pl1-f196.google.com with SMTP id q21so1915727plr.13 for ; Wed, 23 Oct 2019 05:03:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=i4lYL+FdZdQg3HbyjMUx8yf919PYm5gHxe4ZudLcAm0=; b=COOGTVOdlvquHMTsdPXCKgPoIF9NtLi0EwmL9V00MBkTT2CRwXNy/cbccKhN36aTMv fwRczdgjoT9zw7/dpzARt29DSNL8FfJU5M4uIpor5uyoONS6n7EjltzVVG0SjC6Fg1xu 0bVbh/g//XMZqOwTJ7tfAeLe7KlQ1uRrSY451oEo0WwdR7pEEQy/ve7e5aDaRZgcblcL rl3gd6t8zef0aB/zeWUbppOZJRRI4JMKFEpzTPkuWxjigT6/Ng1E7bXukLLrGequ4gLz S5ReFt+gSckg9WBBC+DBhNlm6EgPMeNbWXVjxzu1GFRIQQa0WXenqeR0lUXHA/LMDWaC QnsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=i4lYL+FdZdQg3HbyjMUx8yf919PYm5gHxe4ZudLcAm0=; b=CCSzHdw5JusSi4nF1dAdZ6Fks9xXaHOC7C0woGJlI45rfWaKw4CIL0tftDOXfYIvSH gyDY5VXvl7hLJPgyJS82PO7xc2A4YCwk9aN3J1mDkR2g/+N3TljqZDez1kr1gS2w7o2C ONMgv/hhPPSQlE2LPXacwNs9s036bJPz7nPI8d4z3fAugmP36Iz1+G/sgjeqBLFo8vGS vUyJJbXrQgpL8b7xp1rZWXzQf5ZxN3WV7uu14147L76KaX2McexTHM67rlO1cwFsMHOP 4Tjch0TDz25UHIr2N79CVNQa870PDDbUWZxtcV9QWjnI2LxS7OcWPY0GEiXnRUy7bnZ2 OHmA== X-Gm-Message-State: APjAAAX+QZvX2vIc3w1xlaGlq2MJbhXEu7VdQrFBbj4NeDdR7zGhyw3Y k1LkbxPVw//zeZmxCaOVz6A605AO X-Google-Smtp-Source: APXvYqyP6DWdykHqg3y1YmVMgcQ3Y24Spb3m16O4ziKpptiWo5R9c3+IJiy6g2KqbQ2584EBe8eo/g== X-Received: by 2002:a17:902:b20a:: with SMTP id t10mr9191482plr.277.1571832230913; Wed, 23 Oct 2019 05:03:50 -0700 (PDT) Received: from generichostname ([2601:646:280:1b30:80db:d816:4d15:ae2a]) by smtp.gmail.com with ESMTPSA id l72sm27837826pjb.7.2019.10.23.05.03.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 05:03:49 -0700 (PDT) Date: Wed, 23 Oct 2019 05:03:48 -0700 From: Denton Liu To: Git Mailing List Cc: Junio C Hamano Subject: [PATCH 1/5] t4108: replace create_file with test_write_lines Message-ID: <84fe1614a3c807e3604549ec012535ce6bd17228.1571832176.git.liu.denton@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.2 (2019-09-21) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Since the locally defined create_file() duplicates the functionality of the test_write_lines() helper function, remove create_file() and replace all instances with test_write_lines(). While we're at it, move redirection operators to the end of the command which is the more conventional place to put it. Signed-off-by: Denton Liu --- t/t4108-apply-threeway.sh | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/t/t4108-apply-threeway.sh b/t/t4108-apply-threeway.sh index fa5d4efb89..b109ecbd9f 100755 --- a/t/t4108-apply-threeway.sh +++ b/t/t4108-apply-threeway.sh @@ -4,13 +4,6 @@ test_description='git apply --3way' . ./test-lib.sh -create_file () { - for i - do - echo "$i" - done -} - sanitize_conflicted_diff () { sed -e ' /^index /d @@ -20,7 +13,7 @@ sanitize_conflicted_diff () { test_expect_success setup ' test_tick && - create_file >one 1 2 3 4 5 6 7 && + test_write_lines 1 2 3 4 5 6 7 >one && cat one >two && git add one two && git commit -m initial && @@ -28,13 +21,13 @@ test_expect_success setup ' git branch side && test_tick && - create_file >one 1 two 3 4 5 six 7 && - create_file >two 1 two 3 4 5 6 7 && + test_write_lines 1 two 3 4 5 six 7 >one && + test_write_lines 1 two 3 4 5 6 7 >two && git commit -a -m master && git checkout side && - create_file >one 1 2 3 4 five 6 7 && - create_file >two 1 2 3 4 five 6 7 && + test_write_lines 1 2 3 4 five 6 7 >one && + test_write_lines 1 2 3 4 five 6 7 >two && git commit -a -m side && git checkout master @@ -87,7 +80,7 @@ test_expect_success 'apply with --3way with rerere enabled' ' test_must_fail git merge --no-commit side && # Manually resolve and record the resolution - create_file 1 two 3 4 five six 7 >one && + test_write_lines 1 two 3 4 five six 7 >one && git rerere && cat one >expect && @@ -104,14 +97,14 @@ test_expect_success 'apply -3 with add/add conflict setup' ' git reset --hard && git checkout -b adder && - create_file 1 2 3 4 5 6 7 >three && - create_file 1 2 3 4 5 6 7 >four && + test_write_lines 1 2 3 4 5 6 7 >three && + test_write_lines 1 2 3 4 5 6 7 >four && git add three four && git commit -m "add three and four" && git checkout -b another adder^ && - create_file 1 2 3 4 5 6 7 >three && - create_file 1 2 3 four 5 6 7 >four && + test_write_lines 1 2 3 4 5 6 7 >three && + test_write_lines 1 2 3 four 5 6 7 >four && git add three four && git commit -m "add three and four" && From patchwork Wed Oct 23 12:03:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11206463 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 0833C112C for ; Wed, 23 Oct 2019 12:03:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DA8BF2064A for ; Wed, 23 Oct 2019 12:03:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rD3BErUV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405188AbfJWMDz (ORCPT ); Wed, 23 Oct 2019 08:03:55 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:33367 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731954AbfJWMDy (ORCPT ); Wed, 23 Oct 2019 08:03:54 -0400 Received: by mail-pf1-f194.google.com with SMTP id c184so3292534pfb.0 for ; Wed, 23 Oct 2019 05:03:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=nPWh7QlMWSMmxFHZ7OJjCopz5RbVH9kV7e0OwLhMHbM=; b=rD3BErUVuvGZZCY25nRcliPbWd4lDCaHXbNGT51Z7Ip4GRdaEBa3M6v8Q9LW4AVPE1 h9Jx0tAI5+hQvg5Ul5YPAlopPtMzqtz1QzXgmPUFyu6eIq16+B6VMuwZh/DQ2HdNH7XH UT9ZU4K/yVGeoEb3hGZDC5dm8y5pVO8IufwRTjeYhd5z6dJwG3yxJ1avrCb0ePpM2ZcX tnjc2lOxKA1We9yPH7YaznG85l3tcnnUTe68D1QKDYCC4zzf3stbpkPJoqx2qBPLurRr SuCZ8ynTc55EuvakaD6SjPLBxLbkfiBNtak/IfiBhmk1bY+wy+12wiXCLGsyeI4BONmG iNHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=nPWh7QlMWSMmxFHZ7OJjCopz5RbVH9kV7e0OwLhMHbM=; b=JqeklbsOWvItxCOljFcHnm/1atyyJ6bZ5KAl0Ig0dmigz273X8jksDbShCa0jii1uX MX3aAJnGs046RGTr7l+bm7VfmMSE7zy1qiVIlnZzcHXAVHdtS9bxabJwFWW94dwlijyX fG1i3IfTis4/oxqHxJm8YGGUCoCBgOV5SVWz4BbdW7KzVaC1rU55VrHNmTG3GikNOz/7 ZF1BjZcNpXKDmzeheU40eqVl1Y6rJ2HivzcWh9vR0V97yTAwg7xJlzQa3zDTHe1gxFzB bcdDOQBxJFoMS6MDbVYRpyJA5h8EnJ/htPojsu7g7QQU2jrvQ3FEGFejmPmhkCllID3u pgOg== X-Gm-Message-State: APjAAAVTlNerEu9MVn5SlEZ1fCsL1TyhaFq/68weYi2anQmd7IJ7uEWp HCbG4TEGsJORTgDIhHGmnp3P7UQV X-Google-Smtp-Source: APXvYqw+ZqFBah28NcT5eOhLPEpxIZI+qcc4hIjbxwSlKpdL5dhSU5nd5p7eJNO5qf5lpIms6Vcyiw== X-Received: by 2002:a17:90a:cf97:: with SMTP id i23mr11182866pju.77.1571832233389; Wed, 23 Oct 2019 05:03:53 -0700 (PDT) Received: from generichostname ([2601:646:280:1b30:80db:d816:4d15:ae2a]) by smtp.gmail.com with ESMTPSA id j24sm22770368pff.71.2019.10.23.05.03.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 05:03:52 -0700 (PDT) Date: Wed, 23 Oct 2019 05:03:51 -0700 From: Denton Liu To: Git Mailing List Cc: Junio C Hamano Subject: [PATCH 2/5] t4108: remove git command upstream of pipe Message-ID: <9d915748c1953cc2683fa3189c3c98b1e9a1e299.1571832176.git.liu.denton@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.2 (2019-09-21) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Before, the output of `git diff HEAD` would always be piped to sanitize_conflicted_diff(). However, since the Git command was upstream of the pipe, in case the Git command fails, the return code would be lost. Rewrite into separate statements so that the return code is no longer lost. Since only the command `git diff HEAD` was being piped to sanitize_conflicted_diff(), move the command into the function and rename it to print_sanitized_diff(). Signed-off-by: Denton Liu --- t/t4108-apply-threeway.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/t/t4108-apply-threeway.sh b/t/t4108-apply-threeway.sh index b109ecbd9f..49739ce8b4 100755 --- a/t/t4108-apply-threeway.sh +++ b/t/t4108-apply-threeway.sh @@ -4,11 +4,12 @@ test_description='git apply --3way' . ./test-lib.sh -sanitize_conflicted_diff () { +print_sanitized_diff () { + git diff HEAD >diff.raw && sed -e ' /^index /d s/^\(+[<>][<>][<>][<>]*\) .*/\1/ - ' + ' diff.raw } test_expect_success setup ' @@ -54,14 +55,14 @@ test_expect_success 'apply with --3way' ' git checkout master^0 && test_must_fail git merge --no-commit side && git ls-files -s >expect.ls && - git diff HEAD | sanitize_conflicted_diff >expect.diff && + print_sanitized_diff >expect.diff && # should fail to apply git reset --hard && git checkout master^0 && test_must_fail git apply --index --3way P.diff && git ls-files -s >actual.ls && - git diff HEAD | sanitize_conflicted_diff >actual.diff && + print_sanitized_diff >actual.diff && # The result should resemble the corresponding merge test_cmp expect.ls actual.ls && @@ -114,7 +115,7 @@ test_expect_success 'apply -3 with add/add conflict setup' ' git checkout adder^0 && test_must_fail git merge --no-commit another && git ls-files -s >expect.ls && - git diff HEAD | sanitize_conflicted_diff >expect.diff + print_sanitized_diff >expect.diff ' test_expect_success 'apply -3 with add/add conflict' ' @@ -124,7 +125,7 @@ test_expect_success 'apply -3 with add/add conflict' ' test_must_fail git apply --index --3way P.diff && # ... and leave conflicts in the index and in the working tree git ls-files -s >actual.ls && - git diff HEAD | sanitize_conflicted_diff >actual.diff && + print_sanitized_diff >actual.diff && # The result should resemble the corresponding merge test_cmp expect.ls actual.ls && From patchwork Wed Oct 23 12:03:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11206465 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 C4E0D112C for ; Wed, 23 Oct 2019 12:04:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A33A02064A for ; Wed, 23 Oct 2019 12:04:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="K6r/zdXN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405192AbfJWMEA (ORCPT ); Wed, 23 Oct 2019 08:04:00 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:45142 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405189AbfJWMEA (ORCPT ); Wed, 23 Oct 2019 08:04:00 -0400 Received: by mail-pf1-f193.google.com with SMTP id b4so3885126pfr.12 for ; Wed, 23 Oct 2019 05:03:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=9IX9Tt1pf92q5Us3Mw15Vyjbkm/rfoIxyWi4z+Ci0HM=; b=K6r/zdXNW+Pzi7A51Q1w2qYZ3el5h5C8JmxAdSJG2gCqa1ipNkOAQ9SdBcWeklN/20 ZIet36WExWnbYZN0wZi04MiDA9MimLrs+De8eZlIZhY99GbVqsUCaKVIrhCHpNpeRQA3 nR8anH7qOBtugJSsrtsFO9pbN2YshSGPnC3sAjcyjiBs3LZ8aC+xgMmHWi3exGdUCj66 7lhUERh0JaR/DH71QyzoN+bXgemz8Z3RlcGRq7Cvc7sysBm+85A/cEq5Y94BQAgVzRYs EKsFdytrV3YPCDzD/MXSukx4dk3I4uL96siMghJbNMwdlqsluVHfX1lzfh/Cn2EtYhld jdKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=9IX9Tt1pf92q5Us3Mw15Vyjbkm/rfoIxyWi4z+Ci0HM=; b=Tk7o/AZ36wqYOIPkkQKwMMdcoScMuW+j9RXKBnKUEUOCNn2vl1Jh66Qi3yhzHDx3hp sahXkk18Aa2j3CKegtNrRnzKE+9/IPZyYtX+94jkBBaXL+qR0K+Uxm+0gJuNmT/0vBPu iUOyxOS2psdjTrVJAREeleRvPU5nuz5jjEK+Z/lLzKKtfXIfxgMxb7m/Lnfc05z9oGHg R6QYlONgyKznkRwNxpLv3eKfk4bQHXcXUfIZp1d5wcGjxg7fuqXMveqKCC0+iEtznQiv ke7nfMTnO685o0mrZcjmEZgNvA1GPYvY1wNcnUdLOBZUcFc1v8Of+OUcBiMwO25TSwxn 5VaA== X-Gm-Message-State: APjAAAWhDEXeQ5ZTSLM8Ax/ky0Seks/V13pYTQqIehZPgemqa3gt5IEy D+3Te5NMPdMoyUmYwNiSYU0Hs/kp X-Google-Smtp-Source: APXvYqzqHdVFK9yB0bBl3Qa7bWn4u5Iyuokz1KG0kV3wOCe2TshQQmiev3+0hKGMuZ1occsGjaU9Ow== X-Received: by 2002:a17:90a:d143:: with SMTP id t3mr10896742pjw.105.1571832236167; Wed, 23 Oct 2019 05:03:56 -0700 (PDT) Received: from generichostname ([2601:646:280:1b30:80db:d816:4d15:ae2a]) by smtp.gmail.com with ESMTPSA id x10sm19945594pgl.53.2019.10.23.05.03.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 05:03:55 -0700 (PDT) Date: Wed, 23 Oct 2019 05:03:53 -0700 From: Denton Liu To: Git Mailing List Cc: Junio C Hamano Subject: [PATCH 3/5] t4108: use `test_config` instead of `git config` Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.2 (2019-09-21) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Since `git config` leaves the configurations set even after the test case completes, use `test_config` instead so that the configurations are reset once the test case finishes. Signed-off-by: Denton Liu --- t/t4108-apply-threeway.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/t4108-apply-threeway.sh b/t/t4108-apply-threeway.sh index 49739ce8b4..3615256492 100755 --- a/t/t4108-apply-threeway.sh +++ b/t/t4108-apply-threeway.sh @@ -70,7 +70,7 @@ test_expect_success 'apply with --3way' ' ' test_expect_success 'apply with --3way with rerere enabled' ' - git config rerere.enabled true && + test_config rerere.enabled true && # Merging side should be similar to applying this patch git diff ...side >P.diff && From patchwork Wed Oct 23 12:03:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11206467 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 E5062112C for ; Wed, 23 Oct 2019 12:04:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C2CA62064A for ; Wed, 23 Oct 2019 12:04:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="s3/Nid89" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405195AbfJWMEB (ORCPT ); Wed, 23 Oct 2019 08:04:01 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:44698 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405189AbfJWMEB (ORCPT ); Wed, 23 Oct 2019 08:04:01 -0400 Received: by mail-pl1-f194.google.com with SMTP id q15so9982760pll.11 for ; Wed, 23 Oct 2019 05:03:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=VxuKgLWTlou5NIbIdnFQfMyBFabePKf2qEq0cblINUQ=; b=s3/Nid89iEL1yHxkX1A2S/yG3L5spyoDQBplfynDGvfr6viiE760Nl2Xc/I1sIVD3F BaMsXP/5pySBHYanvJtFORDwUW+oB2kugH9pgvnaJsd3c6x+Er21cRhcUYR+mG6Iliw2 3B3Dd3aHi5oJ7SKoD4Bq2Q4Q/QooWs4bVIz0j5yekkfsOVsVOfUQ79RDUC3CgCy8KZR9 TbS6GTaLHvpvfcYnTXmTzbwz9u6a+04/rimglbwuvT+QUI44KXd+CspbPQRbYmthiV8E +5xYYJcPKdqEiUNG2/M1SqW7O6VL/ZEJi6+1q/IYOgEt5/Sa0yA1gIpRl5HHVEOH4mzz AR3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=VxuKgLWTlou5NIbIdnFQfMyBFabePKf2qEq0cblINUQ=; b=tp1RS5U3RWiOfbw/zmpkEhoG70ICkIU8AfvNKI+AsIx915W6Mzjxx6AJEmBIF7Oq/n EM1Y5Gr7iSIQqvzWcdiX7/N5U//uUwnFh10J7mLZUeuSdOVq/N6kod/fCz6aUMX1caqW EF9767s4Ovx04PjIooKEwBngCXkqodAKpzBXBEhoiAooCUXcYtdsjRQsTfdpbFppdTVC HBwpkmcw/KKpsdOpJaLAcVvfmWCcasSccleo+9oMUKe54sq/2e4BDDBU6hrv3CnLBUkJ GaZawDuhnQdHB4p2q8phJpqRRC/WIaRVvEQP9oA57WYPVVw5yoTrSdoWR5SRDho8qTMh h09Q== X-Gm-Message-State: APjAAAWA0pNY+fE3RZ8ypgMryvZZO6uWfUaSR7ohO6PSNJhT+tNe/4j2 pyfgdqLH05J814baf5J8GFNgzjxj X-Google-Smtp-Source: APXvYqxGFHlrgEp1RaYGF4r543DO0XSZhGO880Z1X0QYHTWI8Agi7xyKH7MDj8rzD9BHB+vlv4ouaA== X-Received: by 2002:a17:902:b485:: with SMTP id y5mr9100005plr.292.1571832238788; Wed, 23 Oct 2019 05:03:58 -0700 (PDT) Received: from generichostname ([2601:646:280:1b30:80db:d816:4d15:ae2a]) by smtp.gmail.com with ESMTPSA id 27sm8801328pgx.23.2019.10.23.05.03.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 05:03:57 -0700 (PDT) Date: Wed, 23 Oct 2019 05:03:56 -0700 From: Denton Liu To: Git Mailing List Cc: Junio C Hamano Subject: [PATCH 4/5] t4108: demonstrate bug in apply Message-ID: <5feddf15978e77b19d8b3e2e5761e394e0bda3e7.1571832177.git.liu.denton@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.2 (2019-09-21) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Currently, apply does not respect the merge.conflictStyle setting. Demonstrate this by making the 'apply with --3way' test case generic and extending it to show that the configuration of merge.conflictStyle = diff3 causes a breakage. Change print_sanitized_diff() to also sanitize `|||||||` conflict markers. Signed-off-by: Denton Liu --- t/t4108-apply-threeway.sh | 58 ++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/t/t4108-apply-threeway.sh b/t/t4108-apply-threeway.sh index 3615256492..84347fc178 100755 --- a/t/t4108-apply-threeway.sh +++ b/t/t4108-apply-threeway.sh @@ -8,7 +8,7 @@ print_sanitized_diff () { git diff HEAD >diff.raw && sed -e ' /^index /d - s/^\(+[<>][<>][<>][<>]*\) .*/\1/ + s/^\(+[<>|][<>|][<>|][<>|]*\) .*/\1/ ' diff.raw } @@ -46,28 +46,42 @@ test_expect_success 'apply without --3way' ' git diff-index --exit-code --cached HEAD ' -test_expect_success 'apply with --3way' ' - # Merging side should be similar to applying this patch - git diff ...side >P.diff && - - # The corresponding conflicted merge - git reset --hard && - git checkout master^0 && - test_must_fail git merge --no-commit side && - git ls-files -s >expect.ls && - print_sanitized_diff >expect.diff && - - # should fail to apply - git reset --hard && - git checkout master^0 && - test_must_fail git apply --index --3way P.diff && - git ls-files -s >actual.ls && - print_sanitized_diff >actual.diff && +test_apply_with_3way () { + status="$1" && + shift && + description="$1" && + shift && + preamble="$1" && + shift && + + test_expect_$status "apply with --3way ($description)" " + $preamble && + + # Merging side should be similar to applying this patch + git diff ...side >P.diff && + + # The corresponding conflicted merge + git reset --hard && + git checkout master^0 && + test_must_fail git merge --no-commit side && + git ls-files -s >expect.ls && + print_sanitized_diff >expect.diff && + + # should fail to apply + git reset --hard && + git checkout master^0 && + test_must_fail git apply --index --3way P.diff && + git ls-files -s >actual.ls && + print_sanitized_diff >actual.diff && + + # The result should resemble the corresponding merge + test_cmp expect.ls actual.ls && + test_cmp expect.diff actual.diff + " +} - # The result should resemble the corresponding merge - test_cmp expect.ls actual.ls && - test_cmp expect.diff actual.diff -' +test_apply_with_3way success default true +test_apply_with_3way failure 'merge.conflictStyle = diff3' 'test_config merge.conflictStyle diff3' test_expect_success 'apply with --3way with rerere enabled' ' test_config rerere.enabled true && From patchwork Wed Oct 23 12:03:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11206469 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 03D6B1747 for ; Wed, 23 Oct 2019 12:04:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D65FF2064A for ; Wed, 23 Oct 2019 12:04:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="oRWrXuvv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405198AbfJWMEC (ORCPT ); Wed, 23 Oct 2019 08:04:02 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:42618 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405196AbfJWMEC (ORCPT ); Wed, 23 Oct 2019 08:04:02 -0400 Received: by mail-pf1-f193.google.com with SMTP id 21so1551032pfj.9 for ; Wed, 23 Oct 2019 05:04:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=0XV9eRpYAap7odwETBIOK/c0KvQF4hNy+9IBmKi/5S8=; b=oRWrXuvvkwqC1cXe//D1NqYJWdbZHm3zqYuIgeNzV1pOQJJhReGGtKX/+AIpI26IoY IP4/IfTX0rb5oF4WMWg692mhhgWeE+wg6Zv2is+Hq/ALSN//zAeMfJPXTt28vyoF4BU+ 9dNxkftnrPKsRO0lciQWlJK+d7rxm7a5ij8JJmqcnTviJqvqpc0DilmF3pmvUUomMWiZ TUnh6RMxXf5vkwW4EgTfKdavqmcBZQrU9kco3QAbAKZYBNKatGU0K7Wygt2n5U6YlJJW U2GsATomQyWuWmeUhGthinPPvD04yqiSxmBgSQQiUBjZAtlxGVBXOWAvx3dFiHwUxYzY JnJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=0XV9eRpYAap7odwETBIOK/c0KvQF4hNy+9IBmKi/5S8=; b=g4iCFgXawG3aIokTT/FvQ3SxPvB0+dlb3BmfEkxj+wS8IQh2PZajUBbEBM3OiR9x67 snNkltifNZpFYOanN/rSMj50zu/mmKesNAVUI8xfIrR6kqqRY61V5C5Ewya1g7FT+R2t OlS8sj6Big2jO+ki0IK7aKtwFzwIaKtVv3VCdpY9woSDRtCENZFoYbsrBefQj0NgYrE1 2quPubJa9PQpyOAAr0bZNUeeXwpVIp1FEU3xkqTPwkbbdRTptKp99z5J3lLchd9j1XMi 47KeIP1eEGHLMeS3RWfrvuXw8AkDPbm//H/qXNeP1DDYskspN2a9SQS63wPMz+m/GlL8 N2RQ== X-Gm-Message-State: APjAAAWKREzKYL1KH5Dn7dtCcWoeN6dow4EDQXcR9i+cWdGNsEPxkvEt zYv33Df1kH6pRYO0K2dPwPq1D4Pu X-Google-Smtp-Source: APXvYqwUpMSfXwFuwhz8PFXkn5PlMwrFgy7xwx7hI9/IjHJ60XljJHe8c2XFM81cId8XJ1GQ2FbXHg== X-Received: by 2002:a63:3d41:: with SMTP id k62mr9181877pga.129.1571832241311; Wed, 23 Oct 2019 05:04:01 -0700 (PDT) Received: from generichostname ([2601:646:280:1b30:80db:d816:4d15:ae2a]) by smtp.gmail.com with ESMTPSA id b14sm24189238pfi.95.2019.10.23.05.04.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 05:04:00 -0700 (PDT) Date: Wed, 23 Oct 2019 05:03:58 -0700 From: Denton Liu To: Git Mailing List Cc: Junio C Hamano Subject: [PATCH 5/5] apply: respect merge.conflictStyle in --3way Message-ID: <56c31310db9358673af9905910e3332893d798de.1571832177.git.liu.denton@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.2 (2019-09-21) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Before, when doing a 3-way merge, the merge.conflictStyle option was not respected and the "merge" style was always used, even if "diff3" was specified. Call git_xmerge_config() at the end of git_apply_config() so that the merge.conflictStyle config is read. Signed-off-by: Denton Liu --- apply.c | 2 +- t/t4108-apply-threeway.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apply.c b/apply.c index f8a046a6a5..b9291f5f7b 100644 --- a/apply.c +++ b/apply.c @@ -32,7 +32,7 @@ static void git_apply_config(void) { git_config_get_string_const("apply.whitespace", &apply_default_whitespace); git_config_get_string_const("apply.ignorewhitespace", &apply_default_ignorewhitespace); - git_config(git_default_config, NULL); + git_config(git_xmerge_config, NULL); } static int parse_whitespace_option(struct apply_state *state, const char *option) diff --git a/t/t4108-apply-threeway.sh b/t/t4108-apply-threeway.sh index 84347fc178..0e4eeac083 100755 --- a/t/t4108-apply-threeway.sh +++ b/t/t4108-apply-threeway.sh @@ -81,7 +81,7 @@ test_apply_with_3way () { } test_apply_with_3way success default true -test_apply_with_3way failure 'merge.conflictStyle = diff3' 'test_config merge.conflictStyle diff3' +test_apply_with_3way success 'merge.conflictStyle = diff3' 'test_config merge.conflictStyle diff3' test_expect_success 'apply with --3way with rerere enabled' ' test_config rerere.enabled true &&