From patchwork Fri Dec 2 11:52: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: 13062675 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 E180AC4321E for ; Fri, 2 Dec 2022 11:53:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233498AbiLBLxv (ORCPT ); Fri, 2 Dec 2022 06:53:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233030AbiLBLx1 (ORCPT ); Fri, 2 Dec 2022 06:53:27 -0500 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44647D0385 for ; Fri, 2 Dec 2022 03:53:06 -0800 (PST) Received: by mail-ej1-x62f.google.com with SMTP id td2so11003057ejc.5 for ; Fri, 02 Dec 2022 03:53:06 -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=TSL4YVkBl9v4YL3WkETOQZTaX4loOZ85oAtX2cPjg/U=; b=WpH6f3Fq1gYXFt12osznhhIBMi6KOVApLF+/Max5UQ5W5TOvR+sGiFBhWdAQjMEdQU ravyBT45HhED3hBO8cw5E0oThB0LwlAbFCE51yYTr4QxUKJnBGuJEG+GwoPyNGxz5DCT XKXEg1qgwvZMsFq6voVtz6Q8bVRMG1RdQERcBRnlUwB4aXETev/0ZIs/0NPPJTdBVfG5 W6IF3MQnWHDBfvjJoT4kkDjW1ZMOJINXrDSWCKdWq2FWYdOnBYy5SaIa1OxFUJ+9Hr2a nPO364PcjKcPEPkURxjTg4BA5CXIsVkrdzgY8RZH2dYQ9QaMNhy/nsX8qplBEdqsOX19 64Dg== 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=TSL4YVkBl9v4YL3WkETOQZTaX4loOZ85oAtX2cPjg/U=; b=TVkm9NiqvY9cmynrEYmr97bD19Hj/X2H8Up4wvZINNyUuNqQTutFsh5zVBlgrw05BZ nfbsyrXrOjjN+LyjaPVG7EV9xMpxjGrBm2REo3aK1uLckhYmYdbMVCPWrrsIMjkAXv01 h6CiJyFv0VlTwJqipUev5lHewza1Cao+2d4mZ9lcCLtMpN0ybux0fZjmxLakW+HAOxl/ NPn/ueKFUUtKcNTQhVnXLfzz/Soj56yF851Is1pY51MW/ZmEcJ0G8eS3w1Lr1dtaAcM7 Wm6nwt2kn9pSBI7bsi24vJSLtEnbhg88YD+fLfOPdGp+k6KWqw+DpT0qZI8EMFm0eEFD XeTw== X-Gm-Message-State: ANoB5pl64KhLUR6R6a8HnN/CCjkLcTNYT9z81wg0LxrTISFEJaU/Eht0 llwpJn8ZaPWxBKfRk/xsaolVf9saJxI1gw== X-Google-Smtp-Source: AA0mqf7wj4fIXRGhncD3yZWCBM2181WZdUesfjAfi2nSN6W8O2T27UEex2wV5HZLcQR6nuQyS10fZg== X-Received: by 2002:a17:907:8c8e:b0:78d:4167:cf08 with SMTP id td14-20020a1709078c8e00b0078d4167cf08mr11757687ejc.337.1669981985014; Fri, 02 Dec 2022 03:53:05 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id q20-20020aa7da94000000b00458947539desm2833754eds.78.2022.12.02.03.53.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 03:53:04 -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?q?Torsten_B=C3=B6gershause?= =?utf-8?q?n?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Subject: [PATCH v3 1/8] merge tests: don't ignore "rev-parse" exit code in helper Date: Fri, 2 Dec 2022 12:52:34 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.rc1.981.gf846af54b4b 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". Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t7600-merge.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh index 7c3f6ed9943..060e145957f 100755 --- a/t/t7600-merge.sh +++ b/t/t7600-merge.sh @@ -105,7 +105,7 @@ verify_mergeheads () { test_write_lines "$@" >mergehead.expected && while read sha1 rest do - git rev-parse $sha1 + git rev-parse $sha1 || return 1 done <.git/MERGE_HEAD >mergehead.actual && test_cmp mergehead.expected mergehead.actual } From patchwork Fri Dec 2 11:52:35 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: 13062677 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 926F1C4321E for ; Fri, 2 Dec 2022 11:53:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232678AbiLBLxz (ORCPT ); Fri, 2 Dec 2022 06:53:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233421AbiLBLxc (ORCPT ); Fri, 2 Dec 2022 06:53:32 -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 85663C7D3E for ; Fri, 2 Dec 2022 03:53:08 -0800 (PST) Received: by mail-ej1-x633.google.com with SMTP id gu23so10964037ejb.10 for ; Fri, 02 Dec 2022 03:53:08 -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=r1dDjD/7/CXFHmg2sg4/yoq8+PwRjsbj38fU78LD7E4=; b=hDjcL7PBk0Meut7abH3dLBbEuWG9+s1HP2hrTroXpMH7/BZUIY3CFBFKjNDS+XvABq 6kxCiDSNTv/ik4EErPnNNVutSLFTyhpT2CGEVJAgnYQPE5QfFqTpwnuR9R4T7w9oag0T Acqt/F/HOBv9YWwRdsQr7kgeyw8TSkidttutGlbZPsA/lspuoUQSWVlJFhrb/+BhlLHq xDPE4ATxEN2Xqczy/4taOlHOPTMdBA8F18IEbOM2a1yucoz4qgpgsQCExgVQQPBGkrTi oxGTe+ARgMyo1GyjO3ClQUqWeF1QQlUD+7GWWd81ufbKa2Gji6sYoDLKZu7obAn0ZqNW QsNg== 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=r1dDjD/7/CXFHmg2sg4/yoq8+PwRjsbj38fU78LD7E4=; b=NF/Bn8mIwg3zDiLmZ93iajJiaCF7jrhsIYFFATs7ZDyjkqtYzeeSZtMZWys7d7qs0a M8MWR6e3ELwHpjgolYLysON6WKtTW/RCvLS8q9g1xi54u8PnnvhGWW0rpLY/Dbp8VRcs QC+Wqwig6lyro6vod6jDxC3btkkZHC48iVW88ALOPowETtGLeQ7zm3OmTfs7tKmeHaGH eBPgKg/g4JsYBkR0Qf8WYKTYBh+HnRSJH1SxYuzDCGWia9zFCT5jbNMbDEQnhsijJZ3s FatQ2146+pnp+b/81Ukx+Wjm14SdXx5C0yQRnJWigb78h0CR6pGRJrLqbS2u81jFPfGF Ctyg== X-Gm-Message-State: ANoB5pliKx1XA159QhmQsKAwFNCtxkxCKpqCz7+CpJp0CcqC1GgWRPkQ FBlWOPQTmeVZq/MRU7rdA8AqmnqsZq32kA== X-Google-Smtp-Source: AA0mqf7E4S3A7jxVTo6FKo4H+vq2OewuuAgRA3j+o5qs29RhBLL55c7sa2LWwYPLIENP/fXIq2fwjQ== X-Received: by 2002:a17:906:9f10:b0:7ad:86f9:1d70 with SMTP id fy16-20020a1709069f1000b007ad86f91d70mr38434327ejc.179.1669981986533; Fri, 02 Dec 2022 03:53:06 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id q20-20020aa7da94000000b00458947539desm2833754eds.78.2022.12.02.03.53.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 03:53:05 -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?q?Torsten_B=C3=B6gershause?= =?utf-8?q?n?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Subject: [PATCH v3 2/8] auto-crlf tests: don't lose exit code in loops and outside tests Date: Fri, 2 Dec 2022 12:52:35 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.rc1.981.gf846af54b4b In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change the functions which are called from within "test_expect_success" to add the "|| return 1" idiom to their for-loops, so we won't lose the exit code of "cp", "git" etc. Then for those setup functions that aren't called from a "test_expect_success" we need to put the setup code in a "test_expect_success" as well. It would not be enough to properly &&-chain these, as the calling code is the top-level script itself. As we don't run the tests with "set -e" we won't report failing commands at the top-level. The "checkout" part of this would miss 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". Helped-by: René Scharfe Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t0027-auto-crlf.sh | 60 +++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh index a94ac1eae37..23f2e613401 100755 --- a/t/t0027-auto-crlf.sh +++ b/t/t0027-auto-crlf.sh @@ -70,7 +70,8 @@ create_NNO_MIX_files () { cp CRLF ${pfx}_CRLF.txt && cp CRLF_mix_LF ${pfx}_CRLF_mix_LF.txt && cp LF_mix_CR ${pfx}_LF_mix_CR.txt && - cp CRLF_nul ${pfx}_CRLF_nul.txt + cp CRLF_nul ${pfx}_CRLF_nul.txt || + return 1 done done done @@ -101,7 +102,8 @@ commit_check_warn () { do fname=${pfx}_$f.txt && cp $f $fname && - git -c core.autocrlf=$crlf add $fname 2>"${pfx}_$f.err" + git -c core.autocrlf=$crlf add $fname 2>"${pfx}_$f.err" || + return 1 done && git commit -m "core.autocrlf $crlf" && check_warning "$lfname" ${pfx}_LF.err && @@ -121,15 +123,19 @@ commit_chk_wrnNNO () { lfmixcr=$1 ; shift crlfnul=$1 ; shift pfx=NNO_attr_${attr}_aeol_${aeol}_${crlf} - #Commit files on top of existing file - create_gitattributes "$attr" $aeol && - for f in LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul - do - fname=${pfx}_$f.txt && - cp $f $fname && - printf Z >>"$fname" && - git -c core.autocrlf=$crlf add $fname 2>"${pfx}_$f.err" - done + + test_expect_success 'setup commit NNO files' ' + #Commit files on top of existing file + create_gitattributes "$attr" $aeol && + for f in LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul + do + fname=${pfx}_$f.txt && + cp $f $fname && + printf Z >>"$fname" && + git -c core.autocrlf=$crlf add $fname 2>"${pfx}_$f.err" || + return 1 + done + ' test_expect_success "commit NNO files crlf=$crlf attr=$attr LF" ' check_warning "$lfwarn" ${pfx}_LF.err @@ -163,15 +169,19 @@ commit_MIX_chkwrn () { lfmixcr=$1 ; shift crlfnul=$1 ; shift pfx=MIX_attr_${attr}_aeol_${aeol}_${crlf} - #Commit file with CLRF_mix_LF on top of existing file - create_gitattributes "$attr" $aeol && - for f in LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul - do - fname=${pfx}_$f.txt && - cp CRLF_mix_LF $fname && - printf Z >>"$fname" && - git -c core.autocrlf=$crlf add $fname 2>"${pfx}_$f.err" - done + + test_expect_success 'setup commit file with mixed EOL' ' + #Commit file with CLRF_mix_LF on top of existing file + create_gitattributes "$attr" $aeol && + for f in LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul + do + fname=${pfx}_$f.txt && + cp CRLF_mix_LF $fname && + printf Z >>"$fname" && + git -c core.autocrlf=$crlf add $fname 2>"${pfx}_$f.err" || + return 1 + done + ' test_expect_success "commit file with mixed EOL onto LF crlf=$crlf attr=$attr" ' check_warning "$lfwarn" ${pfx}_LF.err @@ -294,12 +304,10 @@ 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 - else - git -c core.eol=$ceol checkout -- crlf_false_attr__$f.txt - fi + test_expect_success "setup $f checkout ${ceol:+ with -c core.eol=$ceol}" ' + rm -f crlf_false_attr__$f.txt && + git ${ceol:+-c core.eol=$ceol} checkout -- crlf_false_attr__$f.txt + ' done test_expect_success "ls-files --eol attr=$attr $ident aeol=$aeol core.autocrlf=$crlf core.eol=$ceol" ' From patchwork Fri Dec 2 11:52:36 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: 13062678 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 ED7B3C4321E for ; Fri, 2 Dec 2022 11:53:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232929AbiLBLx5 (ORCPT ); Fri, 2 Dec 2022 06:53:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233311AbiLBLxk (ORCPT ); Fri, 2 Dec 2022 06:53:40 -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 D6ADDD9B09 for ; Fri, 2 Dec 2022 03:53:09 -0800 (PST) Received: by mail-ej1-x62d.google.com with SMTP id vv4so10987678ejc.2 for ; Fri, 02 Dec 2022 03:53:09 -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=mE2Y8Pmxn9TUaxmcHXv+COuBIuBjuU2xHLH8+BlXkks=; b=E4EUyeqV/chBm4FFPP43haUB81LiCZz77Ru67HvXRGdQlFUT3XEmDNVhPKADnMFDEi Lx900cr2Z4MkDvqgLvplxa4pZ8LM5hdU5xSWyikulhms2dtzZkj68Q1l4pYWap1grh6z vYOO0ALPLZIxAf1LxAcjCgCH1gK5AoR0xfGRdNOHf10ZOrHCutYUy++T0q3H2vrOU5BT XOFIEyagqVy5w0yNEMoQoPshbvHv4xh4iK6qpRZtMQrWexKfNhGTOaUE32mOTFXYCvQH TZJXlsZwlPOH32/M256ipxGWxXTj98kRMz1Axy5qGGj7T9xPs7FFgqH0UwfT6ErCaWxK SV/A== 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=mE2Y8Pmxn9TUaxmcHXv+COuBIuBjuU2xHLH8+BlXkks=; b=DZCKedqnntlHdMBufFY0WNZ53ui+RqXNCIcHwR7ZGzoeOkume92WOUONDYj8tQpy8i bMz9JYqjpGVSLU6jzV12xMW0Y9I+KE8QjWIJegOjqpk9HPy3jlLQ+rpftcQGbAI9hgjt w3zGTaRb5xn4ZiiPvUoz+WBUYeyTtET9OvbnZVRoVL2wODk0zp4NxziUyUttzMy8Nuna 9olrtbBLA8yogGL7qfz9JmuDLAyPEpjQ+hoiBMT34gtnGB6W/LY9xkXGQ3Ho0itEXYaX /dyyEULA8AI4Fh8cCgAkIG8RvE7SvpA3yybps4aJ2zwox2denNYyT8aMIwlz3bMTZ0B7 np2w== X-Gm-Message-State: ANoB5plweJzcboEk365+nzxTCA7xQvn+RbBdlrGV2ZLvvQTgQ+7cRz3f U44Dcrxniqtp+WummHEqQr1O0oO6Z2YuJg== X-Google-Smtp-Source: AA0mqf4pZY5YhOzaEPOzer+6AnZ37xWf/Xz1QW5RSLcOMbasNBR7DIODMqPetyve1jq1DLu+nOk8ag== X-Received: by 2002:a17:906:6c87:b0:7c0:cf94:4dd6 with SMTP id s7-20020a1709066c8700b007c0cf944dd6mr315737ejr.95.1669981987834; Fri, 02 Dec 2022 03:53:07 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id q20-20020aa7da94000000b00458947539desm2833754eds.78.2022.12.02.03.53.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 03:53:06 -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?q?Torsten_B=C3=B6gershause?= =?utf-8?q?n?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Subject: [PATCH v3 3/8] diff tests: fix ignored exit codes in t4023 Date: Fri, 2 Dec 2022 12:52:36 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.rc1.981.gf846af54b4b 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 11:52:37 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: 13062679 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 3AAEDC47088 for ; Fri, 2 Dec 2022 11:54:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233166AbiLBLyJ (ORCPT ); Fri, 2 Dec 2022 06:54:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233466AbiLBLxl (ORCPT ); Fri, 2 Dec 2022 06:53:41 -0500 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6BADD9B0D for ; Fri, 2 Dec 2022 03:53:09 -0800 (PST) Received: by mail-ej1-x636.google.com with SMTP id b2so10995627eja.7 for ; Fri, 02 Dec 2022 03:53:09 -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=GAiSUBKxQ3Bylc6B68UkXOP6jbmOaBhpyRPzluogRSE=; b=KzmJLZs9drny8zXyyFp1AJ7tWh+gRTOepnnuIuLa+AEQ+4QPMEDV6VO/bRQUvj4O07 0i4AWh5wcNWWxZ0QlZhCItMKqy7vS9PF9L20OpB9Qjn3zEsmeQ28oBM0lrGvlK8OHHAr gCILL6+8/WyTQAsJ1BxgFyRdJqbNlP1p1hZEuQg4H6Gy7s3I7AnOzSD1StD5ZlCIi4aq uC3wUamEEbygRU3vSG09kEX/3joLXKaR1w4EJAutcYSsw9Tvla7Mw/UbessAwoii7xiD +03k9RXqXX5+SdyuCEFHxsSUZJr31imOal+qq+kuVDw+3kDo/Gy2JQgbF2ph/0zPtXFP l1LA== 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=GAiSUBKxQ3Bylc6B68UkXOP6jbmOaBhpyRPzluogRSE=; b=ssAzkytPZaYKX54pvsjQNLIKcp7YYgpy3qJDbGiAuQrZyrDKt6m53YtTkOu28D7wik qmfMWphDJiFn+L5jr+rkOmhcUMigSeOgyu8Bx88Q2BYk/wOCAepgAR3tysCnEXdbm234 IjuJjODS3Y1iyBR68MxGhqKzrJHq0zOOZ7mwRBTR8ABe7gsLsRn4Urb+VI5kO9gDgN6t cXlVuLGyc6ggQbdWfIdjyWpw91tYSQ9mWrsmSAuz2nnKeUGkYtaxPD+AwS8CUTf/Id0q 3Edp2J29BZwD6b3sunK+Jvl6BTMZ0+rRP9FK6Z3+YVvOfk6T/61KrvKPkHDWTzgEGB7y 8Frg== X-Gm-Message-State: ANoB5pmJyUI3sLtuElkMC2mPvsPo99nOXVkZrDrYFBdAQj1ipWdmOJpL DuSbxIrp1dtVxeKg67JwLKKPqn7b2i/gpA== X-Google-Smtp-Source: AA0mqf5TB67wAQl9GhU/hA1/NwMU5SijF2f0xK+ZJ35EVXvMAT83QA22/HzTKMtiulbDIE/4CojAXg== X-Received: by 2002:a17:906:3da2:b0:7ac:a2b7:6c96 with SMTP id y2-20020a1709063da200b007aca2b76c96mr57790504ejh.412.1669981988886; Fri, 02 Dec 2022 03:53:08 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id q20-20020aa7da94000000b00458947539desm2833754eds.78.2022.12.02.03.53.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 03:53:08 -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?q?Torsten_B=C3=B6gershause?= =?utf-8?q?n?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Subject: [PATCH v3 4/8] t/lib-patch-mode.sh: fix ignored exit codes Date: Fri, 2 Dec 2022 12:52:37 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.rc1.981.gf846af54b4b 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". This avoids losing both the exit code of a "git" and the "cat" processes. 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 | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/t/lib-patch-mode.sh b/t/lib-patch-mode.sh index cfd76bf987b..89ca1f78055 100644 --- a/t/lib-patch-mode.sh +++ b/t/lib-patch-mode.sh @@ -29,8 +29,12 @@ set_and_save_state () { # verify_state verify_state () { - test "$(cat "$1")" = "$2" && - test "$(git show :"$1")" = "$3" + echo "$2" >expect && + test_cmp expect "$1" && + + echo "$3" >expect && + git show :"$1" >actual && + test_cmp expect actual } # verify_saved_state @@ -46,5 +50,6 @@ save_head () { } verify_saved_head () { - test "$(cat _head)" = "$(git rev-parse HEAD)" + git rev-parse HEAD >actual && + test_cmp _head actual } From patchwork Fri Dec 2 11:52:38 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: 13062680 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 18409C4321E for ; Fri, 2 Dec 2022 11:54:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233464AbiLBLyQ (ORCPT ); Fri, 2 Dec 2022 06:54:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233426AbiLBLxn (ORCPT ); Fri, 2 Dec 2022 06:53:43 -0500 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1DD0DA20B for ; Fri, 2 Dec 2022 03:53:11 -0800 (PST) Received: by mail-ej1-x630.google.com with SMTP id ud5so11002178ejc.4 for ; Fri, 02 Dec 2022 03:53:11 -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=mi8iuuk0rywVWdRT179rkZRZo0tAqZnale+pE20tPNc=; b=m17v5xoCOCXC69RD/sK8c2to5aQ8gbaPFB3LULEGjjvIRIg+v568WUZJaI6FQZxMyX yuN+6+eM8fnIU8ApdRV8WScFRvCb4KTpZC7E5v5KGizXqhomsSiq0qy/iD2oHygCJI4v WUay13oQAXnlxaQ3n3ime7I30HNKLQmUDDbYsDQVKikS03eIbxn86dc4Y9g8Yy5xLsb3 LaXn8krvJZ52bV8usXMkPPSOVAvpdg5TixvOerjHxJPVcEZk2CD0obfZtRJvvw/oJUWf 57YPcBtjd7540KxgrNP9+gFLU5GSxfSsH+s34iaHbFhtuBLPPtSot7hydvxaKiIFg3jl x+ow== 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=mi8iuuk0rywVWdRT179rkZRZo0tAqZnale+pE20tPNc=; b=TboVV9P/lvYGjW8uSJhCMo6+jYc+Lc2QCRFFrg7Qf+OICDaoAO1pqKSFWlmQamDSoU GzPDdpH6oEXbXBMpivObwX+erevdTZypWg8VsR6E69w/+16ChFxp7urJB9d7WI2tN9er L6eCj3acIjqy8JjYN1Mr5TFWsZx+i1dLemp7cgHLZQV78V/bRDeCdtgaLTO5Nvek3XkH bp5eFTX6lF2cswliXqJC/g9B6aWOQNpH/kq1/vaLuxyXH/OsI+1PzDxINOH7dAkpKZnn JpUCp99dCS0ighpPj8NOzBKuiJnvjCeN28HO6rlWeFqA6D6Nw3/XC3J6ycAma1woLMxd 3fKg== X-Gm-Message-State: ANoB5pk0P8mJFZkg8f8dhgcGwKWLxA2I/2UeKh2bt0Y7SC8g83uYtkzm tNU1816o2Vt7NXl7CP2eS0CCCXh9dIdEDQ== X-Google-Smtp-Source: AA0mqf5nLf2qvw+lA1Ht9XTFHsVrbp9H3vbJuyMxKt+2ZT6E00IG7I4guP8nRQJ21QA+Zx5ISIHYQA== X-Received: by 2002:a17:906:f2cb:b0:78d:e645:9f7d with SMTP id gz11-20020a170906f2cb00b0078de6459f7dmr12854213ejb.572.1669981990049; Fri, 02 Dec 2022 03:53:10 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id q20-20020aa7da94000000b00458947539desm2833754eds.78.2022.12.02.03.53.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 03:53:09 -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?q?Torsten_B=C3=B6gershause?= =?utf-8?q?n?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Subject: [PATCH v3 5/8] tests: use "test_cmp" instead of "test" in sub-shells Date: Fri, 2 Dec 2022 12:52:38 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.rc1.981.gf846af54b4b 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 | 5 +++-- t/lib-submodule-update.sh | 22 +++++++++------------- t/t0060-path-utils.sh | 4 +++- t/t3200-branch.sh | 13 +++++++------ t/t5605-clone-local.sh | 15 ++++++++++----- t/t7402-submodule-rebase.sh | 14 +++++++++++--- 6 files changed, 43 insertions(+), 30 deletions(-) diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh index 608949ea80b..31e7fa3010c 100644 --- a/t/lib-httpd.sh +++ b/t/lib-httpd.sh @@ -217,8 +217,9 @@ 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)) + echo "$HEAD" >expect && + git -C "$REMOTE_REPO" rev-parse --verify HEAD >actual && + test_cmp expect actual ' 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 2d31fcfda1f..d7c2b670b4a 100644 --- a/t/lib-submodule-update.sh +++ b/t/lib-submodule-update.sh @@ -168,20 +168,16 @@ 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? + echo "../../../$1" >expect && + git -C ".git/modules/$1" config core.worktree >actual && + test_cmp expect actual && + # 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/t0060-path-utils.sh b/t/t0060-path-utils.sh index 68e29c904a6..53ec717cbca 100755 --- a/t/t0060-path-utils.sh +++ b/t/t0060-path-utils.sh @@ -255,7 +255,9 @@ 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")" + echo "a" >expect && + test-tool -C repo path-utils prefix_path prefix "$(cd repo && pwd)/../repolink/a" >actual && + test_cmp expect actual ' relative_path /foo/a/b/c/ /foo/a/b/ c/ diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index 5a169b68d6a..f5fbb84262b 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -242,12 +242,13 @@ 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 && + echo "bam" >expect && + git -C "$bazdir" rev-parse --abbrev-ref HEAD >actual && + test_cmp expect actual && + echo "bam" >expect && + git rev-parse --abbrev-ref HEAD >actual && + test_cmp expect actual && rm -r bazdir && git worktree prune ' diff --git a/t/t5605-clone-local.sh b/t/t5605-clone-local.sh index 38b850c10ef..61a2342bc2c 100755 --- a/t/t5605-clone-local.sh +++ b/t/t5605-clone-local.sh @@ -15,8 +15,12 @@ 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 && + echo true >expect && + git -C a.git config --bool core.bare >actual && + test_cmp expect actual && + echo true >expect && + git -C x config --bool core.bare >actual && + test_cmp expect actual && git bundle create b1.bundle --all && git bundle create b2.bundle main && mkdir dir && @@ -28,9 +32,10 @@ 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) + echo false >expect && + git -C b config --bool core.bare >actual && + test_cmp expect actual && + 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..1927a862839 100755 --- a/t/t7402-submodule-rebase.sh +++ b/t/t7402-submodule-rebase.sh @@ -82,11 +82,19 @@ 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) && + echo submodule >expect && + git diff --name-only >actual && + test_cmp expect actual && + + echo "$CURRENT" >expect && + git -C submodule rev-parse HEAD >actual && + test_cmp expect actual && + git stash apply && test new = $(cat file) && - test $CURRENT = $(cd submodule && git rev-parse HEAD) + echo "$CURRENT" >expect && + git -C submodule rev-parse HEAD >actual && + test_cmp expect actual ' From patchwork Fri Dec 2 11:52:39 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: 13062682 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 6395DC4321E for ; Fri, 2 Dec 2022 11:54:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232681AbiLBLyW (ORCPT ); Fri, 2 Dec 2022 06:54:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233480AbiLBLxp (ORCPT ); Fri, 2 Dec 2022 06:53:45 -0500 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D7A6DA235 for ; Fri, 2 Dec 2022 03:53:13 -0800 (PST) Received: by mail-ed1-x530.google.com with SMTP id v8so6192968edi.3 for ; Fri, 02 Dec 2022 03:53:13 -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=nJAWn+iZVAGenRihLJmMfN2Ec79LFx9cOLLMHOiPafU=; b=g91Edx5rdp2m8IkyxAusnjvw/R3jL3Pvs8GVPGAubkr6lExTv6LAZ8b5r7Q4n99G8W wRraAwjM124aRwWFz+rP4kPq65myo85LafO5JbVUUNXzgSLhUA2oRgOCzMkC8gIba7+Q QOgtwJQxgODesc3zg5wS+l16rn6J1sHfHMbQHQd6asUYhdsIxnDg+TmLxpAvyM9yTj3J rVy+VNmgZ6BkWFznDB73hMJ17xO549oHcCCx1VkrXgUnQnS6JrRbI2G+yuTDAOYHV1g2 L17QekQ34EyGN0lC6AGD9F0LJ04+a6/31I5ugsrk9zaY8mUPepB0axF5qV7bUNd+TwK7 OBhg== 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=nJAWn+iZVAGenRihLJmMfN2Ec79LFx9cOLLMHOiPafU=; b=tLuVHTnHJu+FftGZ0jbf5Necxb0Q94TQteK8mnp0BvS06XCLZaFTHCHb/sSIxx3m9T cTLLdyRCSDzrtrdsOe38O2RaomCHJb0dEGCsYQfS3KdshTKQRWTe+ITgracA4Nnkrhk5 ofzbdNZlk0xnf1cr7e8wd0WPtvb7FD8RHV97W4qxgkeR/i4rim6fRWUsK39l1xDnHSsc xuo6XjTV8R1lSqkuaUjRfDH+vc6GN/LmH7KGWaL5o21NOUChW7Oz59CE94h04obGwqwv ZXdfFO1qM/MAcHEZXHiORxllXscoxd9JEyKubObi00AtNDHYq3tugcxklKrH9q3RZjyA 2uyQ== X-Gm-Message-State: ANoB5pnygUD8OEmiAzwpJOxH2aL4QF9l3y5XjFJKH9ZOlZL4cknSntZC g/paJKnPuGlfWQ+YM+/ghU+l3yyrLzUdEA== X-Google-Smtp-Source: AA0mqf6cPrkaVSAufB1Ku3WEG22mTWRoGKnrrKxtZSSsH1dH6y8pWWoy/pru056rVdVVduEgnSwxAg== X-Received: by 2002:a05:6402:448c:b0:461:7378:3501 with SMTP id er12-20020a056402448c00b0046173783501mr45954674edb.35.1669981991191; Fri, 02 Dec 2022 03:53:11 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id q20-20020aa7da94000000b00458947539desm2833754eds.78.2022.12.02.03.53.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 03:53:10 -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?q?Torsten_B=C3=B6gershause?= =?utf-8?q?n?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Subject: [PATCH v3 6/8] tests: don't lose 'test = $(cmd ...)"' exit code Date: Fri, 2 Dec 2022 12:52:39 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.rc1.981.gf846af54b4b In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Convert some cases in the test suite where we'd lose the exit code of a command being interpolated as one of the arguments to the "test" builtin function to use &&-chaining and "test_cmp" instead. This way we won't lose the exit code, and the failure output will be more helpful. In the case of "t0060-path-utils.sh" and "t2005-checkout-index-symlinks.sh" convert the relevant code to using the modern style of indentation and newline wrapping while having to change it. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/lib-submodule-update.sh | 4 +- t/t0001-init.sh | 9 ++- t/t0002-gitfile.sh | 4 +- t/t0060-path-utils.sh | 103 +++++++++++++++++++++-------- t/t0100-previous.sh | 8 ++- t/t1504-ceiling-dirs.sh | 8 ++- t/t2005-checkout-index-symlinks.sh | 8 ++- t/t5522-pull-symlink.sh | 4 +- t/t7402-submodule-rebase.sh | 9 ++- t/t7504-commit-msg-hook.sh | 4 +- t/t7810-grep.sh | 4 +- 11 files changed, 120 insertions(+), 45 deletions(-) diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh index d7c2b670b4a..dee14992c52 100644 --- a/t/lib-submodule-update.sh +++ b/t/lib-submodule-update.sh @@ -185,7 +185,9 @@ 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" + echo "../../../$1" >expect && + git -C ".git/modules/$1" config core.worktree >actual && + test_cmp expect actual fi } diff --git a/t/t0001-init.sh b/t/t0001-init.sh index d479303efa0..30a6edca1d2 100755 --- a/t/t0001-init.sh +++ b/t/t0001-init.sh @@ -598,9 +598,14 @@ 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) && + echo renamed >expect && + git -C rename-initial symbolic-ref --short HEAD >actual && + test_cmp expect actual && + git -C rename-initial branch -m renamed again && - test again = $(git -C rename-initial symbolic-ref --short HEAD) + echo again >expect && + git -C rename-initial symbolic-ref --short HEAD >actual && + test_cmp expect actual ' test_done diff --git a/t/t0002-gitfile.sh b/t/t0002-gitfile.sh index 26eaca095a2..e013d38f485 100755 --- a/t/t0002-gitfile.sh +++ b/t/t0002-gitfile.sh @@ -33,7 +33,9 @@ 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)" + echo "$REAL" >expect && + git rev-parse --git-dir >actual && + test_cmp expect actual ' test_expect_success 'check hash-object' ' diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh index 53ec717cbca..6490ad5ca1b 100755 --- a/t/t0060-path-utils.sh +++ b/t/t0060-path-utils.sh @@ -10,20 +10,27 @@ 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" " + echo '$expected' >expect && + test-tool path-utils normalize_path_copy '$1' >actual && + test_cmp expect actual + " } 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" " + echo '$expected' >expect && + test-tool path-utils relative_path '$1' '$2' >actual && + test_cmp expect actual + " } 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' + echo '$4' >expect && + test-tool submodule resolve-relative-url '$1' '$2' '$3' >actual && + test_cmp expect actual " } @@ -64,9 +71,11 @@ 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" " + echo '$expected' >expect && + test-tool path-utils longest_ancestor_length '$1' '$2' >actual && + test_cmp expect actual + " } # Some absolute path tests should be skipped on Windows due to path mangling @@ -166,8 +175,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' ' @@ -188,35 +199,61 @@ test_expect_success 'real path rejects the empty string' ' ' test_expect_success POSIX 'real path works on absolute paths 1' ' + echo / >expect && + test-tool path-utils real_path "/" >actual && + test_cmp expect actual && + nopath="hopefully-absent-path" && - test "/" = "$(test-tool path-utils real_path "/")" && - test "/$nopath" = "$(test-tool path-utils real_path "/$nopath")" + echo "/$nopath" >expect && + test-tool path-utils real_path "/$nopath" >actual && + test_cmp expect actual ' 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")" + echo "$d" >expect && + test-tool path-utils real_path "$d" >actual && + test_cmp expect actual && + + nopath="hopefully-absent-path" && + echo "$d/$nopath" >expect && + test-tool path-utils real_path "$d/$nopath" >actual && + test_cmp expect actual ' test_expect_success POSIX 'real path removes extra leading slashes' ' + echo "/" >expect && + test-tool path-utils real_path "///" >actual && + test_cmp expect actual && + nopath="hopefully-absent-path" && - test "/" = "$(test-tool path-utils real_path "///")" && - test "/$nopath" = "$(test-tool path-utils real_path "///$nopath")" && + echo "/$nopath" >expect && + test-tool path-utils real_path "///$nopath" >actual && + test_cmp expect actual && + # 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")" + echo "$d" >expect && + test-tool path-utils real_path "//$d" >actual && + test_cmp expect actual && + + echo "$d/$nopath" >expect && + test-tool path-utils real_path "//$d/$nopath" >actual && + test_cmp expect actual ' 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")" + echo "$d" >expect && + test-tool path-utils real_path "$d///" >actual && + test_cmp expect actual && + + nopath="hopefully-absent-path" && + echo "$d/$nopath" >expect && + test-tool path-utils real_path "$d///$nopath" >actual && + test_cmp expect actual ' test_expect_success SYMLINKS 'real path works on symlinks' ' @@ -227,19 +264,29 @@ 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)" && + echo "$dir" >expect && + test-tool path-utils real_path $dir2 >actual && + test_cmp expect actual && file="$dir"/index && - test "$file" = "$(test-tool path-utils real_path $dir2/index)" && + echo "$file" >expect && + test-tool path-utils real_path $dir2/index >actual && + test_cmp expect actual && basename=blub && - test "$dir/$basename" = "$(cd .git && test-tool path-utils real_path "$basename")" && + echo "$dir/$basename" >expect && + test-tool -C .git path-utils real_path "$basename" >actual && + test_cmp expect actual && ln -s ../first/file .git/syml && sym="$(cd first && pwd -P)"/file && - test "$sym" = "$(test-tool path-utils real_path "$dir2/syml")" + echo "$sym" >expect && + test-tool path-utils real_path "$dir2/syml" >actual && + test_cmp expect actual ' 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" + echo "symlink" >expect && + test-tool path-utils prefix_path prefix "$(pwd)/symlink" >actual && + test_cmp expect actual ' test_expect_success 'prefix_path works with only absolute path to work tree' ' diff --git a/t/t0100-previous.sh b/t/t0100-previous.sh index a16cc3d2983..70a3223f219 100755 --- a/t/t0100-previous.sh +++ b/t/t0100-previous.sh @@ -12,7 +12,9 @@ test_expect_success 'branch -d @{-1}' ' test_commit A && git checkout -b junk && git checkout - && - test "$(git symbolic-ref HEAD)" = refs/heads/main && + echo refs/heads/main >expect && + git symbolic-ref HEAD >actual && + test_cmp expect actual && git branch -d @{-1} && test_must_fail git rev-parse --verify refs/heads/junk ' @@ -21,7 +23,9 @@ 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 && + echo refs/heads/main >expect && + git symbolic-ref HEAD >actual && + test_cmp expect actual && 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..c1679e31d8a 100755 --- a/t/t1504-ceiling-dirs.sh +++ b/t/t1504-ceiling-dirs.sh @@ -6,8 +6,12 @@ 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'" ' + echo "$expect" >expect && + git rev-parse --show-prefix >actual && + test_cmp expect actual + ' } test_fail() { diff --git a/t/t2005-checkout-index-symlinks.sh b/t/t2005-checkout-index-symlinks.sh index 112682a45a1..67d18cfa104 100755 --- a/t/t2005-checkout-index-symlinks.sh +++ b/t/t2005-checkout-index-symlinks.sh @@ -22,8 +22,10 @@ test_expect_success \ git checkout-index symlink && 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_expect_success 'the file must be the blob we added during the setup' ' + echo "$l" >expect && + git hash-object -t blob symlink >actual && + test_cmp expect actual +' test_done diff --git a/t/t5522-pull-symlink.sh b/t/t5522-pull-symlink.sh index bcff460d0a2..9fb73a8c3eb 100755 --- a/t/t5522-pull-symlink.sh +++ b/t/t5522-pull-symlink.sh @@ -78,7 +78,9 @@ test_expect_success SYMLINKS 'pushing from symlinked subdir' ' git commit -m push ./file && git push ) && - test push = $(git show HEAD:subdir/file) + echo push >expect && + git show HEAD:subdir/file >actual && + test_cmp expect actual ' test_done diff --git a/t/t7402-submodule-rebase.sh b/t/t7402-submodule-rebase.sh index 1927a862839..c74798e8d24 100755 --- a/t/t7402-submodule-rebase.sh +++ b/t/t7402-submodule-rebase.sh @@ -55,12 +55,15 @@ chmod a+x fake-editor.sh test_expect_success 'interactive rebase with a dirty submodule' ' - test submodule = $(git diff --name-only) && + echo submodule >expect && + git diff --name-only >actual && + test_cmp expect actual && 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) - + echo submodule >expect && + git diff --name-only >actual && + test_cmp expect actual ' test_expect_success 'rebase with dirty file and submodule fails' ' diff --git a/t/t7504-commit-msg-hook.sh b/t/t7504-commit-msg-hook.sh index a39de8c1126..c0f024eb1ef 100755 --- a/t/t7504-commit-msg-hook.sh +++ b/t/t7504-commit-msg-hook.sh @@ -101,7 +101,9 @@ test_expect_success 'setup: commit-msg hook that always fails' ' ' commit_msg_is () { - test "$(git log --pretty=format:%s%b -1)" = "$1" + printf "%s" "$1" >expect && + git log --pretty=format:%s%b -1 >actual && + test_cmp expect actual } test_expect_success 'with failing hook' ' diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh index 8eded6ab274..39d6d713ecb 100755 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@ -1001,7 +1001,9 @@ 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" && + echo "t/t:test" >expect && + git grep test >actual && + test_cmp expect actual && git update-index --no-assume-unchanged t/t && git checkout t/t ' From patchwork Fri Dec 2 11:52:40 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: 13062681 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 97D2CC4321E for ; Fri, 2 Dec 2022 11:54:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232596AbiLBLyT (ORCPT ); Fri, 2 Dec 2022 06:54:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233403AbiLBLxp (ORCPT ); Fri, 2 Dec 2022 06:53:45 -0500 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59C0FD9B21 for ; Fri, 2 Dec 2022 03:53:14 -0800 (PST) Received: by mail-ed1-x534.google.com with SMTP id e13so6124465edj.7 for ; Fri, 02 Dec 2022 03:53:14 -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=XfbtzD8BT1K9zuz35n8QiIE4xf1kJm8lA2E3lAkToe0=; b=KjmeYsIiRbguFdpGsLKlnc5UtJ/qTeJyHkud1xvp8cWIk93r0ZdrhvWjkWruypAdQ3 y/lYvRRPTf1ljwElcyQaIggaOXd9gxSwbQli7DGeB7zPZbxxUpkKHufuZhRGMsaLkZ2L pKVICIASIQQ96kB4ErGX+mzuIdY0C1aYErUXoCFtQvzB3Ol7BrygUY5QXMN9US/6dXeO m8+hnrQAyDEh/us+uDEY2T8JC0bVtv0rJVl3Oe10rcKxm8CoyWsRUqMyNaoGA8V2MCdL TqHqEdlQ48Xc+0vwy0NahmjYXi+Ga85zQnTuShPGYEuNFCHYN1heavsea0HRsY1ilLQP EpNg== 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=XfbtzD8BT1K9zuz35n8QiIE4xf1kJm8lA2E3lAkToe0=; b=WGexHz/4a5IQGt5aKpwAqsPJngCmoSNQuJKl2ygUDOCsMII+HXoaLSaP4J1UB6Gq5E GD46GC08pt6EYXYcJ6/I4cuEnOd57ChZVAic1890NZj5h8Nfsm26IZvFrfeMOc+lxo2r iwqtXaZuUj716kILzgO1w4QmRp3N82KBMYwtElTWA4ULN1HTzeTQh8iT3OOphhdveKDe KLHzZHhTShZlOhCguBKycXPHglvolgyknRsKoj6MskHs+Pn3OVVMquQoNZHjaFYnFYnP ENDio+gYnr7KXMSnOMTjzF++1j4ylGX0GZrPId1w+8qVeVaO6DFSQeqof/ey9qLiOsf4 xdTw== X-Gm-Message-State: ANoB5pnwUR9P2v42obJnEez9FytgQnB/WdiRn4GPU43y5sENZVxUpr/h tgvIUhZyHOqGITzxl++Di2kP1p/WbZXJOQ== X-Google-Smtp-Source: AA0mqf6nag/Sjslmk0aQYblAKPmgimxbu+rkA/E9Puei6msuPuXqqiBgNJftq/9oUIIGZ6VNNmtMvA== X-Received: by 2002:a05:6402:143:b0:463:f8aa:d2bf with SMTP id s3-20020a056402014300b00463f8aad2bfmr64460796edu.358.1669981992474; Fri, 02 Dec 2022 03:53:12 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id q20-20020aa7da94000000b00458947539desm2833754eds.78.2022.12.02.03.53.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 03:53:11 -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?q?Torsten_B=C3=B6gershause?= =?utf-8?q?n?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Subject: [PATCH v3 7/8] tests: don't lose "git" exit codes in "! ( git ... | grep )" Date: Fri, 2 Dec 2022 12:52:40 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.rc1.981.gf846af54b4b In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change tests that would lose the "git" exit code via a negation pattern to: - In the case of "t0055-beyond-symlinks.sh" compare against the expected output instead. - For "t3700-add.sh" use "sed -n" to print the expected "bad" part, and use "test_must_be_empty" to assert that it's not there. We can also remove a repeated invocation of "git ls-files" for the last test that's being modified in that file, and search the existing "files" output instead. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t0055-beyond-symlinks.sh | 14 ++++++++++++-- t/t3700-add.sh | 18 +++++++++++++----- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/t/t0055-beyond-symlinks.sh b/t/t0055-beyond-symlinks.sh index 6bada370225..c3eb1158ef9 100755 --- a/t/t0055-beyond-symlinks.sh +++ b/t/t0055-beyond-symlinks.sh @@ -15,12 +15,22 @@ test_expect_success SYMLINKS setup ' test_expect_success SYMLINKS 'update-index --add beyond symlinks' ' test_must_fail git update-index --add c/d && - ! ( git ls-files | grep c/d ) + cat >expect <<-\EOF && + a + b/d + EOF + git ls-files >actual && + test_cmp expect actual ' test_expect_success SYMLINKS 'add beyond symlinks' ' test_must_fail git add c/d && - ! ( git ls-files | grep c/d ) + cat >expect <<-\EOF && + a + b/d + EOF + git ls-files >actual && + test_cmp expect actual ' test_done diff --git a/t/t3700-add.sh b/t/t3700-add.sh index 51afbd7b24a..82dd768944f 100755 --- a/t/t3700-add.sh +++ b/t/t3700-add.sh @@ -106,24 +106,32 @@ test_expect_success '.gitignore test setup' ' test_expect_success '.gitignore is honored' ' git add . && - ! (git ls-files | grep "\\.ig") + git ls-files >files && + sed -n "/\\.ig/p" actual && + test_must_be_empty actual ' test_expect_success 'error out when attempting to add ignored ones without -f' ' test_must_fail git add a.?? && - ! (git ls-files | grep "\\.ig") + git ls-files >files && + sed -n "/\\.ig/p" actual && + test_must_be_empty actual ' test_expect_success 'error out when attempting to add ignored ones without -f' ' test_must_fail git add d.?? && - ! (git ls-files | grep "\\.ig") + git ls-files >files && + sed -n "/\\.ig/p" actual && + test_must_be_empty actual ' test_expect_success 'error out when attempting to add ignored ones but add others' ' touch a.if && test_must_fail git add a.?? && - ! (git ls-files | grep "\\.ig") && - (git ls-files | grep a.if) + git ls-files >files && + sed -n "/\\.ig/p" actual && + test_must_be_empty actual && + grep a.if files ' test_expect_success 'add ignored ones with -f' ' From patchwork Fri Dec 2 11:52:41 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: 13062683 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 DFCABC47089 for ; Fri, 2 Dec 2022 11:54:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233470AbiLBLyX (ORCPT ); Fri, 2 Dec 2022 06:54:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233483AbiLBLxp (ORCPT ); Fri, 2 Dec 2022 06:53:45 -0500 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7084EDB0D4 for ; Fri, 2 Dec 2022 03:53:15 -0800 (PST) Received: by mail-ed1-x532.google.com with SMTP id z92so6207094ede.1 for ; Fri, 02 Dec 2022 03:53:15 -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=u26/GgRncCCQAQgiu+8EgkFKc4okja08HT3aHmInaZ4=; b=YMn+NcXRWuaNoiwWDwxNIZjolZjiwrRsDveKgUq1y95polWYd+EI4p2cmzYcXQ/nvF Wfby3r3T1zEEsM5gGHVQ8HVVHlYRNuHQdpbQdDvIwq9k6f1+pME3nip8KohkiE2kd/Qe AlK97EDjrD15vdYhOqO4QTTy++nOw1BHahhQWSKzzh45rUk4kCFC9p89he9LBaCTvh04 VQoAMURGhKTKC7JtzFGTlzdPDagRuWJyt1UnTojDDECGM4H1kEnlT+/zIzBsbSJXRsMU j3vuly4Z91vJ7fD05miAOqOXf9FASeiecxi9jIC2fI0rBVofW/O2MEWdripyw5G5ZIsy YURQ== 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=u26/GgRncCCQAQgiu+8EgkFKc4okja08HT3aHmInaZ4=; b=1s32Mm9eJwivII0uANOSwnCDc8exmldpa/8zGDuwrg/QyrpSm09NQr4aK45bTdfTJo NLZoxgZ+yEkx90A4/mcbfyHaJFSX/tS14axZeckQtsE5NIAfnMSLXU9ini7oPdu2mxi6 s89F/3SJrz6Df62WJ2GNMaEcLWarbnr3ONpr3ezZb+pFAkiqJYJD88Eaa6aCEfW+lu4R 7FugPxdW7ER6zQvcfYwZYjnxhXw64IVZBYhMs2nUHzy2m52TsvrxrT+EHthMHuQD8r6G ptwVbq748GazB1iL3XeYqubtD95vpCZLMkLSaOXHdLqe5G3ZU5ty9Ao9S0KvF+Ar5dUx SDJQ== X-Gm-Message-State: ANoB5pmp+wQj/OlXhZQtCmCinGju8tk5en+cHea7kcnqZpkgq7OhVinq pZEFbc60KoUAdCiiFOMLWVVY/OmvjxxmyQ== X-Google-Smtp-Source: AA0mqf5eH2WN5Mn/+nCV2BiAffGS3SfuEmMOOF7WaCMpE9b1G3pPAxDQ0OmPSuJqZVbBI7QNihqXww== X-Received: by 2002:aa7:ca54:0:b0:46b:5f6f:a303 with SMTP id j20-20020aa7ca54000000b0046b5f6fa303mr17811283edt.110.1669981993667; Fri, 02 Dec 2022 03:53:13 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id q20-20020aa7da94000000b00458947539desm2833754eds.78.2022.12.02.03.53.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 03:53:12 -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?q?Torsten_B=C3=B6gershause?= =?utf-8?q?n?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Subject: [PATCH v3 8/8] tests: don't lose mist "git" exit codes Date: Fri, 2 Dec 2022 12:52:41 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.rc1.981.gf846af54b4b In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Fix a few miscellaneous cases where: - We lost the "git" exit code via "git ... | grep" - Likewise by having a $(git) argument to git itself - Used "test -z" to check that a command emitted no output, we can use "test_must_be_empty" and &&-chaining instead. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t1401-symbolic-ref.sh | 3 ++- t/t3701-add-interactive.sh | 8 +++++--- t/t7516-commit-races.sh | 3 ++- 3 files changed, 9 insertions(+), 5 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/t3701-add-interactive.sh b/t/t3701-add-interactive.sh index 5841f280fb2..f1fe5d60677 100755 --- a/t/t3701-add-interactive.sh +++ b/t/t3701-add-interactive.sh @@ -296,9 +296,11 @@ 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 && + git diff file >out && + test_must_be_empty out ' # end of tests disabled when filemode is not usable 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' '