From patchwork Fri Dec 2 00:06:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13061967 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 8FED7C3A5A7 for ; Fri, 2 Dec 2022 00:07:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231542AbiLBAHZ (ORCPT ); Thu, 1 Dec 2022 19:07:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230445AbiLBAHV (ORCPT ); Thu, 1 Dec 2022 19:07:21 -0500 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A142C510B for ; Thu, 1 Dec 2022 16:07:20 -0800 (PST) Received: by mail-ed1-x52b.google.com with SMTP id b8so4429071edf.11 for ; Thu, 01 Dec 2022 16:07:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XiDj4plKWqRG0LssvoPX7cJ4xT5nzbpj7tZNNg16sAs=; b=IB5gEFRzWIfgjPjatweLiO/FZpjuh9fGIL44BiLYJH2Idq6cUF69rq1wZmAVZrnbeh traUz1QD65SaVXqq3LY1ZVM0+2x+wM/OIX2S4Hcw35Ca5L5JR5Q27RFLPE5FsrT8QDCC +XT63EjKsqJlWdxOlTtCsNxruCm/bYbbgFNQ1ZpXvFL6/CT6TR68sbFEdriU9DpS6aAC zAFgyylv6r327mfWnejlRpb1qUxGuP2SzL1VbrQ/nuzrflXCFxSEqRBUGbrnBhfUZ59i Yw7mY6kfKb246ya/lKbt5oXdDOgVsLtSfXOoybeERzaTnudFVEZ6ZYSuR9hEDfW2TQQD bOzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XiDj4plKWqRG0LssvoPX7cJ4xT5nzbpj7tZNNg16sAs=; b=Ne68DhzWybviXwkefhyfESIgGq6t28j1vXUm+YdHUZIaaxVRjP/Q07c5zee92v3Jh8 MqAAI9WVmAiTqRiaq3u1hgVYaS4keZt4y9SNxb0J2gwaKwv/OZdMMJk+2JmjGRfz3msK u521I4ymydyzT9xIykLoSWcnLd6uVAZCDhC/bPeKXW4AUe36mTx33O1iRMV2dDx6Di1Y Gl0AK21RYOc1vq4cvBgDDsiD/SzHtPF7P8BR7O+MNy83pQbPkzCe7C+U3KPNE7UgV0qb UD2VBJNul3FaXwUNBnWVUag0I5AoRdVuEjQvTqFHgchOsKVYPB3jacAMWr2hsdWNpR7m 2rwQ== X-Gm-Message-State: ANoB5pkQ5W2gF3nrN/PDLJ4nUR1IEkWc1tDv9xkCuHBT1UgwINmW66gN 6ZxFAhwuJhV9UZ5/38B3QGPnky3+UvHlow== X-Google-Smtp-Source: AA0mqf6Pw3D7/6jP/HqTGNRjDRfe7lBjZRYQ0xeaZTHiUOkqSTB50jYAgpE+8hGcQKpP0PVESa+ReQ== X-Received: by 2002:aa7:d912:0:b0:46b:2b37:ffa9 with SMTP id a18-20020aa7d912000000b0046b2b37ffa9mr19123502edr.79.1669939638836; Thu, 01 Dec 2022 16:07:18 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id ex19-20020a170907955300b007be4d8a50d8sm2351576ejc.70.2022.12.01.16.07.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 16:07:18 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?q?Ren=C3=A9_Scharfe?= , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v2 1/8] log tests: don't use "exit 1" outside a sub-shell Date: Fri, 2 Dec 2022 01:06:27 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.rc1.980.g92d3d4579ad In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change an "exit 1" added in ac52d9410e5 (t4205: cover `git log --reflog -z` blindspot, 2019-11-19) to use "return 1" instead, which curiously was done in an adjacent test case added in the same commit. Using "exit 1" outside a sub-shell will cause the test framework itself to exit on failure, which isn't what we want to do here. This issue was spotted with the in-flight "GIT_TEST_PASSING_SANITIZE_LEAK=check" test mode[1]. This "git show" invocation currently leaks memory, and we'd thus "exit 1". This change was initially part of that topic[2] to demonstrate the correctness of the "check" implementation. 1. https://lore.kernel.org/git/patch-07.10-0961df2ab6c-20220719T205710Z-avarab@gmail.com/ 2. https://lore.kernel.org/git/patch-10.10-9cedf0cb0e2-20220719T205710Z-avarab@gmail.com/ Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t4205-log-pretty-formats.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh index e448ef2928a..0404491d6ee 100755 --- a/t/t4205-log-pretty-formats.sh +++ b/t/t4205-log-pretty-formats.sh @@ -156,7 +156,7 @@ test_expect_success 'NUL termination with --reflog --pretty=oneline' ' for r in $revs do git show -s --pretty=oneline "$r" >raw && - cat raw | lf_to_nul || exit 1 + cat raw | lf_to_nul || return 1 done >expect && # the trailing NUL is already produced so we do not need to # output another one From patchwork Fri Dec 2 00:06:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13061969 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 66256C4332F for ; Fri, 2 Dec 2022 00:07:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231719AbiLBAH0 (ORCPT ); Thu, 1 Dec 2022 19:07:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231342AbiLBAHW (ORCPT ); Thu, 1 Dec 2022 19:07:22 -0500 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE0EEC5129 for ; Thu, 1 Dec 2022 16:07:21 -0800 (PST) Received: by mail-ej1-x633.google.com with SMTP id gu23so7982407ejb.10 for ; Thu, 01 Dec 2022 16:07:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Jd75qDYW4QtrqrmJ31ywQCkiHZdH9+1KpGTe3aVyUIg=; b=oKVUcltzLj0/10sNJbBgqF0keEbs4Q2AsSycII9c4QRxCk0qRtN0BMV+oSrO+Ze6zC 4fDTqDU3HxDOD0+2oJUitC2pCd+RJ7vRhIBnNWrZ0JpM6FRwcuntoO6YQsm7ptAx+YFy xhbnqDjsCjcpuKjlxRjkCf3R3zS6bcg+85W46MiJ4tRNF+i0yv05cZSyCFvXcPBm5AMi Y2ZP/IU9Zllhy/LkwpyvKEgRhX9jv9JsJQb1TUnEIj0gSNIAkjQHaoXVrah2GajZ0TIL KJHZM8x+uNtL05gyVraNcqxktZXdxvUiGp0XWygPl2WNJWc/wxIaEtClD/a+WIbpiCi1 CkCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Jd75qDYW4QtrqrmJ31ywQCkiHZdH9+1KpGTe3aVyUIg=; b=L9KF+q4JWmfOSEelUg1LbTlpx5g+Ztb1aJ62Ow5C/RaUiFWmiktpviWaojvTaPJPVM A2MUFUhiuRBuw9Cm+0Bhq6PWSOBTG3hs+aIAC+E3DTlJwv3fLFxlYnUPlDevLLwC8dqg 4jmGCyVeHEyBc5TMakITU/mIdZKu8WsEParsk11+y5NfSK94aYBIW7//aRVY7VJh9gnd whwZUt6/0FszwdNZsvyD5qxn8tvre7zqtIqOuZUKKv5kOPfhI38vPMLhEohmy+3RhUDC VchuKjd2x/yZ/lYUWHM5GJ3WjylKbPUKKACPdsWDITGHDQ2QIJ4XVuH7u5lDcokPPrFk 9aZg== X-Gm-Message-State: ANoB5pljj4mdOW+hLGCX2PYzHmv7919wuHgyxxO5fBAOuisr9mokU2KP BYX0CNS//hVoDwlQmclLABhgH30RzsOA8w== X-Google-Smtp-Source: AA0mqf4Kql6/G+u6y1d2jrQbt9cPYbNVajlDlm6HthQOcwjSKjNjL/EQLaOs2LqDbipzFSHkUG1zLw== X-Received: by 2002:a17:906:901:b0:7ae:23c:3cb4 with SMTP id i1-20020a170906090100b007ae023c3cb4mr14484812ejd.599.1669939639860; Thu, 01 Dec 2022 16:07:19 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id ex19-20020a170907955300b007be4d8a50d8sm2351576ejc.70.2022.12.01.16.07.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 16:07:19 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?q?Ren=C3=A9_Scharfe?= , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v2 2/8] auto-crlf tests: check "git checkout" exit code Date: Fri, 2 Dec 2022 01:06:28 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.rc1.980.g92d3d4579ad In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Don't hide the exit code from the "git checkout" we run to checkout our attributes file. This fixes cases where we'd have e.g. missed memory leaks under SANITIZE=leak, this code doesn't leak (the relevant "git checkout" leak has been fixed), but in a past version of git we'd continue past this failure under SANITIZE=leak when these invocations had errored out, even under "--immediate". Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t0027-auto-crlf.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh index a94ac1eae37..574344a99db 100755 --- a/t/t0027-auto-crlf.sh +++ b/t/t0027-auto-crlf.sh @@ -294,11 +294,17 @@ checkout_files () { pfx=eol_${ceol}_crlf_${crlf}_attr_${attr}_ && for f in LF CRLF LF_mix_CR CRLF_mix_LF LF_nul do - rm crlf_false_attr__$f.txt && - if test -z "$ceol"; then - git checkout -- crlf_false_attr__$f.txt + if test -z "$ceol" + then + test_expect_success "setup $f checkout" ' + rm crlf_false_attr__$f.txt && + git checkout -- crlf_false_attr__$f.txt + ' else - git -c core.eol=$ceol checkout -- crlf_false_attr__$f.txt + test_expect_success "setup $f checkout with core.eol=$ceol" ' + rm crlf_false_attr__$f.txt && + git -c core.eol=$ceol checkout -- crlf_false_attr__$f.txt + ' fi done From patchwork Fri Dec 2 00:06:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13061968 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 B82ABC3A5A7 for ; Fri, 2 Dec 2022 00:07:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231915AbiLBAHa (ORCPT ); Thu, 1 Dec 2022 19:07:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231573AbiLBAHX (ORCPT ); Thu, 1 Dec 2022 19:07:23 -0500 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5983C5131 for ; Thu, 1 Dec 2022 16:07:22 -0800 (PST) Received: by mail-ej1-x62c.google.com with SMTP id vp12so8007905ejc.8 for ; Thu, 01 Dec 2022 16:07:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XPI0sif6GzBdqYmgsWbjnVcekwkTGNvkhzObfJYnMJM=; b=kF7SfbIaN1rR4WsV1G9smVh37wFdRojzIFjuP+h2JStoN6Qd5WPb0KolZTx0C7D7SC w5R0RBlrQpoAVQ1inrur2WAZR0C9bmVMw6Azb7KTGy2Su/5OBEqM8II3TVVlTBqqqOHJ V66JhKzgPt0ppI0BZ09SuY9OMXEVTT0EAqU+GnZrx3tnrvQ/5+wgJOzEf6qCSaDKUejW P42+QEjbO0gLvbUy+831YjivdkoQBt1Se3lWTkEAb+dXZPhBwNnhxlWLCcP59P1PFvBn xoydKWjbHb+DUEeQyT5QWx9BdBK45wRjdLHSQWDtAOoWRq3pD5xqFCzoHR7kyBCIYYg8 ttLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XPI0sif6GzBdqYmgsWbjnVcekwkTGNvkhzObfJYnMJM=; b=SC3r3SFI9ZFt2xIBtNqwJq9nJ27BR2MQa34RiQQ2VFihfDoRfGe8WcZnTxa2j1+6vK In8xpGtJWxU1B5fGaQ5rjrvLeqbnN0IkgmQrD+DDC9+6BdewQU2OxMc4bIvw6LDc4vO8 /P0zQlIL4wThW0YXebzpsmaIP3VxpLX0MG2BLpHXNnK/BarItv+oV0h4VRomooP8xLj4 BVE6G+W0w+1yGyxQdP1Ifg8tCyHAvvKI3ciFZts4AmPV4I1HDnR/KoUFthWGdiZ6vP0q AWUxtfE1p4rGDay63Nt/sDykOFrySZDgHiVyEJD0b5oLykVM88N01Eoiq5LrcR5E/f7n 5TXA== X-Gm-Message-State: ANoB5pkRVD54EmrL+8Fj03F3DGDSwbgDpOuCKSNxEOZEq/DXll4j7MwU lGdWxlU5wZsvXbkwoz8MXQUArwduX7C7Sg== X-Google-Smtp-Source: AA0mqf7UTM3tm3Qu1aKRkbYGQo/dVvgJYdH1OgJdGv0pTz0MYcJQ2E+mOlS0PLwJEkNOKMBcYa+mgw== X-Received: by 2002:a17:906:6dd7:b0:7a1:1c24:e564 with SMTP id j23-20020a1709066dd700b007a11c24e564mr46133698ejt.629.1669939640936; Thu, 01 Dec 2022 16:07:20 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id ex19-20020a170907955300b007be4d8a50d8sm2351576ejc.70.2022.12.01.16.07.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 16:07:20 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?q?Ren=C3=A9_Scharfe?= , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v2 3/8] diff tests: fix ignored exit codes in t4023 Date: Fri, 2 Dec 2022 01:06:29 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.rc1.980.g92d3d4579ad In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change a "git diff-tree" command to be &&-chained so that we won't ignore its exit code, see the ea05fd5fbf7 (Merge branch 'ab/keep-git-exit-codes-in-tests', 2022-03-16) topic for prior art. This fixes code added in b45563a229f (rename: Break filepairs with different types., 2007-11-30). Due to hiding the exit code we hid a memory leak under SANITIZE=leak. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t4023-diff-rename-typechange.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/t/t4023-diff-rename-typechange.sh b/t/t4023-diff-rename-typechange.sh index 7cb99092938..25c31b0cb1b 100755 --- a/t/t4023-diff-rename-typechange.sh +++ b/t/t4023-diff-rename-typechange.sh @@ -52,8 +52,8 @@ test_expect_success setup ' ' test_expect_success 'cross renames to be detected for regular files' ' - - git diff-tree five six -r --name-status -B -M | sort >actual && + git diff-tree five six -r --name-status -B -M >out && + sort actual && { echo "R100 foo bar" && echo "R100 bar foo" @@ -63,8 +63,8 @@ test_expect_success 'cross renames to be detected for regular files' ' ' test_expect_success 'cross renames to be detected for typechange' ' - - git diff-tree one two -r --name-status -B -M | sort >actual && + git diff-tree one two -r --name-status -B -M >out && + sort actual && { echo "R100 foo bar" && echo "R100 bar foo" @@ -74,8 +74,8 @@ test_expect_success 'cross renames to be detected for typechange' ' ' test_expect_success 'moves and renames' ' - - git diff-tree three four -r --name-status -B -M | sort >actual && + git diff-tree three four -r --name-status -B -M >out && + sort actual && { # see -B -M (#6) in t4008 echo "C100 foo bar" && From patchwork Fri Dec 2 00:06:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13061971 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 90A34C4332F for ; Fri, 2 Dec 2022 00:07:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231444AbiLBAHj (ORCPT ); Thu, 1 Dec 2022 19:07:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231550AbiLBAHZ (ORCPT ); Thu, 1 Dec 2022 19:07:25 -0500 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF006C5E16 for ; Thu, 1 Dec 2022 16:07:23 -0800 (PST) Received: by mail-ej1-x62d.google.com with SMTP id td2so8030167ejc.5 for ; Thu, 01 Dec 2022 16:07:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sfakrQ20rATcL/ko51eRpDGYAdUQ6CF6XlPz3JlM53U=; b=e5jvPuiU3zHVm1zgvpprP/cg2i6gqwIW7n061sXAXoIs/3nmfHcJ+67LyJ0JcBsQqc 1pBh2aJgU3LpDwnBeiPYqvtM3ORTRunX5q82YWehbibzSOxdRRCxVaZ7NbMyB4QJX6z4 KBBIsqhlzKJ9lysPwp1cPHUe7JegmtnDBESBhUkAW+rLg7HIwC/UPQBSTxvMYCoQtQ2E cREcSmRKZ+tPwVSyBeuasyRwAfiyHRp2rlkegj0vTxHcNR1+7H42KE/l1koI8mm2vOKZ pAPYEzCIiV+RuWirQOcF7+Wgv46O+VJ5zi0tk+CEhiny1snES4Zf7FI9q9MDiVAASonE tRFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sfakrQ20rATcL/ko51eRpDGYAdUQ6CF6XlPz3JlM53U=; b=fh0gP13Lt6JGdQIWWADWbb+5DtRI3aept/4KSfg9tBcip+N2SGCkXu4Cb0QFsS/7fU tnqIKF8jAmDetJTNtK+z+prqEmep0nAOIgAf/ejWQ3SUWtjHV0C1Pjlq9bYcZuluh4Dh kFuGMvsuijgZpq45FJdRnHKA3TrIL0bCj2G2bBWNJ1mVDiojV11/a7oYSX4xRC2b48Zk XitzDhz1odMyhhoyYQdCwZsvzecXeBeIb1Ih+vP0M1mLVXE6mfL3TpaIXYI9mWPfIkv4 X9DL+d8TCW3lYNjxp1MbgDtZSQ+rdgt2QSZBViMiaQTqiRRzC+FqRp6r+0xJ0jafBUCI jyZA== X-Gm-Message-State: ANoB5pkDuEV1IZ/fsuOVoYg7np/PvwG7edqXwSnsoiw42Yssvjj92rEN r801NndhTxfn/ddm6bot6N7OirarPHtcPA== X-Google-Smtp-Source: AA0mqf4WOKbXunOcrkbo46fnZZbTA51I29pkYJbKdTmnzh95tKAZ31pvLSjb9lj6hbH44+aIezmMYQ== X-Received: by 2002:a17:906:794b:b0:7bb:a098:988c with SMTP id l11-20020a170906794b00b007bba098988cmr32679516ejo.11.1669939642053; Thu, 01 Dec 2022 16:07:22 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id ex19-20020a170907955300b007be4d8a50d8sm2351576ejc.70.2022.12.01.16.07.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 16:07:21 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?q?Ren=C3=A9_Scharfe?= , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v2 4/8] test-lib-functions: add and use test_cmp_cmd Date: Fri, 2 Dec 2022 01:06:30 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.rc1.980.g92d3d4579ad In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add a "test_cmp_cmd" helper for the common pattern discussed in the documentation being added here to "t/test-lib-functions.sh". This implementation leaves the door open for extending this helper past its obvious limitations, such as: test_cmp_cmd "some" "lines" -- test_cmp_cmd --stdin By using this in we'll catch cases where "git" or "test-tool" errors (such as segfaults or abort()) were previously hidden, and we'd either pass the test, or fail in some subsequent assertion. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/lib-submodule-update.sh | 2 +- t/t0001-init.sh | 4 +-- t/t0002-gitfile.sh | 2 +- t/t0060-path-utils.sh | 57 ++++++++++++++++++++------------------- t/t0100-previous.sh | 4 +-- t/t1504-ceiling-dirs.sh | 6 +++-- t/test-lib-functions.sh | 18 +++++++++++++ 7 files changed, 58 insertions(+), 35 deletions(-) diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh index 2d31fcfda1f..d5d98714b4e 100644 --- a/t/lib-submodule-update.sh +++ b/t/lib-submodule-update.sh @@ -189,7 +189,7 @@ test_git_directory_exists () { if test -f sub1/.git then # does core.worktree point at the right place? - test "$(git -C .git/modules/$1 config core.worktree)" = "../../../$1" + test_cmp_cmd "../../../$1" git -C ".git/modules/$1" config core.worktree fi } diff --git a/t/t0001-init.sh b/t/t0001-init.sh index d479303efa0..a3b902bcd8f 100755 --- a/t/t0001-init.sh +++ b/t/t0001-init.sh @@ -598,9 +598,9 @@ test_expect_success 'invalid default branch name' ' test_expect_success 'branch -m with the initial branch' ' git init rename-initial && git -C rename-initial branch -m renamed && - test renamed = $(git -C rename-initial symbolic-ref --short HEAD) && + test_cmp_cmd renamed git -C rename-initial symbolic-ref --short HEAD && git -C rename-initial branch -m renamed again && - test again = $(git -C rename-initial symbolic-ref --short HEAD) + test_cmp_cmd again git -C rename-initial symbolic-ref --short HEAD ' test_done diff --git a/t/t0002-gitfile.sh b/t/t0002-gitfile.sh index 26eaca095a2..aca847512c4 100755 --- a/t/t0002-gitfile.sh +++ b/t/t0002-gitfile.sh @@ -33,7 +33,7 @@ test_expect_success 'bad setup: invalid .git file path' ' test_expect_success 'final setup + check rev-parse --git-dir' ' echo "gitdir: $REAL" >.git && - test "$REAL" = "$(git rev-parse --git-dir)" + test_cmp_cmd "$REAL" git rev-parse --git-dir ' test_expect_success 'check hash-object' ' diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh index 68e29c904a6..c90d2e4d2b1 100755 --- a/t/t0060-path-utils.sh +++ b/t/t0060-path-utils.sh @@ -10,20 +10,21 @@ TEST_PASSES_SANITIZE_LEAK=true norm_path() { expected=$(test-tool path-utils print_path "$2") - test_expect_success $3 "normalize path: $1 => $2" \ - "test \"\$(test-tool path-utils normalize_path_copy '$1')\" = '$expected'" + test_expect_success $3 "normalize path: $1 => $2" " + test_cmp_cmd '$expected' test-tool path-utils normalize_path_copy '$1' + " } relative_path() { expected=$(test-tool path-utils print_path "$3") - test_expect_success $4 "relative path: $1 $2 => $3" \ - "test \"\$(test-tool path-utils relative_path '$1' '$2')\" = '$expected'" + test_expect_success $4 "relative path: $1 $2 => $3" " + test_cmp_cmd '$expected' test-tool path-utils relative_path '$1' '$2' + " } test_submodule_relative_url() { test_expect_success "test_submodule_relative_url: $1 $2 $3 => $4" " - actual=\$(test-tool submodule resolve-relative-url '$1' '$2' '$3') && - test \"\$actual\" = '$4' + test_cmp_cmd '$4' test-tool submodule resolve-relative-url '$1' '$2' '$3' " } @@ -64,9 +65,9 @@ ancestor() { expected=$(($expected-$rootslash+$rootoff)) ;; esac - test_expect_success $4 "longest ancestor: $1 $2 => $expected" \ - "actual=\$(test-tool path-utils longest_ancestor_length '$1' '$2') && - test \"\$actual\" = '$expected'" + test_expect_success $4 "longest ancestor: $1 $2 => $expected" " + test_cmp_cmd '$expected' test-tool path-utils longest_ancestor_length '$1' '$2' + " } # Some absolute path tests should be skipped on Windows due to path mangling @@ -166,8 +167,10 @@ ancestor D:/Users/me C:/ -1 MINGW ancestor //server/share/my-directory //server/share/ 14 MINGW test_expect_success 'strip_path_suffix' ' - test c:/msysgit = $(test-tool path-utils strip_path_suffix \ - c:/msysgit/libexec//git-core libexec/git-core) + echo c:/msysgit >expect && + test-tool path-utils strip_path_suffix \ + c:/msysgit/libexec//git-core libexec/git-core >actual && + test_cmp expect actual ' test_expect_success 'absolute path rejects the empty string' ' @@ -189,34 +192,34 @@ test_expect_success 'real path rejects the empty string' ' test_expect_success POSIX 'real path works on absolute paths 1' ' nopath="hopefully-absent-path" && - test "/" = "$(test-tool path-utils real_path "/")" && - test "/$nopath" = "$(test-tool path-utils real_path "/$nopath")" + test_cmp_cmd / test-tool path-utils real_path "/" && + test_cmp_cmd "/$nopath" test-tool path-utils real_path "/$nopath" ' test_expect_success 'real path works on absolute paths 2' ' nopath="hopefully-absent-path" && # Find an existing top-level directory for the remaining tests: d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") && - test "$d" = "$(test-tool path-utils real_path "$d")" && - test "$d/$nopath" = "$(test-tool path-utils real_path "$d/$nopath")" + test_cmp_cmd "$d" test-tool path-utils real_path "$d" && + test_cmp_cmd "$d/$nopath" test-tool path-utils real_path "$d/$nopath" ' test_expect_success POSIX 'real path removes extra leading slashes' ' nopath="hopefully-absent-path" && - test "/" = "$(test-tool path-utils real_path "///")" && - test "/$nopath" = "$(test-tool path-utils real_path "///$nopath")" && + test_cmp_cmd "/" test-tool path-utils real_path "///" && + test_cmp_cmd "/$nopath" test-tool path-utils real_path "///$nopath" && # Find an existing top-level directory for the remaining tests: d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") && - test "$d" = "$(test-tool path-utils real_path "//$d")" && - test "$d/$nopath" = "$(test-tool path-utils real_path "//$d/$nopath")" + test_cmp_cmd "$d" test-tool path-utils real_path "//$d" && + test_cmp_cmd "$d/$nopath" test-tool path-utils real_path "//$d/$nopath" ' test_expect_success 'real path removes other extra slashes' ' nopath="hopefully-absent-path" && # Find an existing top-level directory for the remaining tests: d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") && - test "$d" = "$(test-tool path-utils real_path "$d///")" && - test "$d/$nopath" = "$(test-tool path-utils real_path "$d///$nopath")" + test_cmp_cmd "$d" test-tool path-utils real_path "$d///" && + test_cmp_cmd "$d/$nopath" test-tool path-utils real_path "$d///$nopath" ' test_expect_success SYMLINKS 'real path works on symlinks' ' @@ -227,19 +230,19 @@ test_expect_success SYMLINKS 'real path works on symlinks' ' mkdir third && dir="$(cd .git && pwd -P)" && dir2=third/../second/other/.git && - test "$dir" = "$(test-tool path-utils real_path $dir2)" && + test_cmp_cmd "$dir" test-tool path-utils real_path $dir2 && file="$dir"/index && - test "$file" = "$(test-tool path-utils real_path $dir2/index)" && + test_cmp_cmd "$file" test-tool path-utils real_path $dir2/index && basename=blub && - test "$dir/$basename" = "$(cd .git && test-tool path-utils real_path "$basename")" && + test_cmp_cmd "$dir/$basename" test-tool -C .git path-utils real_path "$basename" && ln -s ../first/file .git/syml && sym="$(cd first && pwd -P)"/file && - test "$sym" = "$(test-tool path-utils real_path "$dir2/syml")" + test_cmp_cmd "$sym" test-tool path-utils real_path "$dir2/syml" ' test_expect_success SYMLINKS 'prefix_path works with absolute paths to work tree symlinks' ' ln -s target symlink && - test "$(test-tool path-utils prefix_path prefix "$(pwd)/symlink")" = "symlink" + test_cmp_cmd "symlink" test-tool path-utils prefix_path prefix "$(pwd)/symlink" ' test_expect_success 'prefix_path works with only absolute path to work tree' ' @@ -255,7 +258,7 @@ test_expect_success 'prefix_path rejects absolute path to dir with same beginnin test_expect_success SYMLINKS 'prefix_path works with absolute path to a symlink to work tree having same beginning as work tree' ' git init repo && ln -s repo repolink && - test "a" = "$(cd repo && test-tool path-utils prefix_path prefix "$(pwd)/../repolink/a")" + test_cmp_cmd "a" test-tool -C repo path-utils prefix_path prefix "$(cd repo && pwd)/../repolink/a" ' relative_path /foo/a/b/c/ /foo/a/b/ c/ diff --git a/t/t0100-previous.sh b/t/t0100-previous.sh index a16cc3d2983..e315283cccd 100755 --- a/t/t0100-previous.sh +++ b/t/t0100-previous.sh @@ -12,7 +12,7 @@ test_expect_success 'branch -d @{-1}' ' test_commit A && git checkout -b junk && git checkout - && - test "$(git symbolic-ref HEAD)" = refs/heads/main && + test_cmp_cmd refs/heads/main git symbolic-ref HEAD && git branch -d @{-1} && test_must_fail git rev-parse --verify refs/heads/junk ' @@ -21,7 +21,7 @@ test_expect_success 'branch -d @{-12} when there is not enough switches yet' ' git reflog expire --expire=now && git checkout -b junk2 && git checkout - && - test "$(git symbolic-ref HEAD)" = refs/heads/main && + test_cmp_cmd refs/heads/main git symbolic-ref HEAD && test_must_fail git branch -d @{-12} && git rev-parse --verify refs/heads/main ' diff --git a/t/t1504-ceiling-dirs.sh b/t/t1504-ceiling-dirs.sh index 0fafcf9dde3..2c73869235d 100755 --- a/t/t1504-ceiling-dirs.sh +++ b/t/t1504-ceiling-dirs.sh @@ -6,8 +6,10 @@ TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_prefix() { - test_expect_success "$1" \ - "test '$2' = \"\$(git rev-parse --show-prefix)\"" + local expect="$2" && + test_expect_success "$1: git rev-parse --show-prefix is '$2'" ' + test_cmp_cmd "$expect" git rev-parse --show-prefix + ' } test_fail() { diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 796093a7b32..0e8e0f808e3 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -1274,6 +1274,24 @@ test_cmp_rev () { fi } +# test_cmp_cmd is a convenience helper for doing the more verbose: +# +# echo something >expect && +# >actual && +# test_cmp expect actual +# +# As: +# +# test_cmp_cmd something +test_cmp_cmd () { + local expect="$1" && + shift && + printf "%s\n" "$expect" >expect && + "$@" >actual 2>err && + test_must_be_empty err + test_cmp expect actual +} + # Compare paths respecting core.ignoreCase test_cmp_fspath () { if test "x$1" = "x$2" From patchwork Fri Dec 2 00:06:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13061970 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 30CA3C4332F for ; Fri, 2 Dec 2022 00:07:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231224AbiLBAHh (ORCPT ); Thu, 1 Dec 2022 19:07:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230445AbiLBAHZ (ORCPT ); Thu, 1 Dec 2022 19:07:25 -0500 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7646C5135 for ; Thu, 1 Dec 2022 16:07:23 -0800 (PST) Received: by mail-ej1-x633.google.com with SMTP id gu23so7982626ejb.10 for ; Thu, 01 Dec 2022 16:07:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Bx+NdMOZotI1X8QlHYADdQkhlr/v61I9v5jxO6U4Ad0=; b=l7TjXJUD7r2IcO9FWXn0gS34GyU6N3dLNmnLooYdqasq9p5NyA/aPm55rzzvofeTfw +2Bhjn+YgotMVDcy+Hzgso8PS9bOuCt5cZ3MSoJolemLhv6Bdu8wQDELetE+Mf0yLNFy qoTou1vnf69gkPuD9F5Wkb3v6qI13FmyCef8j6st9QfpJX6E1Nq6WsH/sO5xB93vDjCp 49bbPi517LwwqcRQILctg08+WL+46oPMICmNJphkeA9ivF2ARHKQjYcgjCPoi53fplrf hx+jwhCbnzOM5ePBD5DHofCiuWZRkP90AJtBeQCto7dqCaI6/2SbvqpjbhyJnYupgPea Y8Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Bx+NdMOZotI1X8QlHYADdQkhlr/v61I9v5jxO6U4Ad0=; b=H7gPruY1Agwx83N0laHPuQHpDPQ0Sdqxjehzumw/dxp2c1YzmAUt6DBsFdvWVxFNQq nYls4XyOLNbUMaZGn4bwfiH+nFu9wlOgh/IE0wH43mZf0WXsw145SVEd07xMN+c3lodU qumM3fk5nZOsbpQVe3m1TIgUk/SGF877ae+lsRmIewqMcr60MGj4klepbNkCiHKlrP59 r3NZrI3lvEGVvZM+h/9ayqMysZMZowNAE1rhuqTe3U9cm5evF+MZRNWjFFV+JDhDw3CF hOXtSSKqntRV7+bJeqcHk98nldjiHxJRYO7p70WFMiq8OtgXcnCeT1BRv623Nsfxf3t8 ODzA== X-Gm-Message-State: ANoB5pkBvnTmCmluJkDKd9sPCQxW2MzJYEA2hwZug//kx9ER5Pxb+dFF XBEtZ1poC1BLLM2s3M5gvKxu+gyOT8B0uA== X-Google-Smtp-Source: AA0mqf6L0uqRvzeG45vs82s/SXeIWSb+h49R5fIaECx7YnNxYTS8Ng0oHOr5Gfo61DX+RXC7DcrX4Q== X-Received: by 2002:a17:906:1e8a:b0:7b2:b992:694d with SMTP id e10-20020a1709061e8a00b007b2b992694dmr52578235ejj.651.1669939643070; Thu, 01 Dec 2022 16:07:23 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id ex19-20020a170907955300b007be4d8a50d8sm2351576ejc.70.2022.12.01.16.07.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 16:07:22 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?q?Ren=C3=A9_Scharfe?= , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v2 5/8] t/lib-patch-mode.sh: fix ignored "git" exit codes Date: Fri, 2 Dec 2022 01:06:31 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.rc1.980.g92d3d4579ad In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Fix code added in b319ef70a94 (Add a small patch-mode testing library, 2009-08-13) to use &&-chaining and the newly added "test_cmp_cmd" instead of interpolating "git" commands in a "test" statement. This fixes cases where we'd have e.g. missed memory leaks under SANITIZE=leak, this code doesn't leak now as far as I can tell, but I discovered it while looking at leaks in related code. The "cat _head >expect" here is redundant, we could simply give "_head" to "test_cmp", but let's be consistent in using the "expect" and "actual" names for clarity. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/lib-patch-mode.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/t/lib-patch-mode.sh b/t/lib-patch-mode.sh index cfd76bf987b..ae51f33a010 100644 --- a/t/lib-patch-mode.sh +++ b/t/lib-patch-mode.sh @@ -29,8 +29,11 @@ set_and_save_state () { # verify_state verify_state () { - test "$(cat "$1")" = "$2" && - test "$(git show :"$1")" = "$3" + echo "$2" >expect && + cat "$1" >actual && + test_cmp expect actual && + + test_cmp_cmd "$3" git show :"$1" } # verify_saved_state @@ -46,5 +49,5 @@ save_head () { } verify_saved_head () { - test "$(cat _head)" = "$(git rev-parse HEAD)" + test_cmp_cmd "$(cat _head)" git rev-parse HEAD } From patchwork Fri Dec 2 00:06:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13061972 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 3D084C4332F for ; Fri, 2 Dec 2022 00:07:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231905AbiLBAHo (ORCPT ); Thu, 1 Dec 2022 19:07:44 -0500 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 S231628AbiLBAH0 (ORCPT ); Thu, 1 Dec 2022 19:07:26 -0500 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6E9CC510B for ; Thu, 1 Dec 2022 16:07:25 -0800 (PST) Received: by mail-ej1-x632.google.com with SMTP id td2so8030315ejc.5 for ; Thu, 01 Dec 2022 16:07:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PNfAvdQFXXe+9ThL11w33UlC+TtUkH7jNduzG2ZIdDI=; b=ia6hPyDb2dKK1SE7oO3R/nvW4akjrU6KBbL2Tey3tQnNhjtcajGIT86eOQe1V93g7R j6liOxgTMCLQSdv0OpXOZKqHCT6XeYgqOeBR7FHGViCbK/C6QQIjrW3tAgYsC5QylwWz dC/jxEU9euG8JFQ685Hcg9SZwEiJdBeK7dC2KJZVZl1zG2sAoyryz3PT2IpNiCSZJE7A noRcG0SlD95VBGB6JoboOrViDjNVS8YC9qpriSlnMGCKIl4DMSWpHXFu+rLISkgnohoE HVUN6OsXhUU7K4HbhEVNT6YQBbm+lcnYDxSmndpsQSVYA0I37t3rlqj/6npPfePt9v46 2sqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PNfAvdQFXXe+9ThL11w33UlC+TtUkH7jNduzG2ZIdDI=; b=UgtedVRZnhS8zwCr8AsbsDUqEFs0gVyO5lfI4anvlOzIHwh/BNDge+o/SYtVEgR9iO BqdO6jrWNwAYQD8zaHvYpMrsbu8npSIBnEGX+bt45+GhcUuNwVWdpUfVs0mtc2PblOsy T4jhwxsd8cRQTqFAELDh+uUFujAD9m0YyduYXYH6c9i74IQfxGj1clFJ1wHkAudvlSSW DLFxdxT/Uzjnii0sC4q+Y9Ku4w+Ap+AG3mtDcx9ijh8OjKBrtLcRrSW9SOeyNfmufOdv EKZf67XYiSTupkU4zQJGAtV7VaftDEpLv+vT3ZMaiVYxHinFkUbmgHl7QUnPYGV//8QV 8LHw== X-Gm-Message-State: ANoB5pkFMF2BwWcv9COgGFy1yum6vVmuQClt6iQ/LHri25ZYXWnN/mov yt+ED5KDkARrOxrO+jb8WfyrW4RIIa3nSw== X-Google-Smtp-Source: AA0mqf6Kd2KPQ5k+6ogwifEqtejv2XcI85OIO2+LXhyQJV9lT0BhAt8Pd/0IvSj9SlSGF4VPeMeb3g== X-Received: by 2002:a17:907:8a23:b0:7bd:2864:d33d with SMTP id sc35-20020a1709078a2300b007bd2864d33dmr27808697ejc.330.1669939644163; Thu, 01 Dec 2022 16:07:24 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id ex19-20020a170907955300b007be4d8a50d8sm2351576ejc.70.2022.12.01.16.07.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 16:07:23 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?q?Ren=C3=A9_Scharfe?= , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v2 6/8] merge tests: don't ignore "rev-parse" exit code in helper Date: Fri, 2 Dec 2022 01:06:32 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.rc1.980.g92d3d4579ad In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change the verify_mergeheads() helper the check the exit code of "git rev-parse". The "$rest" variable added in 274a5c06d52 (merge: record tag objects without peeling in MERGE_HEAD, 2011-11-07) wasn't being used. Such a thing is needed to support the .git/MERGE_HEAD format in general, but in this case we have no such addition to the line. So let's compare with "test_cmp" instead, we can always add back this "$rest" parsing if it's needed in the future. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t7600-merge.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh index 7c3f6ed9943..f5c4cbae9c8 100755 --- a/t/t7600-merge.sh +++ b/t/t7600-merge.sh @@ -102,12 +102,11 @@ verify_parents () { } verify_mergeheads () { - test_write_lines "$@" >mergehead.expected && - while read sha1 rest + for rev in "$@" do - git rev-parse $sha1 - done <.git/MERGE_HEAD >mergehead.actual && - test_cmp mergehead.expected mergehead.actual + git rev-parse $rev || return 1 + done >mergehead.expected && + test_cmp mergehead.expected .git/MERGE_HEAD } verify_no_mergehead () { From patchwork Fri Dec 2 00:06:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13061973 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 25349C4321E for ; Fri, 2 Dec 2022 00:07:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231970AbiLBAHq (ORCPT ); Thu, 1 Dec 2022 19:07:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231903AbiLBAH2 (ORCPT ); Thu, 1 Dec 2022 19:07:28 -0500 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1CA0CAFA8 for ; Thu, 1 Dec 2022 16:07:26 -0800 (PST) Received: by mail-ej1-x62e.google.com with SMTP id fy37so7978618ejc.11 for ; Thu, 01 Dec 2022 16:07:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=T+QvEsVnJmW8QE43e1iISyaVNyquKvjsIJPBChtGd54=; b=fVwvU+qyOKKtxoszLGeobZQHIzb0u7luTGH35ZW3k4IdTamkNiGxS1n9qJLDZ21YXK QzQIbqYfk1MgKDRcCWEIiayNoFtIKvQ3m6rn3hOnA/DsDCht1EUVf/HrRS3HTQ12pARe fOdRnO9zS1Y/Wg+LnzmV6P/zLkeU0BaCC/u5enJHlz0owcY8STN2YWwlGX2mOi0JgP23 sMu6Mj5b6g3BiCSCDEE5Sy7GYTxxp6Yqqky30DILIyC0HfJdRSFueF5HQVUsRp+RY2AV pZQZUKmCKpS+ALteMpDrwrsGk/bsTYqgZFPNtFJYJKAhRGEfqkX9B20cg+dNM6IKMfsM kNsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=T+QvEsVnJmW8QE43e1iISyaVNyquKvjsIJPBChtGd54=; b=p6yXNo16NaMoSC0jjEFkm5CeNVPh7KNCjZQjyqM9BnJiQOcm2YjV1L3JoIjTe28pkM qs4CyC5CXVUhx78bvJFpqzzu4aLqSr3j8TABuqekeQH/TUwoWk6t1aD4Dnq9qvfMm8Yt uwX02ogY8FbyiG/si10gY+U2bL5GCz2ag4/f/uGvVZa7ukJ5yM06/S/I5WMd63QY+wvz 961NtPIYV0vogNJS/Aor3bxVzx2T+m4IYcyWU69SjmhNr17F9oa7tKlKr3VhSFxBle05 KSyXv/f2/w39k7PzLH0Z28UEWOt8Ps1GRmIQLC2zSOMGAD41wDPc2Dl/Eyyhz+Fiapvb X+Rg== X-Gm-Message-State: ANoB5plDeouz78b4+rM1H/DqmCNBT5uWy/5soZyluUHr3mBqP2UoQHAn sKUPssGRgJLkLNc0kVWpc73fvFLPWglADA== X-Google-Smtp-Source: AA0mqf4W3Pn2wMF4Jq2+OQEQRVv1csbDAyscx3YHkNjUKJ3CW1il6bNkyq1myKP10n8F5uAuKTFvLA== X-Received: by 2002:a17:906:68a:b0:78d:3188:9116 with SMTP id u10-20020a170906068a00b0078d31889116mr58878673ejb.176.1669939645039; Thu, 01 Dec 2022 16:07:25 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id ex19-20020a170907955300b007be4d8a50d8sm2351576ejc.70.2022.12.01.16.07.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 16:07:24 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?q?Ren=C3=A9_Scharfe?= , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v2 7/8] tests: use "test_cmp_cmd" instead of "test" in sub-shells Date: Fri, 2 Dec 2022 01:06:33 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.rc1.980.g92d3d4579ad In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Convert a few cases where we were using "test" inside a sub-shell, and were losing the exit code of "git". In the case of "t3200-branch.sh" some adjacent code outside of a sub-shell that was losing the exit code is also being converted, as it's within the same hunk. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/lib-httpd.sh | 3 +-- t/lib-submodule-update.sh | 20 +++++++------------- t/t3200-branch.sh | 9 +++------ t/t5605-clone-local.sh | 9 ++++----- t/t7402-submodule-rebase.sh | 6 +++--- 5 files changed, 18 insertions(+), 29 deletions(-) diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh index 608949ea80b..082496d6535 100644 --- a/t/lib-httpd.sh +++ b/t/lib-httpd.sh @@ -217,8 +217,7 @@ test_http_push_nonff () { git commit -a -m path2 --amend && test_must_fail git push -v origin >output 2>&1 && - (cd "$REMOTE_REPO" && - test $HEAD = $(git rev-parse --verify HEAD)) + test_cmp_cmd "$HEAD" git -C "$REMOTE_REPO" rev-parse --verify HEAD ' test_expect_success 'non-fast-forward push show ref status' ' diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh index d5d98714b4e..207fab77bd3 100644 --- a/t/lib-submodule-update.sh +++ b/t/lib-submodule-update.sh @@ -168,20 +168,14 @@ replace_gitfile_with_git_dir () { # Note that this only supports submodules at the root level of the # superproject, with the default name, i.e. same as its path. test_git_directory_is_unchanged () { - ( - cd ".git/modules/$1" && - # does core.worktree point at the right place? - test "$(git config core.worktree)" = "../../../$1" && - # remove it temporarily before comparing, as - # "$1/.git/config" lacks it... - git config --unset core.worktree - ) && + # does core.worktree point at the right place? + test_cmp_cmd "../../../$1" git -C ".git/modules/$1" config core.worktree + # remove it temporarily before comparing, as + # "$1/.git/config" lacks it... + git -C ".git/modules/$1" config --unset core.worktree && diff -r ".git/modules/$1" "$1/.git" && - ( - # ... and then restore. - cd ".git/modules/$1" && - git config core.worktree "../../../$1" - ) + # ... and then restore. + git -C ".git/modules/$1" config core.worktree "../../../$1" } test_git_directory_exists () { diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index 5a169b68d6a..c31036b49be 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -242,12 +242,9 @@ test_expect_success 'git branch -M baz bam should succeed when baz is checked ou test_expect_success 'git branch -M baz bam should succeed within a worktree in which baz is checked out' ' git checkout -b baz && git worktree add -f bazdir baz && - ( - cd bazdir && - git branch -M baz bam && - test $(git rev-parse --abbrev-ref HEAD) = bam - ) && - test $(git rev-parse --abbrev-ref HEAD) = bam && + git -C "$bazdir" branch -M baz bam && + test_cmp_cmd "bam" git -C "$bazdir" rev-parse --abbrev-ref HEAD && + test_cmp_cmd "bam" git rev-parse --abbrev-ref HEAD && rm -r bazdir && git worktree prune ' diff --git a/t/t5605-clone-local.sh b/t/t5605-clone-local.sh index 38b850c10ef..55bda2c0aa9 100755 --- a/t/t5605-clone-local.sh +++ b/t/t5605-clone-local.sh @@ -15,8 +15,8 @@ test_expect_success 'preparing origin repository' ' : >file && git add . && git commit -m1 && git clone --bare . a.git && git clone --bare . x && - test "$(cd a.git && git config --bool core.bare)" = true && - test "$(cd x && git config --bool core.bare)" = true && + test_cmp_cmd true git -C a.git config --bool core.bare && + test_cmp_cmd true git -C x config --bool core.bare && git bundle create b1.bundle --all && git bundle create b2.bundle main && mkdir dir && @@ -28,9 +28,8 @@ test_expect_success 'preparing origin repository' ' test_expect_success 'local clone without .git suffix' ' git clone -l -s a b && - (cd b && - test "$(git config --bool core.bare)" = false && - git fetch) + test_cmp_cmd false git -C b config --bool core.bare && + git -C b fetch ' test_expect_success 'local clone with .git suffix' ' diff --git a/t/t7402-submodule-rebase.sh b/t/t7402-submodule-rebase.sh index ebeca12a711..277bb8ae520 100755 --- a/t/t7402-submodule-rebase.sh +++ b/t/t7402-submodule-rebase.sh @@ -82,11 +82,11 @@ test_expect_success 'stash with a dirty submodule' ' CURRENT=$(cd submodule && git rev-parse HEAD) && git stash && test new != $(cat file) && - test submodule = $(git diff --name-only) && - test $CURRENT = $(cd submodule && git rev-parse HEAD) && + test_cmp_cmd submodule git diff --name-only && + test_cmp_cmd "$CURRENT" git -C submodule rev-parse HEAD && git stash apply && test new = $(cat file) && - test $CURRENT = $(cd submodule && git rev-parse HEAD) + test_cmp_cmd "$CURRENT" git -C submodule rev-parse HEAD ' From patchwork Fri Dec 2 00:06:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13061974 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 75115C4332F for ; Fri, 2 Dec 2022 00:07:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231928AbiLBAH4 (ORCPT ); Thu, 1 Dec 2022 19:07:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231573AbiLBAHk (ORCPT ); Thu, 1 Dec 2022 19:07:40 -0500 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8BAECAFA3 for ; Thu, 1 Dec 2022 16:07:27 -0800 (PST) Received: by mail-ej1-x633.google.com with SMTP id ml11so8028893ejb.6 for ; Thu, 01 Dec 2022 16:07:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YfkSuwqGq1tKx1Utf0WUuru+Hn9E6BHQOy/sGUq5NIg=; b=OsTfHnkw1jqQdcjoeMITqO5UXRH7x0dbb6Ciw3pii6X38f1L2pGwUFok87X/oQcocK NKCdo58VgaH9D2AL+qlzSrmrigI91jHEZuOGjktR9SmVJ9ResuGtEzsoKx5DjBJhFsEC IvCMFLMLjzSuZRnIasOItID9GhDeDib1/jRDnu1lAPGcc2a/VOkxDxW8p7NopulVt4dH FdO0O0oHADbmU6XWrvMSWvkLZncirBh4NCGJZUZaov7zoWLi6TpNUf+kq92i4zIQB7UV wuAZzWBJg+bDpk5vQ0490wg5O7e1RpspvTBB4bkjcHwpHGq6ddEcwLpm5ZIh5E+GaaN7 WT2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YfkSuwqGq1tKx1Utf0WUuru+Hn9E6BHQOy/sGUq5NIg=; b=1pjXv10+9wzmKEo3fjvBiVKNPoM+bCSZr41fliLBZLonc3P3iQt7tWxCMa2ZmSjMCP cZ6Gfr4PvKjYHOF67dTtxjy3Z2LHVmHH2uaLtpSm01wizNfING4XRh8eK5dyTVXUsOQN HF7rNQf26LF9y8XSd2znXZdtLNjSxmg08dCRjXTkl+GEXa9MEzEs7qfC0JoL11Jxcya1 d4MREdJJNM867S9rRU1omj2rGCcq3my2pIckr4OxvnGLYdaR+S/ChfgC/fAO/wRKvM99 fio4dd32kkpPk/yMxPn1P+jwm6yBaA6EG978zoUxFbcloJE+y/8m2RFcqfY8xjxyR4Xt 88nA== X-Gm-Message-State: ANoB5pmoQPsumDtPP1OrxGwkucfiMLhUK3111R28SQLFBKawVx7TD3g1 5r5eIqZHa6s4eKx1UolZYTVO/08/NWSf5Q== X-Google-Smtp-Source: AA0mqf6K0YRsQxe2OQ+OBcNS6iqhKH7/9rRfmQnPcJ4cg8mxJ1UzA2vdSiP33Sr7ghVYO7c7/PjqLg== X-Received: by 2002:a17:906:f157:b0:7c0:b0fe:263a with SMTP id gw23-20020a170906f15700b007c0b0fe263amr4155151ejb.496.1669939646053; Thu, 01 Dec 2022 16:07:26 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id ex19-20020a170907955300b007be4d8a50d8sm2351576ejc.70.2022.12.01.16.07.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 16:07:25 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?q?Ren=C3=A9_Scharfe?= , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v2 8/8] tests: use "test_cmp_cmd" in misc tests Date: Fri, 2 Dec 2022 01:06:34 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.rc1.980.g92d3d4579ad In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change a few miscellaneous tests to use "test_cmp_cmd" to avoid losing the exit code of "git". There's many offenders left that match patterns like: /test .*\$\((test-tool|git)/ What these all have in common is that they were the rare odd cases out in test files that were otherwise consistently checking the exit code. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t1401-symbolic-ref.sh | 3 ++- t/t2005-checkout-index-symlinks.sh | 2 +- t/t3701-add-interactive.sh | 9 ++++++--- t/t5522-pull-symlink.sh | 2 +- t/t7402-submodule-rebase.sh | 4 ++-- t/t7504-commit-msg-hook.sh | 2 +- t/t7516-commit-races.sh | 3 ++- t/t7810-grep.sh | 2 +- 8 files changed, 16 insertions(+), 11 deletions(-) diff --git a/t/t1401-symbolic-ref.sh b/t/t1401-symbolic-ref.sh index d708acdb819..5e36899d207 100755 --- a/t/t1401-symbolic-ref.sh +++ b/t/t1401-symbolic-ref.sh @@ -33,7 +33,8 @@ test_expect_success 'symbolic-ref refuses non-ref for HEAD' ' reset_to_sane test_expect_success 'symbolic-ref refuses bare sha1' ' - test_must_fail git symbolic-ref HEAD $(git rev-parse HEAD) + rev=$(git rev-parse HEAD) && + test_must_fail git symbolic-ref HEAD "$rev" ' reset_to_sane diff --git a/t/t2005-checkout-index-symlinks.sh b/t/t2005-checkout-index-symlinks.sh index 112682a45a1..aee80d39221 100755 --- a/t/t2005-checkout-index-symlinks.sh +++ b/t/t2005-checkout-index-symlinks.sh @@ -24,6 +24,6 @@ test -f symlink' test_expect_success \ 'the file must be the blob we added during the setup' ' -test "$(git hash-object -t blob symlink)" = $l' +test_cmp_cmd "$l" git hash-object -t blob symlink' test_done diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh index 5841f280fb2..3e59ffd18a0 100755 --- a/t/t3701-add-interactive.sh +++ b/t/t3701-add-interactive.sh @@ -296,9 +296,12 @@ test_expect_success FILEMODE 'stage mode and hunk' ' echo content >>file && chmod +x file && printf "y\\ny\\n" | git add -p && - git diff --cached file | grep "new mode" && - git diff --cached file | grep "+content" && - test -z "$(git diff file)" + git diff --cached file >out && + grep "new mode" out && + grep "+content" out && + test_must_be_empty out ' # end of tests disabled when filemode is not usable diff --git a/t/t5522-pull-symlink.sh b/t/t5522-pull-symlink.sh index bcff460d0a2..b36dd40e34e 100755 --- a/t/t5522-pull-symlink.sh +++ b/t/t5522-pull-symlink.sh @@ -78,7 +78,7 @@ test_expect_success SYMLINKS 'pushing from symlinked subdir' ' git commit -m push ./file && git push ) && - test push = $(git show HEAD:subdir/file) + test_cmp_cmd push git show HEAD:subdir/file ' test_done diff --git a/t/t7402-submodule-rebase.sh b/t/t7402-submodule-rebase.sh index 277bb8ae520..b27d8da69ee 100755 --- a/t/t7402-submodule-rebase.sh +++ b/t/t7402-submodule-rebase.sh @@ -55,11 +55,11 @@ chmod a+x fake-editor.sh test_expect_success 'interactive rebase with a dirty submodule' ' - test submodule = $(git diff --name-only) && + test_cmp_cmd submodule git diff --name-only && HEAD=$(git rev-parse HEAD) && GIT_EDITOR="\"$(pwd)/fake-editor.sh\"" EDITOR_TEXT="pick $HEAD" \ git rebase -i HEAD^ && - test submodule = $(git diff --name-only) + test_cmp_cmd submodule git diff --name-only ' diff --git a/t/t7504-commit-msg-hook.sh b/t/t7504-commit-msg-hook.sh index a39de8c1126..2b94237f9d1 100755 --- a/t/t7504-commit-msg-hook.sh +++ b/t/t7504-commit-msg-hook.sh @@ -101,7 +101,7 @@ test_expect_success 'setup: commit-msg hook that always fails' ' ' commit_msg_is () { - test "$(git log --pretty=format:%s%b -1)" = "$1" + test_cmp_cmd "$1" git log --pretty=tformat:%s%b -1 } test_expect_success 'with failing hook' ' diff --git a/t/t7516-commit-races.sh b/t/t7516-commit-races.sh index f2ce14e9071..2d38a16480e 100755 --- a/t/t7516-commit-races.sh +++ b/t/t7516-commit-races.sh @@ -10,7 +10,8 @@ test_expect_success 'race to create orphan commit' ' test_must_fail env EDITOR=./hare-editor git commit --allow-empty -m tortoise -e && git show -s --pretty=format:%s >subject && grep hare subject && - test -z "$(git show -s --pretty=format:%P)" + git show -s --pretty=format:%P >out && + test_must_be_empty out ' test_expect_success 'race to create non-orphan commit' ' diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh index 8eded6ab274..232b041b0cf 100755 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@ -1001,7 +1001,7 @@ test_expect_success 'log --committer does not search in timestamp' ' test_expect_success 'grep with CE_VALID file' ' git update-index --assume-unchanged t/t && rm t/t && - test "$(git grep test)" = "t/t:test" && + test_cmp_cmd "t/t:test" git grep test && git update-index --no-assume-unchanged t/t && git checkout t/t '