From patchwork Tue Apr 20 12:21:52 2021 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: 12214111 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65BE9C433ED for ; Tue, 20 Apr 2021 12:22:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 25F9C613C5 for ; Tue, 20 Apr 2021 12:22:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231393AbhDTMWl (ORCPT ); Tue, 20 Apr 2021 08:22:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231773AbhDTMWl (ORCPT ); Tue, 20 Apr 2021 08:22:41 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 991EBC06174A for ; Tue, 20 Apr 2021 05:22:09 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id k26so20969629wrc.8 for ; Tue, 20 Apr 2021 05:22:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9Zt4mTy7ptiU6X+xKENr0MX+oJpAnPVNmt7f8N0ZNKo=; b=lXB+zb45eMLmnbnuCOgGJncZFR0LLlcsrfk2+qcZfCsnC7YqC3ZEyFyXT4UKfZfw4K vHGeUPyotEnEXc17kiNEb95CmKofJTtRh9NlV1OENm/yYY41yEradAfQvMuOXpiflTVV mstzbTth2Xn0iXp1Ek+j5hakDBcs1D7kslLGFSXq2/l8+Eme+Pg/alJUbDEI+E3948Ps 5hEIDPXTU5YCMvQrJwhq4FmiUAMnkgBVXHYhlKBTP6yg+s4i4TRTFpnGQOuColJuuDNf D0fHOUmABe9hz6mYUdIX/xZ2Q2IsDCzxtkqb+L1w7HU0jjvCZYbrftOI212GonJ+0r3+ xr0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9Zt4mTy7ptiU6X+xKENr0MX+oJpAnPVNmt7f8N0ZNKo=; b=Fg/Z9usYzGIF1500DkqhVpNZRQmt5cEZy/YNcNQ4Yt4WKzvIaWj8M4I9wTcq9StgOd P3Rdc8hpkzsfYZpVEXZ9+TOVGKw4tqju7mIFdiBA6qKFPbftEnVidtcglikkk/RTN8VV H68DLpfbs9Qlb0TvP7Tjzhflgo6MvrPcKfw7p5ErThXhpUc69/cC34WFZXg/o0ARy+f/ /RN0JJSNDnp0Oi1nDmoFnWeyCwDoWr4aHEUqYEF5qgEDbE1UpPoYHvcRDBxaO4vxlugU HQI7nv+pN9epUNNaHY+CO2n+rOYq1oOFiqbUQ7axc52fuwmlm+uJUGBUGVphQVNxZKCi xQiA== X-Gm-Message-State: AOAM5301weAA9bcQs5mEi2SDoyuqhYtMu4ZMrpk+/rfSYD4dBtDBxE6q tvBpqNO2iUytyKsFXK4FlTRwvi11vpaVGA== X-Google-Smtp-Source: ABdhPJz0ZxQymGQmdEzsWaB34XLU9vdA1ehd2KUX33xLIcTeiR2frsaJ+XLdLf4Vl3owKSBEwKVLFQ== X-Received: by 2002:adf:e7c2:: with SMTP id e2mr20965607wrn.248.1618921328082; Tue, 20 Apr 2021 05:22:08 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b1sm30541768wru.90.2021.04.20.05.22.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 05:22:07 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Matthieu Moy , Johannes Schindelin , Eric Sunshine , =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7Ru?= =?utf-8?b?ZyBEYW5o?= , =?utf-8?q?SZEDER_G=C3=A1bor?= , =?utf-8?b?w4Z2YXIg?= =?utf-8?b?QXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v3 01/12] check-non-portable-shell: check for "test -a/-o " Date: Tue, 20 Apr 2021 14:21:52 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.723.gf6bad1b9ba1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add a check for -a/-o in "test", as a follow-up to the CodingGuidelines having recommended against their use since 897f964c0dc (CodingGuidelines: avoid "test -a/-o ", 2014-05-20). These constructs are considered obsolescent by POSIX[1]. GNU has likewise warned against them[2] for a few decades. These will only match the simplistic forms of `test -X blah` (where "-X" is some single letter option), but will miss expressions such as `test "$foo" = bar`. We stop at "&" or "|" to try not to overmatch things like: test whatever && ls -a foo test whatever && foo -o outfile 1. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html#tag_20_128_16 2. https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.70/html_node/Limitations-of-Builtins.html Signed-off-by: Ævar Arnfjörð Bjarmason --- t/check-non-portable-shell.pl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/t/check-non-portable-shell.pl b/t/check-non-portable-shell.pl index fd3303552b..894aa0a4f9 100755 --- a/t/check-non-portable-shell.pl +++ b/t/check-non-portable-shell.pl @@ -41,6 +41,8 @@ sub err { /^\s*declare\s+/ and err 'arrays/declare not portable'; /^\s*[^#]\s*which\s/ and err 'which is not portable (use type)'; /\btest\s+[^=]*==/ and err '"test a == b" is not portable (use =)'; + /\btest\s+-[a-z]\s+[^&|]+\s+-a\s+/ and err '"test A && test B" preferred to "test A -a B"'; + /\btest\s+-[a-z]\s+[^&|]+\s+-o\s+/ and err '"test A || test B" preferred to "test A -o B"'; /\bwc -l.*"\s*=/ and err '`"$(wc -l)"` is not portable (use test_line_count)'; /\bhead\s+-c\b/ and err 'head -c is not portable (use test_copy_bytes BYTES out)'; /(?:\$\(seq|^\s*seq\b)/ and err 'seq is not portable (use test_seq)'; From patchwork Tue Apr 20 12:21:53 2021 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: 12214113 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 238BCC43461 for ; Tue, 20 Apr 2021 12:22:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D6A9C613C1 for ; Tue, 20 Apr 2021 12:22:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232084AbhDTMWm (ORCPT ); Tue, 20 Apr 2021 08:22:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232031AbhDTMWl (ORCPT ); Tue, 20 Apr 2021 08:22:41 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B596C06174A for ; Tue, 20 Apr 2021 05:22:10 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id w186so15512262wmg.3 for ; Tue, 20 Apr 2021 05:22:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HM6toKW+5a1mvdYKKirFl4WUMcf2kp/k5IIoYPnyjRA=; b=Dd/lMsTw5Fm0cWghzsyRZoQaRjr1guK6jIEjd7ijWqS+D+D9lW6XOqm/326nZBbiSi Vs1ch6xqxcmX9hp8XgYTnvgHyCNBs9skLob7OilNJD9CcE6zADgADi77sWDEVQ8hmEU3 c1+wZ4z4u4Hg8HxlgcqkHsWonsptKlJX0IeYD2xPuDZWtZOG+6fqBOHHMDqcIGKVxK/S qG+TibF4aslGhL6s1aCKuXmsZLqHDfl7E2bL+/BjuS4sdfl0iDP4CjwQZ0t/lKGgF8Lf P7kuol0l2UnezShyX0WCD32z6HYZJmisdiJiv/iDu45pbweU+tG5U10M4FsW3z6M7euO WzAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HM6toKW+5a1mvdYKKirFl4WUMcf2kp/k5IIoYPnyjRA=; b=fh7wd5mkBsktvjaMomuGnPbhcxrkWmnLUTT6tt4k3YdwX/GYl9fM8sj1trjJYgCAqg 5oaHncrqU1h8+UjDqQdjSuRhPvQOcHpWVFF8NTKO8LzLfY2q5Hf7ZaLwh6SYuKxpyOTm bvMtus8i1J1NTpg6XgBFLkSzHPuQWRm5Ju5MJwWfThVz3yXQolHTfDzzBC1fr6MqqngF 5jiQzOpPUMCM27ItbPBwXPFkXeDXRQ5rgpvbXnvq3/c+nwNM3A4+CAAHTXjstqLDRqGg pX/D/w1K7dwSH0QlUXb/zgnfy5GMEoUQIav6F/x+r/MAYA+Bd/6cs5f1Rs3xbtZsrTmK XKdQ== X-Gm-Message-State: AOAM531byzbK1v9LWPO11DU0mAZ8ZRv/7eVNV2LM6LwR7CC1hDFzgtqV mdWpL9LSD99ZlH7yAIDpJL4TX81VG87k0Q== X-Google-Smtp-Source: ABdhPJxtY0KXhLT9qGu2hJPsi579mziq/pGXkLYIUAf3jIZiYf/agvKIP3H2NzXCDrDef8yZ4/tr+w== X-Received: by 2002:a1c:9a43:: with SMTP id c64mr4317255wme.16.1618921328865; Tue, 20 Apr 2021 05:22:08 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b1sm30541768wru.90.2021.04.20.05.22.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 05:22:08 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Matthieu Moy , Johannes Schindelin , Eric Sunshine , =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7Ru?= =?utf-8?b?ZyBEYW5o?= , =?utf-8?q?SZEDER_G=C3=A1bor?= , =?utf-8?b?w4Z2YXIg?= =?utf-8?b?QXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v3 02/12] test-lib: bring $remove_trash out of retirement Date: Tue, 20 Apr 2021 14:21:53 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.723.gf6bad1b9ba1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org There's no point in creating a repository or directory only to decide right afterwards that we're skipping all the tests. We can save ourselves the redundant "git init" or "mkdir" and "rm -rf" in this case. We carry around the "$remove_trash" variable because if the directory is unexpectedly gone at test_done time we'll hit the error about it being unexpectedly gone added in df4c0d1a792 (test-lib: abort when can't remove trash directory, 2017-04-20). So let's partially revert 06478dab4c (test-lib: retire $remove_trash variable, 2017-04-23) and move the decision about whether to skip all tests earlier. I tested this with --debug, see 4d0912a206 (test-lib.sh: do not barf under --debug at the end of the test, 2017-04-24) for a bug we don't want to re-introduce. While I'm at it let's move the HOME assignment to just before test_create_repo, it could be lower, but it seems better to set it before calling anything in test-lib-functions.sh Signed-off-by: Ævar Arnfjörð Bjarmason --- t/test-lib.sh | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/t/test-lib.sh b/t/test-lib.sh index 3dec266221..7522faf39f 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -1169,7 +1169,7 @@ test_done () { esac fi - if test -z "$debug" + if test -z "$debug" && test -n "$remove_trash" then test -d "$TRASH_DIRECTORY" || error "Tests passed but trash directory already removed before test cleanup; aborting" @@ -1334,6 +1334,21 @@ then exit 1 fi +# Are we running this test at all? +this_test=${0##*/} +this_test=${this_test%%-*} +if match_pattern_list "$this_test" $GIT_SKIP_TESTS +then + say_color info >&3 "skipping test $this_test altogether" + skip_all="skip all tests in $this_test" + test_done +fi + +# Last-minute variable setup +HOME="$TRASH_DIRECTORY" +GNUPGHOME="$HOME/gnupg-home-not-used" +export HOME GNUPGHOME + # Test repository rm -fr "$TRASH_DIRECTORY" || { GIT_EXIT_OK=t @@ -1341,10 +1356,7 @@ rm -fr "$TRASH_DIRECTORY" || { exit 1 } -HOME="$TRASH_DIRECTORY" -GNUPGHOME="$HOME/gnupg-home-not-used" -export HOME GNUPGHOME - +remove_trash=t if test -z "$TEST_NO_CREATE_REPO" then test_create_repo "$TRASH_DIRECTORY" @@ -1356,15 +1368,6 @@ fi # in subprocesses like git equals our $PWD (for pathname comparisons). cd -P "$TRASH_DIRECTORY" || exit 1 -this_test=${0##*/} -this_test=${this_test%%-*} -if match_pattern_list "$this_test" $GIT_SKIP_TESTS -then - say_color info >&3 "skipping test $this_test altogether" - skip_all="skip all tests in $this_test" - test_done -fi - if test -n "$write_junit_xml" then junit_xml_dir="$TEST_OUTPUT_DIRECTORY/out" From patchwork Tue Apr 20 12:21:54 2021 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: 12214115 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99B2FC433B4 for ; Tue, 20 Apr 2021 12:22:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 61D53613C5 for ; Tue, 20 Apr 2021 12:22:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232109AbhDTMWp (ORCPT ); Tue, 20 Apr 2021 08:22:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232031AbhDTMWm (ORCPT ); Tue, 20 Apr 2021 08:22:42 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52A3FC06174A for ; Tue, 20 Apr 2021 05:22:11 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id w186so15512289wmg.3 for ; Tue, 20 Apr 2021 05:22:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cmt/OfrANsb1x/lcuP8wCH7s7LiSjmv6NxWhC90EpLs=; b=BH4Z99XzguYCBMs1dH+jMMLGbvqcPA+P4UlO5yhD0F/eokKhcz1qCW62N1GPADK6HP pBPV1YeFg6InBK65SYjx283cY9c3Epx13WLPBEUaRgFtaa0lsgnnEn45a+VT3CH2SjFA I3Qc46VAtscTCIbFsfcGM6QKkd/TY3RjW2kkajQIeGn+jalGVLChgAnXR7CZu7vg8gaq PxxwfUn2vUNDeBGuENc1D57hCMTeR7r91Qqsh2Q8qA70fYSEenSWM67vKm/RWdBRLyZ2 CuEN5m9EtKJazrFO7OTgR/tbFpSfW4Ghi9jnBrJDTanuWIYJngpVR+wiDcyelX+6CDZY /SyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cmt/OfrANsb1x/lcuP8wCH7s7LiSjmv6NxWhC90EpLs=; b=uVigWOhTBapJYDEecjy0BdIyBbcuYCshuLa9+KkUXwtQWqB+NI2btTaKb0eubrCwXP vcW6XNuzyaj23mNblY5phOK/hdXJuC+F0Ud+7k5QG1IHxtFy5J4uu9pX+gBlBw9NzgZk IJc1JPFR/bcYzjX5ZT40Ja93EPQ7SVKV6Y+29lRPOxFHRqa+GRXeWGMiHG9Sx5MAizUT USIoNf39j3Jo9hzndRPbIQYyRsc0uQygEzzy+D8o8WJRk1YLjDGaLxtjb+ouTpMbA4jg 8S1QmWuJ68mw52e94e6gd3nnuNJntm/OMJ4nusFx2axcNrK1I2/wTxaRQ4zikqU7cqqE 04Eg== X-Gm-Message-State: AOAM5319ik+11HgnCiPJE1tStUpUe70Uh7AYRQ9fumT07jhLAt3DRKIh E87sxLFdwSmzBrA+0kOZxX2/tnuClqm9fQ== X-Google-Smtp-Source: ABdhPJxWxmIR0zfAZTgilL90z4Y6jyf2wTTFIKefIznGbpUIfvASlTjwZbxX2eeeW9XSDTgJT4AIAw== X-Received: by 2002:a1c:1f52:: with SMTP id f79mr4277672wmf.171.1618921329821; Tue, 20 Apr 2021 05:22:09 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b1sm30541768wru.90.2021.04.20.05.22.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 05:22:09 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Matthieu Moy , Johannes Schindelin , Eric Sunshine , =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7Ru?= =?utf-8?b?ZyBEYW5o?= , =?utf-8?q?SZEDER_G=C3=A1bor?= , =?utf-8?b?w4Z2YXIg?= =?utf-8?b?QXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v3 03/12] test-lib tests: remove dead GIT_TEST_FRAMEWORK_SELFTEST variable Date: Tue, 20 Apr 2021 14:21:54 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.723.gf6bad1b9ba1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Stop setting the GIT_TEST_FRAMEWORK_SELFTEST variable. This was originally needed back in 4231d1ba99 (t0000: do not get self-test disrupted by environment warnings, 2018-09-20). It hasn't been needed since I deleted the relevant code in test-lib.sh in c0eedbc009 (test-lib: remove check_var_migration, 2021-02-09), I just didn't notice that it was set here. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t0000-basic.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh index 705d62cc27..2c6e34b947 100755 --- a/t/t0000-basic.sh +++ b/t/t0000-basic.sh @@ -84,10 +84,6 @@ _run_sub_test_lib_test_common () { passing metrics ' - # Tell the framework that we are self-testing to make sure - # it yields a stable result. - GIT_TEST_FRAMEWORK_SELFTEST=t && - # Point to the t/test-lib.sh, which isn't in ../ as usual . "\$TEST_DIRECTORY"/test-lib.sh EOF From patchwork Tue Apr 20 12:21:55 2021 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: 12214119 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1EDD3C43460 for ; Tue, 20 Apr 2021 12:22:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E5D6C613C2 for ; Tue, 20 Apr 2021 12:22:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232142AbhDTMWr (ORCPT ); Tue, 20 Apr 2021 08:22:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232137AbhDTMWo (ORCPT ); Tue, 20 Apr 2021 08:22:44 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F56CC06138A for ; Tue, 20 Apr 2021 05:22:12 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id y124-20020a1c32820000b029010c93864955so22429519wmy.5 for ; Tue, 20 Apr 2021 05:22:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CecjrqhZu5jr158EfKTQNkLxhfn9+U4Xzq5YaTdHXKw=; b=kxn+QyzUKLY3669x2eVh0904T7C942OkcMErXg6Aqoul2hoD6fRSBUG6UNbW7GX8DF oMJgS8PGkliWVUb2HZfAF/dJXUzcGJJOtrT0vY569Dgo2ToMqiTNZgekP3Ytssa8zD2G DmVIfQGl1Rwcj93gI9lVe2XnnJY2zMjoIGN1R4ENXLlOdk6RtQz5oR6O+9qS17tBxSyS iSAEKOUWxIBAWhJozcGOMJfd8/TzKhSE1/e9rT3pW+PQ0tdNI5OzMWC6GuzAU+X1KLe8 PgKTho0jojUefsmXHaWLFdP1cgh/Y3w3GCOTLwebK4+qgPlDRj2jCAOTZdxPrqV4p3xC zjcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CecjrqhZu5jr158EfKTQNkLxhfn9+U4Xzq5YaTdHXKw=; b=dZ5EY470JvZsCvkVSHo2hZ8CzDB6zdSQaDZJoLkXC5WGxJ5a99niH5SdjX/gWbqCb/ +T29lmLIo1a9IGSi9Arxd7LMmqNhkXnnsz7OeKAfHzValjyI04AtXj/qSXzAocr7xyNx rxffqZX0PsSnEqeqXwZ4HzjabYJh6MQWaqaR7ScmfubR4bxRqHow1bq5MYoY742BMhfU ux6n79PhPoRoeVUK6IXF4zLBagPMHA1xzsCgUiMkCQFscDxTxmEzTN9ZGmNumZPwNRLB Tshy2tiWSujd5kvcYnMbWAQEpD7zlriqepaYq1Jqjf1sG8mEvXmGOtXVcjx2DfSECmf8 Il2w== X-Gm-Message-State: AOAM531SraRZzTKAy4ooTVaDIGI5fFUEUP1JAAVz9xWeljNo3jRdSklv Z5+X6hyszfnfLepl+ZqL985IA3JCQLElSQ== X-Google-Smtp-Source: ABdhPJxaGtAr7HCQ2JjDZCLp7L5AgGGq0lvk16+B/TdCLUEBBNFzdv3sNa7V+ITGSDsb7b1akI2i4Q== X-Received: by 2002:a1c:c918:: with SMTP id f24mr4328704wmb.12.1618921330657; Tue, 20 Apr 2021 05:22:10 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b1sm30541768wru.90.2021.04.20.05.22.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 05:22:10 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Matthieu Moy , Johannes Schindelin , Eric Sunshine , =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7Ru?= =?utf-8?b?ZyBEYW5o?= , =?utf-8?q?SZEDER_G=C3=A1bor?= , =?utf-8?b?w4Z2YXIg?= =?utf-8?b?QXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v3 04/12] test-lib-functions: reword "test_commit --append" docs Date: Tue, 20 Apr 2021 14:21:55 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.723.gf6bad1b9ba1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Reword the documentation for "test_commit --append" added in my 3373518cc8 (test-lib functions: add an --append option to test_commit, 2021-01-12). A follow-up commit will make the "echo" part of this configurable, and in any case saying "echo >>" rather than ">>" was redundant. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/test-lib-functions.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 6348e8d733..d169fb2f59 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -172,8 +172,7 @@ debug () { # --notick # Do not call test_tick before making a commit # --append -# Use "echo >>" instead of "echo >" when writing "" to -# "" +# Use ">>" instead of ">" when writing "" to "" # --signoff # Invoke "git commit" with --signoff # --author From patchwork Tue Apr 20 12:21:56 2021 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: 12214117 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 260F0C433ED for ; Tue, 20 Apr 2021 12:22:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DD862613C5 for ; Tue, 20 Apr 2021 12:22:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232119AbhDTMWq (ORCPT ); Tue, 20 Apr 2021 08:22:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232134AbhDTMWo (ORCPT ); Tue, 20 Apr 2021 08:22:44 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A74FC06138B for ; Tue, 20 Apr 2021 05:22:13 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id x7so37366067wrw.10 for ; Tue, 20 Apr 2021 05:22:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Vhkn8aNMXvudUAyFYl3RRxpym/GXdxGrK9Z5x1F/uk4=; b=PKnkXQTJv111A7ZogV7D6baRjtcKF3KsZ57TNocwllM1Ks5cwioRgr6TuVd8BXLJbB /a5+QVG6bwcgOlYN7GUOfRQu24YGYLwm8opLw+wXFkPCp/soj1Y06PmNPTt6Ouzgc5xc AdVpuYNy9gXP7xP+Oi53QUrfSOo51sQGNO2TQk3OC7b3acI70hY/SgKn8aagaCyvacem bjnXBd/Cl5VRjcv/iE6NPUu98HDRqIhp6kkU0SOEps0xq2W3hDvdePEapvE16xd57/0S nrsbsIq7i8Mu4JZFr31fLuYfddBOuN7Oxuk+yA0JiyzjyMMptO4d0irdIGP56CEQrnK4 QL3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Vhkn8aNMXvudUAyFYl3RRxpym/GXdxGrK9Z5x1F/uk4=; b=bnGakllZsDvwkCfMxoW+NIl2VMFMuWen7eIjRDLAyUW9DAIcID7Y3yss+vtLF/gByA Bb44jPyKkE5KW2vXjScgr0xklwZ3mrd4CcS5mUNLJkKuSE6GCmHxKs6u0Qw8Gn7LWAdZ VMC2d2KlxDZKJn5rQ0a40J74+JH8MS2Bk70bRXuIlBG32DCCzrOzPQ8U6jYgC8iVU3sB 4GQj9hAR06rUEqve9XZmh9kJoR2lPFC2R69if149n4wT5zEePmYtbo1nNHYbFaD8bddJ 8docMImPMaDwfWv3GVuAW18V62I1b7qkhwpXClA+jHcqEFJLh209a0eoaqQYXm/8NKx5 AvkQ== X-Gm-Message-State: AOAM533Em2CBsyOomLMM6C5maMjzvFKymJWK7bzsw62TwnVvfVwVgnl+ p+OACNrxeNDhahf05K2s7nXUAeCnD1yQfw== X-Google-Smtp-Source: ABdhPJz5nqeb88LhLQRGUZMQraxjn2YnIuzus0rx7+HNWKmFDVxol7M0+cdGLNcDZbexc7RGQHimXw== X-Received: by 2002:a5d:400d:: with SMTP id n13mr20088954wrp.372.1618921331598; Tue, 20 Apr 2021 05:22:11 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b1sm30541768wru.90.2021.04.20.05.22.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 05:22:11 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Matthieu Moy , Johannes Schindelin , Eric Sunshine , =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7Ru?= =?utf-8?b?ZyBEYW5o?= , =?utf-8?q?SZEDER_G=C3=A1bor?= , =?utf-8?b?w4Z2YXIg?= =?utf-8?b?QXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v3 05/12] test-lib-functions: document test_commit --no-tag Date: Tue, 20 Apr 2021 14:21:56 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.723.gf6bad1b9ba1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In 76b8b8d05c (test-lib functions: document arguments to test_commit, 2021-01-12) I added missing documentation to test_commit, but in less than a month later in 3803a3a099 (t: add --no-tag option to test_commit, 2021-02-09) we got another undocumented option. Let's fix that. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/test-lib-functions.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index d169fb2f59..d0f4f3885d 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -177,6 +177,8 @@ debug () { # Invoke "git commit" with --signoff # --author # Invoke "git commit" with --author +# --no-tag +# Do not tag the resulting commit # # This will commit a file with the given contents and the given commit # message, and tag the resulting commit with the given tag name. From patchwork Tue Apr 20 12:21:57 2021 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: 12214121 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F0D5C43461 for ; Tue, 20 Apr 2021 12:22:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 498FA613C0 for ; Tue, 20 Apr 2021 12:22:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232214AbhDTMWu (ORCPT ); Tue, 20 Apr 2021 08:22:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231196AbhDTMWp (ORCPT ); Tue, 20 Apr 2021 08:22:45 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FAF8C06138C for ; Tue, 20 Apr 2021 05:22:14 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id o21-20020a1c4d150000b029012e52898006so10227622wmh.0 for ; Tue, 20 Apr 2021 05:22:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qQ89R2jPrxNBf1MAp0hasSUAvVS3ath0w3MYAzCfep8=; b=Kd26aZt5kAdaSkTcc+37JWYQRS5GTIeUYLEeMOx63NwJQDzcbWAfQp6A/nvYLb9LJG dkO4A+uU0UJoXlb0fRqNH/XwuEBecXLMnObxLSJBvnkl8gNcAM6Z8KzB9eNhk7XrSbAj evcPcudotzY/0I/famQiIegEUkDRxNYp0DI9nnQAMyTJRhGka8XtmTpsNVjVqorJsQ6x XXhw36yjHcZFQlu85MXBuCxQditdjrBOtE4sizTeuGE/hPmaWd2YnATXrfBiBzPuKlL3 GmWdiWBWoN6rJb0/YWghU9mRYb6CPC/PbUwlUcA3Q/JZPERWn6Bb/5T/gVymaZdJOIuP Uamg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qQ89R2jPrxNBf1MAp0hasSUAvVS3ath0w3MYAzCfep8=; b=PKrSjebE3w2mQOD8wzD2dsw/B2eOuMIIL/xT+yp9/LgFLmgfmDfYzK/pNCc1nHfN3A NA11yk56CMdlb64Tj+opCRdRvbLWd+UC96mRLz/YtYWURWY4VRbqGFi7O7dGbKg4rPN3 MX6rO3HPglwC5frGzkBhijxzViHm4w8bqMnNP8GuQa3LmPAIf5ZsUFZYH4uZQdFg6Bix r9WCAaUerfDQk3AlqPJEDuKfsI1NLhBGkVNhbQ/An2WhcAlj3ynvKttOi2+B+KVAwzFt eIo7nTXfSu1Sk1KxK9e5AhleY0Z0oyqsQCjUqLTbbpkC+V6piX3coyDHxW+rmGzHAe3/ 2Djw== X-Gm-Message-State: AOAM532JoeRXcDuL5CyHMPUJ//gva7NBBUfhMRDz6vSKLyYnXK1Vw99e 4KELod0XLYa+2d1pPIRRI8DDE7j46B9XTQ== X-Google-Smtp-Source: ABdhPJyqEokWwGwQJuK2kysA8wpyirSYCGfyIoihsZDvl53vr8IC3uc7ASMsob4MZNWQbfpFNtKb0g== X-Received: by 2002:a05:600c:d5:: with SMTP id u21mr4172562wmm.153.1618921332557; Tue, 20 Apr 2021 05:22:12 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b1sm30541768wru.90.2021.04.20.05.22.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 05:22:12 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Matthieu Moy , Johannes Schindelin , Eric Sunshine , =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7Ru?= =?utf-8?b?ZyBEYW5o?= , =?utf-8?q?SZEDER_G=C3=A1bor?= , =?utf-8?b?w4Z2YXIg?= =?utf-8?b?QXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v3 06/12] test-lib functions: add an --annotated option to "test_commit" Date: Tue, 20 Apr 2021 14:21:57 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.723.gf6bad1b9ba1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add an --annotated option to test_commit to create annotated tags. The tag will share the same message as the commit, and we'll call test_tick before creating it (unless --notick) is provided. There's quite a few tests that could be simplified with this construct. I've picked one to convert in this change as a demonstration. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t1403-show-ref.sh | 6 ++---- t/test-lib-functions.sh | 27 ++++++++++++++++++++++----- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/t/t1403-show-ref.sh b/t/t1403-show-ref.sh index 6ce62f878c..17d3cc1405 100755 --- a/t/t1403-show-ref.sh +++ b/t/t1403-show-ref.sh @@ -7,11 +7,9 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME . ./test-lib.sh test_expect_success setup ' - test_commit A && - git tag -f -a -m "annotated A" A && + test_commit --annotate A && git checkout -b side && - test_commit B && - git tag -f -a -m "annotated B" B && + test_commit --annotate B && git checkout main && test_commit C && git branch B A^0 diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index d0f4f3885d..6e2332a324 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -179,6 +179,10 @@ debug () { # Invoke "git commit" with --author # --no-tag # Do not tag the resulting commit +# --annotate +# Create an annotated tag with "--annotate -m ". Calls +# test_tick between making the commit and tag, unless --notick +# is given. # # This will commit a file with the given contents and the given commit # message, and tag the resulting commit with the given tag name. @@ -191,7 +195,7 @@ test_commit () { author= && signoff= && indir= && - no_tag= && + tag=light && while test $# != 0 do case "$1" in @@ -219,7 +223,10 @@ test_commit () { shift ;; --no-tag) - no_tag=yes + tag=none + ;; + --annotate) + tag=annotate ;; *) break @@ -243,10 +250,20 @@ test_commit () { git ${indir:+ -C "$indir"} commit \ ${author:+ --author "$author"} \ $signoff -m "$1" && - if test -z "$no_tag" - then + case "$tag" in + none) + ;; + light) git ${indir:+ -C "$indir"} tag "${4:-$1}" - fi + ;; + annotate) + if test -z "$notick" + then + test_tick + fi && + git ${indir:+ -C "$indir"} tag -a -m "$1" "${4:-$1}" + ;; + esac } # Call test_merge with the arguments " ", where From patchwork Tue Apr 20 12:21:58 2021 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: 12214125 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C719C43462 for ; Tue, 20 Apr 2021 12:22:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2D36A613C0 for ; Tue, 20 Apr 2021 12:22:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232181AbhDTMWv (ORCPT ); Tue, 20 Apr 2021 08:22:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232111AbhDTMWq (ORCPT ); Tue, 20 Apr 2021 08:22:46 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 033B4C06174A for ; Tue, 20 Apr 2021 05:22:15 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id t14-20020a05600c198eb029012eeb3edfaeso10091940wmq.2 for ; Tue, 20 Apr 2021 05:22:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VvAwW3pZ0KXSCg400wEK8KILNxqoHxjpNb9AzvVL3/w=; b=QI/6VpN78czpPJ0eKj5LLCVP4U1cKtpVZgyzZA3Cz+1z0zYRcTi/GgAh1Jsb3r9U63 r2sYTuuq4omyqzh22X1ndViKTZSSVrmsjpIN3R6I1ME4YyhTe34MUHWLMVi1YLepTHJl cBkm+qMwXB61DP4AnoO7iPEK38R29LSllaBot6M5FkQadQJ7w3DgbgnVsE2/evTVzEoM Gc1R31SH1VVLrjnhA4Rg62+WiUEIdfiW1v9l0QmtT2b3oSHeGhcZa+srHefj3aOFT+0q Ns/lzP4MmFclsmxsqjU8PypM/sqfECZHDuaFT4rYF3PKSOipuSHg2hNH3obT0lE2wMjF LDtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VvAwW3pZ0KXSCg400wEK8KILNxqoHxjpNb9AzvVL3/w=; b=ahMjTTg9BYe6bohfkGqirsO9AJY7fBLj0GYh/eJsNFEhwXXLzmyY7n5TBR60mjS4vY XkzO/IMmhVMfqilBIGwKP+tEtpDgO27sCOszfNvYI4qDkOQH5BFtVNEIRVTCU4j6h81w 40PfzMTgTosbWrDwkTe9Tcp+kgET8xN6m96EBh0R4kgWWpY6CLR4B3AdaHyts2DHgFHU q6fJ0bedmjGcD/Y07ryisLz5vtygq65/CMPvle8Xx8M3WSWV5bAXAwZZ6kHQ9/hVUEV1 cVpWA2UhLj2g4KYTuGAAkyo2QX2oy+m7aiSCkFFZ203De1nhfjGBGFbnVWyNESWrjI+S qhEg== X-Gm-Message-State: AOAM5335Xg9OlSWQUy3oCYnguo5/08NnVUWo68SN1BLIFik6AifBvgK8 IXm6Wg//vBxW0kleVaU1tpLyZ/CoCYsqag== X-Google-Smtp-Source: ABdhPJwyRgZEMWwHYvb7RBiuVCqY2pIwT7WpyumfoptG0Or0Gv2fUY2JvoutRt5d30KcfdXLodA6Iw== X-Received: by 2002:a7b:cbc1:: with SMTP id n1mr4267323wmi.50.1618921333467; Tue, 20 Apr 2021 05:22:13 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b1sm30541768wru.90.2021.04.20.05.22.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 05:22:13 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Matthieu Moy , Johannes Schindelin , Eric Sunshine , =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7Ru?= =?utf-8?b?ZyBEYW5o?= , =?utf-8?q?SZEDER_G=C3=A1bor?= , =?utf-8?b?w4Z2YXIg?= =?utf-8?b?QXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v3 07/12] describe tests: convert setup to use test_commit Date: Tue, 20 Apr 2021 14:21:58 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.723.gf6bad1b9ba1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Convert the setup of the describe tests to use test_commit when possible. This makes use of the new --annotated-tag option to test_commit. Some of the setup here could simply be removed since the data being created wasn't important to any of the subsequent tests, so I've done so. E.g. assigning to the "one" variable was always useless, and just checking that we can describe HEAD after the first commit wasn't useful. In the case of the "two" variable we could instead use the tag we just created. See 5312ab11fbf (Add describe test., 2007-01-13) for the initial version of this code. There's other cases here like redundant "test_tick" invocations, or the simplification of not echoing "X" to a file we're about to tag as "x", now we just use "x" in both cases. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t6120-describe.sh | 58 ++++++++++----------------------------------- 1 file changed, 13 insertions(+), 45 deletions(-) diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh index e89b6747be..88fddc9142 100755 --- a/t/t6120-describe.sh +++ b/t/t6120-describe.sh @@ -31,64 +31,32 @@ check_describe () { } test_expect_success setup ' + test_commit initial file one && + test_commit second file two && + test_commit third file three && + test_commit --annotate A file A && + test_commit c file c && - test_tick && - echo one >file && git add file && git commit -m initial && - one=$(git rev-parse HEAD) && - - git describe --always HEAD && - - test_tick && - echo two >file && git add file && git commit -m second && - two=$(git rev-parse HEAD) && - - test_tick && - echo three >file && git add file && git commit -m third && - - test_tick && - echo A >file && git add file && git commit -m A && - test_tick && - git tag -a -m A A && - - test_tick && - echo c >file && git add file && git commit -m c && - test_tick && - git tag c && - - git reset --hard $two && - test_tick && - echo B >side && git add side && git commit -m B && - test_tick && - git tag -a -m B B && + git reset --hard second && + test_commit --annotate B side B && test_tick && git merge -m Merged c && merged=$(git rev-parse HEAD) && - git reset --hard $two && - test_tick && - echo D >another && git add another && git commit -m D && - test_tick && - git tag -a -m D D && - test_tick && - git tag -a -m R R && - - test_tick && - echo DD >another && git commit -a -m another && + git reset --hard second && + test_commit --no-tag D another D && test_tick && - git tag e && + git tag -a -m R R && - test_tick && - echo DDD >another && git commit -a -m "yet another" && + test_commit e another DD && + test_commit --no-tag "yet another" another DDD && test_tick && git merge -m Merged $merged && - test_tick && - echo X >file && echo X >side && git add file side && - git commit -m x - + test_commit --no-tag x file ' check_describe A-* HEAD From patchwork Tue Apr 20 12:21:59 2021 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: 12214123 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5762BC433B4 for ; Tue, 20 Apr 2021 12:22:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 06ACE613C1 for ; Tue, 20 Apr 2021 12:22:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232201AbhDTMWw (ORCPT ); Tue, 20 Apr 2021 08:22:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232177AbhDTMWt (ORCPT ); Tue, 20 Apr 2021 08:22:49 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D53C7C06174A for ; Tue, 20 Apr 2021 05:22:15 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id w4so33676101wrt.5 for ; Tue, 20 Apr 2021 05:22:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FrAch+ez0rxEpk6SU/z3hzgvOyPmdswlPariD3IIa+4=; b=iidHM6MUv1UtAuRaJHEWVdGthNWe4Oi0uN2NvPN7SFnulH/8jlZU/ctxlc74n5Z10Y G7z7SxWAtTet7HqKG2Re2/1jtCI79UkvANyl32KWql4aHsu4+UCnQF/AQhp7U22IaZRM qJOPhhFkGevDo41y1r/pqz5Fs+7P7MjU1nPEqfUXBPXse4HEhUjuCXkJK67Dur4RVe7j sMZMXuUm7iW+InqtD3ZhunTGdPWqZw81QFH9UlvP5mm7IhlHhjvlh4uW4/ez0HhbZgeM OmlJ75QKXLB89H+J+Ko0KHI6kqCR6uX4d4nlKcBHYk/e+udWJZbsKc1M98rYYxc7bk7J jX1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FrAch+ez0rxEpk6SU/z3hzgvOyPmdswlPariD3IIa+4=; b=HTJ37qcEnjcSNKE8sRZtdqbIBv80nk34xVLn4XgHZrFj9OhSxFQ3CSup5iuGqTGcT/ B3mwNMC4gQyA4KfEw10Wou2vcbbWTC7KqGRKuaXDpYxBBUyN/jjL/lbA2R0nYPjMdhWy lRFp7RRrBf1yfyRQ3/jrSIykFic5en/VM4IbolMMvLg2+SrJeEwmkRwBXgxSG33T/qRu KHpqpxrbE/xCtNk9cAMt2FRux8Gz2WfuJeFCTwcAqoyp5xqVVU0mVYA9CfYb/GV7x8Jo B7ffCVZObWxrZKSWr/38+Eh/LpAKP2Xuh5o4VG+7Os+52RtZ1vGZYF/ZteFUw2YLYn8f Ur8g== X-Gm-Message-State: AOAM532Y2zvs1I3t5Dx28uacjfb19pm0lq+tUoEPx1mJutusC3j9vQRG oibJBoSZLJInE/64FszoV638wjyjzbxXTQ== X-Google-Smtp-Source: ABdhPJy93X4On8xczq1inIWDYNn8DjjeNyhIh6yCNW8uPlcz0WhLg15huEiaauU6zETcky1nJC3xHQ== X-Received: by 2002:adf:e50d:: with SMTP id j13mr20243379wrm.80.1618921334341; Tue, 20 Apr 2021 05:22:14 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b1sm30541768wru.90.2021.04.20.05.22.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 05:22:13 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Matthieu Moy , Johannes Schindelin , Eric Sunshine , =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7Ru?= =?utf-8?b?ZyBEYW5o?= , =?utf-8?q?SZEDER_G=C3=A1bor?= , =?utf-8?b?w4Z2YXIg?= =?utf-8?b?QXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v3 08/12] test-lib functions: add --printf option to test_commit Date: Tue, 20 Apr 2021 14:21:59 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.723.gf6bad1b9ba1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add a --printf option to test_commit to allow writing to the file with "printf" instead of "echo". This is useful for writing "\n", "\0" etc., in particular in combination with the --append option added in 3373518cc8 (test-lib functions: add an --append option to test_commit, 2021-01-12). I'm converting a few tests to use the new option rather than a manual printf/add/commit combination to demonstrate its usefulness. While I'm at it use "test_create_repo" where appropriate, and give the first/second commit a meaningful/more conventional log message in cases where no test cared about that message. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t1307-config-blob.sh | 4 +--- t/t2030-unresolve-info.sh | 3 +-- t/t4006-diff-mode.sh | 6 ++---- t/t4030-diff-textconv.sh | 8 ++------ t/t5520-pull.sh | 10 ++-------- t/test-lib-functions.sh | 12 ++++++++++-- 6 files changed, 18 insertions(+), 25 deletions(-) diff --git a/t/t1307-config-blob.sh b/t/t1307-config-blob.sh index 002e6d3388..930dce06f0 100755 --- a/t/t1307-config-blob.sh +++ b/t/t1307-config-blob.sh @@ -65,9 +65,7 @@ test_expect_success 'parse errors in blobs are properly attributed' ' ' test_expect_success 'can parse blob ending with CR' ' - printf "[some]key = value\\r" >config && - git add config && - git commit -m CR && + test_commit --printf CR config "[some]key = value\\r" && echo value >expect && git config --blob=HEAD:config some.key >actual && test_cmp expect actual diff --git a/t/t2030-unresolve-info.sh b/t/t2030-unresolve-info.sh index be6c84c52a..f691e6d903 100755 --- a/t/t2030-unresolve-info.sh +++ b/t/t2030-unresolve-info.sh @@ -179,8 +179,7 @@ test_expect_success 'rerere and rerere forget (subdirectory)' ' test_expect_success 'rerere forget (binary)' ' git checkout -f side && - printf "a\0c" >binary && - git commit -a -m binary && + test_commit --printf binary binary "a\0c" && test_must_fail git merge second && git rerere forget binary ' diff --git a/t/t4006-diff-mode.sh b/t/t4006-diff-mode.sh index 275ce5fa15..6cdee2a216 100755 --- a/t/t4006-diff-mode.sh +++ b/t/t4006-diff-mode.sh @@ -26,10 +26,8 @@ test_expect_success 'chmod' ' ' test_expect_success 'prepare binary file' ' - git commit -m rezrov && - printf "\00\01\02\03\04\05\06" >binbin && - git add binbin && - git commit -m binbin + git commit -m one && + test_commit --printf two binbin "\00\01\02\03\04\05\06" ' test_expect_success '--stat output after text chmod' ' diff --git a/t/t4030-diff-textconv.sh b/t/t4030-diff-textconv.sh index c906320b60..a39a626664 100755 --- a/t/t4030-diff-textconv.sh +++ b/t/t4030-diff-textconv.sh @@ -26,12 +26,8 @@ EOF chmod +x hexdump test_expect_success 'setup binary file with history' ' - printf "\\0\\n" >file && - git add file && - git commit -m one && - printf "\\01\\n" >>file && - git add file && - git commit -m two + test_commit --printf one file "\\0\\n" && + test_commit --printf --append two file "\\01\\n" ' test_expect_success 'file is considered binary by porcelain' ' diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh index a09411327f..e2c0c51022 100755 --- a/t/t5520-pull.sh +++ b/t/t5520-pull.sh @@ -746,14 +746,8 @@ test_expect_success 'pull --rebase fails on corrupt HEAD' ' ' test_expect_success 'setup for detecting upstreamed changes' ' - mkdir src && - ( - cd src && - git init && - printf "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" > stuff && - git add stuff && - git commit -m "Initial revision" - ) && + test_create_repo src && + test_commit -C src --printf one stuff "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" && git clone src dst && ( cd src && diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 6e2332a324..dbeb3d9262 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -173,6 +173,10 @@ debug () { # Do not call test_tick before making a commit # --append # Use ">>" instead of ">" when writing "" to "" +# --printf +# Use "printf" instead of "echo" when writing "" to +# "". You will need to provide your own trailing "\n". You +# can only supply the FORMAT for the printf(1), not its ARGUMENT(s). # --signoff # Invoke "git commit" with --signoff # --author @@ -191,6 +195,7 @@ debug () { test_commit () { notick= && + echo=echo && append= && author= && signoff= && @@ -202,6 +207,9 @@ test_commit () { --notick) notick=yes ;; + --printf) + echo=printf + ;; --append) append=yes ;; @@ -238,9 +246,9 @@ test_commit () { file=${2:-"$1.t"} && if test -n "$append" then - echo "${3-$1}" >>"$indir$file" + $echo "${3-$1}" >>"$indir$file" else - echo "${3-$1}" >"$indir$file" + $echo "${3-$1}" >"$indir$file" fi && git ${indir:+ -C "$indir"} add "$file" && if test -z "$notick" From patchwork Tue Apr 20 12:22:00 2021 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: 12214127 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 301D5C433ED for ; Tue, 20 Apr 2021 12:22:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0AE3F613C1 for ; Tue, 20 Apr 2021 12:22:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232060AbhDTMWx (ORCPT ); Tue, 20 Apr 2021 08:22:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232149AbhDTMWv (ORCPT ); Tue, 20 Apr 2021 08:22:51 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9425C06138E for ; Tue, 20 Apr 2021 05:22:16 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id e7so28428035wrs.11 for ; Tue, 20 Apr 2021 05:22:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uYeDChtgEsC/IVgoNOfFLY+PHPMRIES1HFPwehZ/UZo=; b=ctABP0QGulFH/19XcUyXkAvF6yUCHqarDM1sRjSOhAicQUlujPEi69EMXpyHmGZTbP DB/WAVC+8/GK6I1VLQyiatOzzV6GXZ23wH+EryDFzwu9YHs1fsbd+uUyt6wdja9W/Sbl hx7SSoyB9TNVL16oVBwMcAKVyLhkvq+nDERgrbLKslKQT0cdn6YCA1OjzniTMOvFtG+k uqcq8jQaadRnyUulR3Thy9s134ciOdDXsMwEtOceoG/De6qPy7aC+PMQoM6x5aOAayC8 fXcgKKBRZkuvc07sSagK2KdKK+TzbykSu3wXGODlIiWXORsZ6tnZlZ+FJR0X3kbOjhPm TF+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uYeDChtgEsC/IVgoNOfFLY+PHPMRIES1HFPwehZ/UZo=; b=QHQZVMBLJnjFVJeE2uVAh3x4wsLlYoDDZQdpiCdbU+qVlNbAA7jFpNoRPhvHSMkfrZ bSSibqFllsU9F4dSlqQGd/MFxtXEKUb3lSKaG817tcxHmT1/voo9YaICWYpjyHFRZEcr 5rGOTda2/xx6LrR8QZdfWyUeItT794PuYWTTqo7smW3c/qfv1lP666ye1XwxyDfjx5rM 49AwxtTNj5Eqq/6DgUXnlZXKvyvIPjXAaEaUs2pmZG0uh4OALkL8/ZPb+N/eXqBfE2CW 9h5AyPTKNjYrtimmo+m3nsnK1l1Q2J5cOP7eSTzamoMtCl45VZSymnjpKSUxLPwHnYII Nx0A== X-Gm-Message-State: AOAM530QAhB5AtQqVOxENmrOS051A0IYwQPRj3IyzAshBv8ycoRxAmbf 0qN+nS4Vhvug4J4FP+yzOBWFxLFLDyKygQ== X-Google-Smtp-Source: ABdhPJzPP5EORz5is96GZl6aR9j+2n85VT71PU4xFf1qY6UoVVRTdDkJSuDBcEmfY4NVn7jkRuHZDg== X-Received: by 2002:a5d:628e:: with SMTP id k14mr20406531wru.150.1618921335427; Tue, 20 Apr 2021 05:22:15 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b1sm30541768wru.90.2021.04.20.05.22.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 05:22:14 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Matthieu Moy , Johannes Schindelin , Eric Sunshine , =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7Ru?= =?utf-8?b?ZyBEYW5o?= , =?utf-8?q?SZEDER_G=C3=A1bor?= , =?utf-8?b?w4Z2YXIg?= =?utf-8?b?QXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v3 09/12] submodule tests: use symbolic-ref --short to discover branch name Date: Tue, 20 Apr 2021 14:22:00 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.723.gf6bad1b9ba1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change a use of $GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME added in 704fed9ea22 (tests: start moving to a different default main branch name, 2020-10-23) to simply discover the initial branch name of a repository set up in this function with "symbolic-ref --short". That's something done in another test in 704fed9ea22, so doing it like this seems like an omission, or rather an overly eager search/replacement instead of fixing the test logic. There are only three uses of the GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME variable in the test suite, this gets rid of one of those. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/lib-submodule-update.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh index 4b714e9308..f7c7df0ca4 100644 --- a/t/lib-submodule-update.sh +++ b/t/lib-submodule-update.sh @@ -63,6 +63,7 @@ create_lib_submodule_repo () { git init submodule_update_repo && ( cd submodule_update_repo && + branch=$(git symbolic-ref --short HEAD) && echo "expect" >>.gitignore && echo "actual" >>.gitignore && echo "x" >file1 && @@ -144,7 +145,7 @@ create_lib_submodule_repo () { git checkout -b valid_sub1 && git revert HEAD && - git checkout "${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}" + git checkout "$branch" ) } From patchwork Tue Apr 20 12:22:01 2021 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: 12214129 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A324C43470 for ; Tue, 20 Apr 2021 12:22:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CF65C613C0 for ; Tue, 20 Apr 2021 12:22:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232218AbhDTMWy (ORCPT ); Tue, 20 Apr 2021 08:22:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232167AbhDTMWv (ORCPT ); Tue, 20 Apr 2021 08:22:51 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CA56C06138F for ; Tue, 20 Apr 2021 05:22:17 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id n127so8243410wmb.5 for ; Tue, 20 Apr 2021 05:22:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=F/nBlWuE1tdIPOvGrTELqSDs2xw15fq2mf8SutZs5hc=; b=o+0JVYKJgPriBpqckcnWow7XjMQurQ+o2JzQXafmEYqX7FhKu15BUhJzSM0fmp4FRz n6dfWEy8LbvtFlXlHm7IifKFykAvT9VYaFFO7IpfTW39JQi+NUuvRXHKUe0LEzHBh7yy eIbkt1FyMNVMUUGvAVgTyFzJPjYr9eSFliRRBEvmqIJM1OEZVOZicziNMrFQMg5Soqwy hpfuIm7245uWP2AajcnCofbCn8xgOoxFrHEgHrM2D3nEKlGpOzGv0FbNzn1FrA5tVYh8 40s3qruKCWDRVeR2oX4mxEZqbQs1D2Y+oj7xfjnNjlYMMPYaz9vQdB6TMyCFsgYmYVC1 2KNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=F/nBlWuE1tdIPOvGrTELqSDs2xw15fq2mf8SutZs5hc=; b=mH0TM9i5D7vHNzX8dn974bHxI42OipmddYrYKCkwTrLd0nBxn/daWZne3DnjWJaafh kM3MIJT1QkEQLjWzDYglhxPI/mdYstmkTYtVGl8uDaijd5/HqwE3/x4bFsSFCwt58l2i h+MXAXrzlT8APgO5QHZOn0YmG+RqGlD/BX4ghsRX7MS4gosJi2PMnd8j58WJslDI8ZSS K5OY8HGdp88nTY4wktqs6GCYgqGXiHHgpXZ1q+WMCoZ9Q17xN39QtbHVNW3aMdNIqHKH owZEi6Jkpeb36kSkRfaU9rQ3uqWE/TjW4drAmAztHCXBFdKTIGrpt6RVgmKKuoDmSsAa bWpQ== X-Gm-Message-State: AOAM530IUYiTxjBT/Q0G8AuJL1O1reBv8DIZkesWq1ysAd4C+buZo+e2 NZm+r4l2eojkCADEqWCTaFE34pzzViuiTA== X-Google-Smtp-Source: ABdhPJzt8taLQvkpeuW5DBN6kbZ6M5nPPqf2gUy5gQdtO1soeLXn5VPcJ+2UUhQZ/fDdFjjLURsmLw== X-Received: by 2002:a05:600c:4b92:: with SMTP id e18mr4348661wmp.150.1618921336248; Tue, 20 Apr 2021 05:22:16 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b1sm30541768wru.90.2021.04.20.05.22.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 05:22:15 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Matthieu Moy , Johannes Schindelin , Eric Sunshine , =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7Ru?= =?utf-8?b?ZyBEYW5o?= , =?utf-8?q?SZEDER_G=C3=A1bor?= , =?utf-8?b?w4Z2YXIg?= =?utf-8?b?QXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v3 10/12] test-lib: reformat argument list in test_create_repo() Date: Tue, 20 Apr 2021 14:22:01 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.723.gf6bad1b9ba1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Reformat an argument list changed in 675704c74dd (init: provide useful advice about init.defaultBranch, 2020-12-11) to have the "-c" on the same line as the argument it sets. This whitespace-only change makes it easier to review a subsequent commit. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/test-lib-functions.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index dbeb3d9262..21271020c7 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -1257,8 +1257,8 @@ test_create_repo () { mkdir -p "$repo" ( cd "$repo" || error "Cannot setup test environment" - "${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X" -c \ - init.defaultBranch="${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}" \ + "${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X" \ + -c init.defaultBranch="${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}" \ init \ "--template=$GIT_BUILD_DIR/templates/blt/" >&3 2>&4 || error "cannot run git init -- have you built things yet?" From patchwork Tue Apr 20 12:22:02 2021 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: 12214131 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B39D5C43460 for ; Tue, 20 Apr 2021 12:22:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 82936613C1 for ; Tue, 20 Apr 2021 12:22:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232228AbhDTMWz (ORCPT ); Tue, 20 Apr 2021 08:22:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232227AbhDTMWv (ORCPT ); Tue, 20 Apr 2021 08:22:51 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3449BC061342 for ; Tue, 20 Apr 2021 05:22:18 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id h4so28363167wrt.12 for ; Tue, 20 Apr 2021 05:22:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tKDKLk+PjKYvWkPm8sNaufz+xJcQq+vr1o1v7Bvbpd8=; b=gvsOz114pd3+UtwncjP5XUy67eaNSKN0deO92A/Tc+98DjpHW/S0Pe/8mQW0ybYoWM 6iW4S2E5I+197aVD1erulIlOpjjRioLjHuANVtrICXaG76FOFVoV4mTv54R1i+tXG4t0 if+hFoq95/n4ZraBcxpIpkFkut9RhT45ivtN3SA3GXOfJMi3IO0bXJ58knAxA0JLcs2/ Y2M0hZmql7iXRaQTaSP5Zx5qWiuHGRyZmzm/MBzhPtlrUgmj7ALazeGSVTHHbxGIpecm QKpKQp9LyBsZUmcntfjGg+Bg4ih29kmYs+tPRV/8BSJM2ZwhMAaPrlXUzujm2EP21vKg psuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tKDKLk+PjKYvWkPm8sNaufz+xJcQq+vr1o1v7Bvbpd8=; b=aYjkej9YnIfY+Ayu1iaydgiuueSSjvvH46LH9Y3gPGuXSXjM7dcJ8OiRwa5vQIN/Kz y0srnEearm0k6xcfb2G93zfVZf8Zw3ceVs7YpvPgNXu47WiUH8zpD468CHHQqUCTgXTh b0LiFlfLWBIaADrpB/LqmsjcSNNy5Qt+17JJIrgGTH1LUAvJhFNUb5gZdIPMFAhLRlHh DrNlAbd1BWYWpYy+V7wJR5LamLNfJ6bCVe/LoeLT8nCz9vUouHrCcpUHi+prOGTptf5y jJYMw6CMlPPEHG8/Cr0Tq9BMrcw2fLAL+nG0p5WHpKOf7q8anxhQ+WfuObYUoFG0YuUC rHWw== X-Gm-Message-State: AOAM530fwkjmfUKssb/rS9pChLPrkLcnDdkiUzDJvjyopa810LNU7gZ2 u3xwANO+Iae8z6AfWUxUgdgnEdrnqWLsPQ== X-Google-Smtp-Source: ABdhPJzMFsARQCiJeel4FwFh8Y+1+Tvr74max1iackOuTNbV+LiC7hrotTrpSmJ3cY3LO9CRKQNGIw== X-Received: by 2002:a5d:6447:: with SMTP id d7mr20661419wrw.1.1618921337170; Tue, 20 Apr 2021 05:22:17 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b1sm30541768wru.90.2021.04.20.05.22.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 05:22:16 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Matthieu Moy , Johannes Schindelin , Eric Sunshine , =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7Ru?= =?utf-8?b?ZyBEYW5o?= , =?utf-8?q?SZEDER_G=C3=A1bor?= , =?utf-8?b?w4Z2YXIg?= =?utf-8?b?QXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v3 11/12] test-lib: do not show advice about init.defaultBranch under --verbose Date: Tue, 20 Apr 2021 14:22:02 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.723.gf6bad1b9ba1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Arrange for the advice about naming the initial branch not to be shown in the --verbose output of the test suite. Since 675704c74dd (init: provide useful advice about init.defaultBranch, 2020-12-11) some tests have been very chatty with repeated occurrences of this multi-line advice. Having it be this verbose isn't helpful for anyone in the context of git's own test suite, and it makes debugging tests that use their own "git init" invocations needlessly distracting. By setting the GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME variable early in test-lib.sh itself we'll squash the warning not only for test_create_repo(), as 675704c74dd explicitly intended, but also for other "git init" invocations. And once we'd like to have this configuration set for all "git init" invocations in the test suite we can get rid of the init.defaultBranch configuration setting in test_create_repo(), as repo_default_branch_name() in refs.c will take the GIT_TEST_* variable over it being set. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/test-lib-functions.sh | 1 - t/test-lib.sh | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 21271020c7..8e75a013a4 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -1258,7 +1258,6 @@ test_create_repo () { ( cd "$repo" || error "Cannot setup test environment" "${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X" \ - -c init.defaultBranch="${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}" \ init \ "--template=$GIT_BUILD_DIR/templates/blt/" >&3 2>&4 || error "cannot run git init -- have you built things yet?" diff --git a/t/test-lib.sh b/t/test-lib.sh index 7522faf39f..9ebb595c33 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -64,6 +64,11 @@ then export GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS fi +# Explicitly set the default branch name for testing, to avoid the +# transitory "git init" warning under --verbose. +: ${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME:=master} +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + ################################################################ # It appears that people try to run tests without building... "${GIT_TEST_INSTALLED:-$GIT_BUILD_DIR}/git$X" >/dev/null From patchwork Tue Apr 20 12:22:03 2021 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: 12214133 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3DA3C433B4 for ; Tue, 20 Apr 2021 12:22:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C5461613C1 for ; Tue, 20 Apr 2021 12:22:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232222AbhDTMW5 (ORCPT ); Tue, 20 Apr 2021 08:22:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232144AbhDTMWw (ORCPT ); Tue, 20 Apr 2021 08:22:52 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA79FC061343 for ; Tue, 20 Apr 2021 05:22:19 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id p6so30695067wrn.9 for ; Tue, 20 Apr 2021 05:22:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fYRYMNUQTSuyeIHpKLJ/CAznQPac7DR8nZ1PoBFK+5E=; b=LRVonTqBOmK/U92hl3wVJ6QFKJdY0XrVdbj0l3f06jWJgauYYSZDguo9dkHz6Hre8B HiVkcBTxLYXtLYq8EGkQR7Z9PMdMueAtVa+zWMgbwiXgpVY2RLAvwmKP96CExf7vycU8 T5cIJ3dfUwHB8ZmCgeQQ1DRcOluQHacV6YmrOgjM8SfkXrX68ot/XV7VhmshV8wNxyOk EsnxBfXoqIAOGlXJnWKSRiNkFKkQK5I40lEXSxL30tfJjL+h9kQWaV19d00vOarEEdVC orRTnz8R/H+6+MVR5KLGZyDi59+FhogDj8B1wDG0aK2azrmeljQQUeT4SMwBo4tAwmew +v6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fYRYMNUQTSuyeIHpKLJ/CAznQPac7DR8nZ1PoBFK+5E=; b=MlFt5YhbfZF9NEfQo7XevPnBKqeuxBA/js/s9+jqbx788a712HfII7InK9xFJGM8TP 2iRhgBg8k8ZTjEeUo5ajGfTg42DAULWttwyB9hEyUX0N4euxWT4c6CVi4LVS9b/34vCC aMVfPITToZ0DTMiCyG+5k8zn0DdZIT7ROPI1Qq+Qf/1Fc4pEoZGT39isUUp222ot+Mp5 QUo0u2GP2jgXdOIjTfh3F74xG+H+X/W0IVs18PEu9YkmHb79S0hOyLOoMk40IsKqB90d xBVacr47M50ndQdyX5ei7G0zUP/icEXeVZXx+PQvencnTRtQi1E04FMzwUgumr1IptbN V8oQ== X-Gm-Message-State: AOAM5322voFRyEdjSASg9fmq+O4ajehd5A91VrJ+W4PXEERZ4nMpqWCS VvviyW4whnbKOs9i2Bt0C56QMzOlbl5qOA== X-Google-Smtp-Source: ABdhPJxQ9qFcihSar+9LmS0ljkmGVxQdtK49E2YL40XnAFMv5r9P2Ie37yq5QUTooEc3nx7PdIpi8w== X-Received: by 2002:a5d:568f:: with SMTP id f15mr20597681wrv.346.1618921338305; Tue, 20 Apr 2021 05:22:18 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b1sm30541768wru.90.2021.04.20.05.22.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 05:22:17 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Matthieu Moy , Johannes Schindelin , Eric Sunshine , =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7Ru?= =?utf-8?b?ZyBEYW5o?= , =?utf-8?q?SZEDER_G=C3=A1bor?= , =?utf-8?b?w4Z2YXIg?= =?utf-8?b?QXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v3 12/12] test-lib: split up and deprecate test_create_repo() Date: Tue, 20 Apr 2021 14:22:03 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.723.gf6bad1b9ba1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Remove various redundant or obsolete code from the test_create_repo() function, and split up its use in test-lib.sh from what tests need from it. This leave us with a pass-through wrapper for "git init" in test-lib-functions.sh, in test-lib.sh we have the same, except for needing to redirect stdout/stderr, and emitting an error ourselves if it fails. We don't need to error() ourselves when test_create_repo() is invoked, as the invocation will be a part of a test's "&&"-chain. Everything below this paragraph is a detailed summary of the history of test_create_repo() explaining why it's safe to remove the various things it was doing: 1. "mkdir -p" isn't needed because "git init" itself will create leading directories if needed. 2. Since we're now a simple wrapper for "git init" we don't need to check that we have only one argument. If someone wants to run "test_create_repo --bare x" that's OK. 3. We won't ever hit that "Cannot setup test environment" error. Checking the test environment sanity when doing "git init" dates back to eea420693be (t0000: catch trivial pilot errors., 2005-12-10) and 2ccd2027b01 (trivial: check, if t/trash directory was successfully created, 2006-01-05). We can also see it in another form a bit later in my own 0d314ce834d (test-lib: use subshell instead of cd $new && .. && cd $old, 2010-08-30). But since 2006f0adaee (t/test-lib: make sure Git has already been built, 2012-09-17) we already check if we have a built git earlier. The one thing this was testing after that 2012 change was that we'd just built "git", but not "git-init", but since 3af4c7156c4 (tests: respect GIT_TEST_INSTALLED when initializing repositories, 2018-11-12) we invoke "git", not "git-init". So all of that's been checked already, and we don't need to re-check it here. 4. We don't need to move .git/hooks out of the way. That dates back to c09a69a83e3 (Disable hooks during tests., 2005-10-16), since then hooks became disabled by default in f98f8cbac01 (Ship sample hooks with .sample suffix, 2008-06-24). So the hooks were already disabled by default, but as can be seen from "mkdir .git/hooks" changes various tests needed to re-setup that directory. Now they no longer do. 5. Since we don't need to move the .git/hooks directory we don't need the subshell here either. See 0d314ce834 for when the subshell use got introduced for the convenience of not having to "cd" back and forth while setting up the hooks. 6. We can drop the --template argument and instead rely on the GIT_TEMPLATE_DIR set to the same path earlier in test-lib.sh. See 8683a45d669 (Introduce GIT_TEMPLATE_DIR, 2006-12-19) 7. We only needed that ">&3 2>&4" redirection when invoked from test-lib.sh. We could still invoke test_create_repo() there, but as the invocation is now trivial and we don't have a good reason to use test_create_repo() elsewhere let's call "git init" there ourselves. 8. We didn't need to resolve "git" as "${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X" in test_create_repo(), even for the use of test-lib.sh PATH is already set up in test-lib.sh to start with GIT_TEST_INSTALLED and/or GIT_EXEC_PATH before test_create_repo() (now "git init") is called.. So we can simply run "git" and rely on the PATH lookup choosing the right executable. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t5406-remote-rejects.sh | 1 - t/t5407-post-rewrite-hook.sh | 2 -- t/t5409-colorize-remote-messages.sh | 1 - t/test-lib-functions.sh | 15 ++------------- t/test-lib.sh | 3 ++- 5 files changed, 4 insertions(+), 18 deletions(-) diff --git a/t/t5406-remote-rejects.sh b/t/t5406-remote-rejects.sh index ff06f99649..5c509db6fc 100755 --- a/t/t5406-remote-rejects.sh +++ b/t/t5406-remote-rejects.sh @@ -5,7 +5,6 @@ test_description='remote push rejects are reported by client' . ./test-lib.sh test_expect_success 'setup' ' - mkdir .git/hooks && write_script .git/hooks/update <<-\EOF && exit 1 EOF diff --git a/t/t5407-post-rewrite-hook.sh b/t/t5407-post-rewrite-hook.sh index 5bb23cc3a4..6da8d760e2 100755 --- a/t/t5407-post-rewrite-hook.sh +++ b/t/t5407-post-rewrite-hook.sh @@ -20,8 +20,6 @@ test_expect_success 'setup' ' git checkout main ' -mkdir .git/hooks - cat >.git/hooks/post-rewrite < "$TRASH_DIRECTORY"/post-rewrite.args diff --git a/t/t5409-colorize-remote-messages.sh b/t/t5409-colorize-remote-messages.sh index 5d8f401d8e..9f1a483f42 100755 --- a/t/t5409-colorize-remote-messages.sh +++ b/t/t5409-colorize-remote-messages.sh @@ -5,7 +5,6 @@ test_description='remote messages are colorized on the client' . ./test-lib.sh test_expect_success 'setup' ' - mkdir .git/hooks && write_script .git/hooks/update <<-\EOF && echo error: error echo ERROR: also highlighted diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 8e75a013a4..bd64a15c73 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -1248,21 +1248,10 @@ test_atexit () { } && (exit \"\$eval_ret\"); eval_ret=\$?; $test_atexit_cleanup" } -# Most tests can use the created repository, but some may need to create more. +# Deprecated wrapper for "git init", use "git init" directly instead # Usage: test_create_repo test_create_repo () { - test "$#" = 1 || - BUG "not 1 parameter to test-create-repo" - repo="$1" - mkdir -p "$repo" - ( - cd "$repo" || error "Cannot setup test environment" - "${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X" \ - init \ - "--template=$GIT_BUILD_DIR/templates/blt/" >&3 2>&4 || - error "cannot run git init -- have you built things yet?" - mv .git/hooks .git/hooks-disabled - ) || exit + git init "$@" } # This function helps on symlink challenged file systems when it is not diff --git a/t/test-lib.sh b/t/test-lib.sh index 9ebb595c33..06026bbe75 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -1364,7 +1364,8 @@ rm -fr "$TRASH_DIRECTORY" || { remove_trash=t if test -z "$TEST_NO_CREATE_REPO" then - test_create_repo "$TRASH_DIRECTORY" + git init "$TRASH_DIRECTORY" >&3 2>&4 || + error "cannot run git init" else mkdir -p "$TRASH_DIRECTORY" fi