From patchwork Sun Aug 28 05:17:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sunshine X-Patchwork-Id: 12957168 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 489A6ECAAD2 for ; Sun, 28 Aug 2022 05:18:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232143AbiH1FSH (ORCPT ); Sun, 28 Aug 2022 01:18:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231981AbiH1FSF (ORCPT ); Sun, 28 Aug 2022 01:18:05 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 550C831ED4 for ; Sat, 27 Aug 2022 22:18:04 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id k9so6368463wri.0 for ; Sat, 27 Aug 2022 22:18:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc; bh=7ho9sgT861keFsrVjVONjG5/0bkGcfd7okraMt66mx4=; b=MBFwheCcI6dHOXQEN8xisVcGlG+77RU7YUHIp6qQRdwrBb7OAo7juYcoWQ8s7lZGhC F9l+03OePSuup3/np+9llM5w1g2tu7HSwFFNWgiEUlDmULKTg8EefZGyociUU6ZGUD3y /H0BuQPqc2RaTWY/AjCgXCOSCMjdmWMIUnBH2E++dZXoXc00ewzvnrooQx6B30k0oxVY DpsCZqrOT/UV3O+bvrwQ9lbXXmaIncfBJjyfoGZdRL3OsmFg9U2Tp7x1NM8N/Zr7VhkX wu+qMZpmQeYzAGJSg0qA+EgXDxQ2VgUywCoT4/QEM9wqYjun40G6SfrXetJ4nCJcjepW QsOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc; bh=7ho9sgT861keFsrVjVONjG5/0bkGcfd7okraMt66mx4=; b=L9++oZeMwdD4uSQTBxkKDJyM1im3GYncWN8tl6OaGF8VhnaqC9atKc27tjObg0W0pU 6a9/VPjDsEURQ01yQAwHLbJKwVf0ANbJU71OJz6KU0o/sLc8isJJQByepGmUiQ9yv4Yn n7JwqpByaXav/ZiEQ4WeaGz+vRp9W/nV/MJTPrEJGBmGCXW2hvX65JSw+iWrvQi6kJAt /y2SnWVrPHII7ExnTkoO7+Dnf6Cqf6Q8iSaAp5Z0BrFSiabKmXTnhq1AAfsCagYECtyG NYCxl2m8hEgGTKU9S+JNBk3PJjjHrSPTkxQ4VqsnhqxGA5wiT6FvRatC9JqfrKxPIBSK pM+g== X-Gm-Message-State: ACgBeo0pgKPji8+gkRzkNEz1fL3k/SCfwXgIHXLmzrgRVFh1EFI6fLAP oAiLLdCd0ZVnA12gNe0JbdPaF2uxqcc= X-Google-Smtp-Source: AA6agR5AuzmGJj9MAmGwkdwha7uSJU77fSe4v9Bpy0Zsrb7vzGRRSgr3+5p11rStMdiBP/c5izgDRA== X-Received: by 2002:adf:d1ec:0:b0:226:d538:40b0 with SMTP id g12-20020adfd1ec000000b00226d53840b0mr1377165wrd.693.1661663882435; Sat, 27 Aug 2022 22:18:02 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id p6-20020a1c5446000000b003a83fda1dc5sm2278223wmi.44.2022.08.27.22.18.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Aug 2022 22:18:01 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Sun, 28 Aug 2022 05:17:57 +0000 Subject: [PATCH 1/3] t4301: account for behavior differences between sed implementations Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Elijah Newren , Eric Sunshine , Eric Sunshine Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Eric Sunshine From: Eric Sunshine It is a common pattern in this script to write the result of `merge-tree -z` (NUL-termination mode) to an "actual" file and then manually append a newline to that file so that it can be diff'd easily with a hand-crafted "expect" file which itself ends with a newline since it has been created by standard Unix tools which terminate lines by default. For instance: git merge-tree --write-tree -z ... >out && printf "\\n" >>out anonymize_hash out >actual && q_to_nul <<-EOF >expect && ... EOF test_cmp expect actual However, one test gets this backward: git merge-tree --write-tree -z ... >out && anonymize_hash out >actual && printf "\\n" >>actual which means that, unlike all other cases, when anonymize_hash() is called, the file being anonymized does not end with a newline. As a result, this test fails on some platforms. anonymize_hash() is implemented like this: anonymize_hash() { sed -e "s/[0-9a-f]\{40,\}/HASH/g" "$@" } The problem arises due to differences in behavior of various `sed` implementations when fed an incomplete line (lacking a newline). Although most modern `sed` implementations output such a line unmolested (i.e. without a newline), some older `sed` implementations forcibly add a newline to the incomplete line (giving the output an extra unexpected newline), while other very old implementations simply swallow an incomplete line and don't emit it at all (making the output shorter than expected). Fix this test by manually adding the newline before passing it through `sed`, thus ensuring identical behavior with all `sed` implementation, and bringing the test in line with other tests in this script. Signed-off-by: Eric Sunshine --- t/t4301-merge-tree-write-tree.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/t4301-merge-tree-write-tree.sh b/t/t4301-merge-tree-write-tree.sh index c5fd56df28f..d44c7767f30 100755 --- a/t/t4301-merge-tree-write-tree.sh +++ b/t/t4301-merge-tree-write-tree.sh @@ -760,8 +760,8 @@ test_expect_success 'NUL terminated conflicted file "lines"' ' git commit -m "Renamed numbers" && test_expect_code 1 git merge-tree --write-tree -z tweak1 side2 >out && + printf "\\n" >>out && anonymize_hash out >actual && - printf "\\n" >>actual && # Expected results: # "greeting" should merge with conflicts From patchwork Sun Aug 28 05:17:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sunshine X-Patchwork-Id: 12957169 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 28A2AC0502E for ; Sun, 28 Aug 2022 05:18:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231981AbiH1FSJ (ORCPT ); Sun, 28 Aug 2022 01:18:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232065AbiH1FSG (ORCPT ); Sun, 28 Aug 2022 01:18:06 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 516CE31ED3 for ; Sat, 27 Aug 2022 22:18:05 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id z16so6323934wrh.10 for ; Sat, 27 Aug 2022 22:18:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc; bh=gwTlIKyOe2QThf0Yr8VcfrqGBitnhSbLhbGyZxD5R1Q=; b=SwbveS+InO2WJppNhZ3d4nBezjOUy5hUDytivyZ4s8Y8MHZ0fY9F67Jo42PQeqb2Px 1RpZaMnWO/+z6afpZk45pJOgBxU/U5ap0AmKdcofEc69YT5FD7DQk4nUG7tguAyMMG4/ Bd02vO9wQic6pKBNhqa1loDV/IeUpL83Msrm/vvQhjz9lgHeoZhKOwUjyQ/lqunu2cMb j/WP0J/H/kULfi2Uq6506WkQt7/HPl8nVbiGZ/jCAukPHM/iVbDV8CiJcXBI6Rpmv+ca pQadWMIU5Nj2zwzX++VGDHfV5nxBZD55Wx8RhTneijhYC/bZmCY+f6sqTM6IHpP5H7MP eNdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc; bh=gwTlIKyOe2QThf0Yr8VcfrqGBitnhSbLhbGyZxD5R1Q=; b=cBs4TpZckhCRXLdsZVkkL+kqU6BEsLaPFpaHoqusvU2YAlQeA89ebjLN0LlvBJzxY6 aATrLvXq60etjakQSoRG4AUL3VkL8zs68XLsRFQItf5CTWICe5QGiF9M7cY9RAImb4LB Uhzy7tPx7C8TmEC8Q8OHRMbVmkg5GDQaESmIwz9PBTDRy/VYBCk5B/oD41WTr3P3oM8C Zx6HCL1enIRyeYDHUkHXvQdkzdwg5h+kbl5Mq/Wl3DvRPYfIh1uDkAcI/E0UIryIIHjF pHr5pUMbVv8pxSib6dJc07/9pqe/X3eQeTKgPPeL5euTQwl3M39GXXuI+adEDgG5Zs13 J+Bw== X-Gm-Message-State: ACgBeo3QL+YIsNiLqjUfv4M6WUI61guckBylRkjZN/UoW8Gpb7QxhlzN DDzVV/49CBNPOgDHmMgCQq7hd74hh0A= X-Google-Smtp-Source: AA6agR7cW0kKP4rrTNJ9rjzdfmCkXtVXvI47dBl4FZuDmdRTIvdt9nImJcfmI48ndAmmkgi75ysbOQ== X-Received: by 2002:a05:6000:1c0c:b0:225:569c:dd2c with SMTP id ba12-20020a0560001c0c00b00225569cdd2cmr3191347wrb.628.1661663883661; Sat, 27 Aug 2022 22:18:03 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id az27-20020a05600c601b00b003a5c244fc13sm4956450wmb.2.2022.08.27.22.18.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Aug 2022 22:18:02 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Sun, 28 Aug 2022 05:17:58 +0000 Subject: [PATCH 2/3] t4031: fix broken &&-chains and add missing loop termination Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Elijah Newren , Eric Sunshine , Eric Sunshine Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Eric Sunshine From: Eric Sunshine Fix &&-chain breaks in a couple tests which went unnoticed due to blind spots in the &&-chain linters. In particular, the "magic exit code 117" &&-chain checker built into test-lib.sh only recognizes broken &&-chains at the top-level; it does not work within `{...}` groups, `(...)` subshells, `$(...)` substitutions, or within bodies of compound statements, such as `if`, `for`, `while`, `case`, etc. Furthermore, `chainlint.sed`, which detects broken &&-chains only in `(...)` subshells, missed these cases (which are in subshells) because it (surprisingly) neglects to check for intact &&-chain on single-line `for` loops. While at it, explicitly signal failure of commands within the `for` loops (which might arise due to the filesystem being full or "inode" exhaustion). This is important since failures within `for` and `while` loops can go unnoticed if not detected and signaled manually since the loop itself does not abort when a contained command fails, nor will a failure necessarily be detected when the loop finishes since the loop returns the exit code of the last command it ran on the final iteration, which may not be the command which failed. Signed-off-by: Eric Sunshine --- t/t4301-merge-tree-write-tree.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/t4301-merge-tree-write-tree.sh b/t/t4301-merge-tree-write-tree.sh index d44c7767f30..82a104bcbc9 100755 --- a/t/t4301-merge-tree-write-tree.sh +++ b/t/t4301-merge-tree-write-tree.sh @@ -150,7 +150,7 @@ test_expect_success 'directory rename + content conflict' ' cd dir-rename-and-content && test_write_lines 1 2 3 4 5 >foo && mkdir olddir && - for i in a b c; do echo $i >olddir/$i; done + for i in a b c; do echo $i >olddir/$i || exit 1; done && git add foo olddir && git commit -m "original" && @@ -662,7 +662,7 @@ test_expect_success 'directory rename + rename/delete + modify/delete + director cd 4-stacked-conflict && test_write_lines 1 2 3 4 5 >foo && mkdir olddir && - for i in a b c; do echo $i >olddir/$i; done + for i in a b c; do echo $i >olddir/$i || exit 1; done && git add foo olddir && git commit -m "original" && From patchwork Sun Aug 28 05:17:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sunshine X-Patchwork-Id: 12957170 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 94753ECAAD2 for ; Sun, 28 Aug 2022 05:18:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232197AbiH1FSM (ORCPT ); Sun, 28 Aug 2022 01:18:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232167AbiH1FSH (ORCPT ); Sun, 28 Aug 2022 01:18:07 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FD5231ED4 for ; Sat, 27 Aug 2022 22:18:06 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id m17-20020a7bce11000000b003a5bedec07bso6494284wmc.0 for ; Sat, 27 Aug 2022 22:18:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc; bh=ao/HoFwMErGAKFpH1ar8+UrSeOZ4X3nC41g9X/28iUE=; b=j2N3X6uTqZJrsN9fOgKEw1Yp3paP0OJY3S+y+sLTSMYkWJLHo1NqxMpoMbIiI1jMUy bCuvw4Sp7Y/Ah5790VfzXkvOPEuU82vuNpOiLNbwDL1Bd9HqYpHsK6r3p/orVu0Ehf2h I6p3Mnuv8I2uUkTF7c8E6wYD9OXtEQr2C4WXMNCa0cQe5H5kTW+9bdFzKJhrbxnUHx2+ kpJaqzwgitAZKSdhBTm9kHxJEpukH723or1YjOq1fPNPi4Dds4QrF0ayIUKSNVtXWxDO 7N/7ATP3Mql6VU2vXKAlkQ5L/KNyDzpLeghwIEkphW1Bgcp/0ip1mNU6o+WshIH5AykD QOaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc; bh=ao/HoFwMErGAKFpH1ar8+UrSeOZ4X3nC41g9X/28iUE=; b=jY+/oI7q/jpI792YwBVGtHGVYDl8G9ZrV+eE4bgLnL7NecF3pAHZWBFVmXGQy/adVK B0jk7cLoLRaQ9F47dhQyFCVRu+fSUHZjxbVTt5yzs+D3PJ8bpuxrY0MofQ6f5OBBquvd 7UhjySEFiY3DlmBTGNjBKW6ew/1eN4L0IxuSEkjf/fSbUvB+oy/WqJsqIVo9N2bmf0k0 C7dnZa5DSuKN0sH56R9BQgoWallT/sxh5NEp/REHLZln+yxeQu1mYysZvzjQJC0kuFrC WGWlQeW6NAP6b1Se5u+HiTn4t/a4bKak/78TwkOvikdoZeyZmSFSyBEGVBgB0Q651JSU RaeA== X-Gm-Message-State: ACgBeo1z6jx0DdGHY/VTsYHUdC9f3hyR+R6u2bijM1Lv43OQtVV3lTvf tkDab3HM4JV6wYSws159tNGtBaYpOO4= X-Google-Smtp-Source: AA6agR7F3Z7FmO742unV/MPdmN5e2wp9hn1f2L9y/H1E8XSsfErq5UdLcLpqO4Oea18wDnwnASE5PA== X-Received: by 2002:a05:600c:4f10:b0:3a5:f8c8:a5b5 with SMTP id l16-20020a05600c4f1000b003a5f8c8a5b5mr3687112wmq.34.1661663884961; Sat, 27 Aug 2022 22:18:04 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id ay15-20020a5d6f0f000000b002207a5d8db3sm3764095wrb.73.2022.08.27.22.18.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Aug 2022 22:18:04 -0700 (PDT) Message-Id: <32cb3a23c31ecc2700d14d80b62fcccf40da81a6.1661663880.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sun, 28 Aug 2022 05:17:59 +0000 Subject: [PATCH 3/3] t4301: emit blank line in more idiomatic fashion Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Elijah Newren , Eric Sunshine , Eric Sunshine Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Eric Sunshine From: Eric Sunshine The unusual use of: printf "\\n" >>file && may give readers pause, making them wonder why this form was chosen over the more typical: printf "\n" >>file && However, even that may give pause since it is a somewhat unusual and long-winded way of saying: echo >>file && Therefore, replace `printf` with the more idiomatic `echo`, with the hope of eliminating a possible stumbling block for those reading the code. Signed-off-by: Eric Sunshine --- t/t4301-merge-tree-write-tree.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/t/t4301-merge-tree-write-tree.sh b/t/t4301-merge-tree-write-tree.sh index 82a104bcbc9..28ca5c38bb5 100755 --- a/t/t4301-merge-tree-write-tree.sh +++ b/t/t4301-merge-tree-write-tree.sh @@ -176,7 +176,7 @@ test_expect_success 'directory rename + content conflict' ' test_expect_code 1 \ git merge-tree -z A^0 B^0 >out && - printf "\\n" >>out && + echo >>out && anonymize_hash out >actual && q_to_tab <<-\EOF | lf_to_nul >expect && HASH @@ -230,7 +230,7 @@ test_expect_success 'rename/delete handling' ' test_expect_code 1 \ git merge-tree -z A^0 B^0 >out && - printf "\\n" >>out && + echo >>out && anonymize_hash out >actual && q_to_tab <<-\EOF | lf_to_nul >expect && HASH @@ -284,7 +284,7 @@ test_expect_success 'rename/add handling' ' test_expect_code 1 \ git merge-tree -z A^0 B^0 >out && - printf "\\n" >>out && + echo >>out && # # First, check that the bar that appears at stage 3 does not @@ -351,7 +351,7 @@ test_expect_success SYMLINKS 'rename/add, where add is a mode conflict' ' test_expect_code 1 \ git merge-tree -z A^0 B^0 >out && - printf "\\n" >>out && + echo >>out && # # First, check that the bar that appears at stage 3 does not @@ -417,7 +417,7 @@ test_expect_success 'rename/rename + content conflict' ' test_expect_code 1 \ git merge-tree -z A^0 B^0 >out && - printf "\\n" >>out && + echo >>out && anonymize_hash out >actual && q_to_tab <<-\EOF | lf_to_nul >expect && HASH @@ -471,7 +471,7 @@ test_expect_success 'rename/add/delete conflict' ' test_expect_code 1 \ git merge-tree -z B^0 A^0 >out && - printf "\\n" >>out && + echo >>out && anonymize_hash out >actual && q_to_tab <<-\EOF | lf_to_nul >expect && @@ -528,7 +528,7 @@ test_expect_success 'rename/rename(2to1)/delete/delete conflict' ' test_expect_code 1 \ git merge-tree -z A^0 B^0 >out && - printf "\\n" >>out && + echo >>out && anonymize_hash out >actual && q_to_tab <<-\EOF | lf_to_nul >expect && @@ -600,7 +600,7 @@ test_expect_success 'mod6: chains of rename/rename(1to2) and add/add via collidi test_expect_code 1 \ git merge-tree -z A^0 B^0 >out && - printf "\\n" >>out && + echo >>out && # # First, check that some of the hashes that appear as stage @@ -690,7 +690,7 @@ test_expect_success 'directory rename + rename/delete + modify/delete + director test_expect_code 1 \ git merge-tree -z A^0 B^0 >out && - printf "\\n" >>out && + echo >>out && anonymize_hash out >actual && q_to_tab <<-\EOF | lf_to_nul >expect && @@ -760,7 +760,7 @@ test_expect_success 'NUL terminated conflicted file "lines"' ' git commit -m "Renamed numbers" && test_expect_code 1 git merge-tree --write-tree -z tweak1 side2 >out && - printf "\\n" >>out && + echo >>out && anonymize_hash out >actual && # Expected results: