From patchwork Fri Apr 23 07:21:05 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: 12219745 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,URIBL_BLOCKED,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 AFDE0C433ED for ; Fri, 23 Apr 2021 07:21:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6B249613DB for ; Fri, 23 Apr 2021 07:21:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241063AbhDWHWB (ORCPT ); Fri, 23 Apr 2021 03:22:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240981AbhDWHWA (ORCPT ); Fri, 23 Apr 2021 03:22:00 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8A0AC061574 for ; Fri, 23 Apr 2021 00:21:24 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id sd23so63799244ejb.12 for ; Fri, 23 Apr 2021 00:21:24 -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=xEXil81XGsIn7ez73csuPkHBu+5/DvCKlakTqsUpZTQ=; b=pm4NHmJzNq9bMcv4V1/0jyf55iqaoDvn+dadIy+5ToYCSRWhwjujIBN54lI0vs6GcU I8V02u3TaJjQzi7ow58wyqaikHiSbZJG+X5B4vbdWckx6DWqMCcF2hIDlhM0m5dfu0iz 4nituUE+ZrTxVYnuU2luRq729LEJxjTooD5LbAC2KtSD5lpHNoS74xPjQh0eCmcEf6rk bsfWal+RfjA0LBeI+Ste/ellHHrHQDUaun1HYYNfJp4NPx1PwJak0cfoKN9vYm4zsKKm FD/9Q3P7uUr9TNq4yxgYkiCH6mdtckHzSDHN/lcTJuP5nfkOA6jCs5gp0gM5NhtoXYYv BHJA== 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=xEXil81XGsIn7ez73csuPkHBu+5/DvCKlakTqsUpZTQ=; b=JDchjIg63mg+wyYkKAmXqkFVJwyMKscs7aq1yXsXjM0fV0VyQpyjk8KIcjn4mRKjNV e2bfQtetAHRcUcYHDesdcXjhFT/BRdQXb0oKf0U2pBhdgTLN/2BvsPplVBdG6llsBiAd +zQ56Jo6fQLmDEuaT4MVC6V48rAe+7r1j7XXQwdIAwY1D1BSP4dIhGp62YIiF0Yn6BZM xSLmescjHBE0ByYhvd2yzC+B2O7AklFvty3XHAEluwUhVrT871JHeTZ4nhZcGXbX928I aiFSgBVAmJ974IztXdC72WFeaALtJj3hcIOrjgKaEH5Lo16dpBY2ogUyQKgab3lWyDEr 54lw== X-Gm-Message-State: AOAM532teBnrtOPEw0JWs+64frNbDRUZI4TLpCyUYu+YqOVpB7YzCh3z WG4cymdmiEaf600+RS78N9tk67kgzKE= X-Google-Smtp-Source: ABdhPJyx3KBepqVfSPOrMvO90bAqSLoYoyJh4Bfsk3VLb7yuF09wEbxJfQS1QpDBcP4IMvYMtF4HKw== X-Received: by 2002:a17:906:1c17:: with SMTP id k23mr2783677ejg.266.1619162483179; Fri, 23 Apr 2021 00:21:23 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id e5sm3328892ejq.85.2021.04.23.00.21.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 00:21:22 -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?= , Andreas Schwab , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 01/11] test-lib: bring $remove_trash out of retirement Date: Fri, 23 Apr 2021 09:21:05 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.737.g98b508eba36 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. Let's also fix a bug that was with us since abc5d372ec (Enable parallel tests, 2008-08-08): we would leak $remove_trash from the environment. We don't want this to error out, so let's reset it to the empty string first: remove_trash=t GIT_SKIP_TESTS=t0001 ./t0001-init.sh 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 | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/t/test-lib.sh b/t/test-lib.sh index 3dec266221c..105c424bf56 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,22 @@ then exit 1 fi +# Are we running this test at all? +remove_trash= +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 +1357,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 +1369,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 Fri Apr 23 07:21:06 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: 12219747 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,URIBL_BLOCKED,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 372E6C43461 for ; Fri, 23 Apr 2021 07:21:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EF8E5613DB for ; Fri, 23 Apr 2021 07:21:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241081AbhDWHWC (ORCPT ); Fri, 23 Apr 2021 03:22:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241042AbhDWHWB (ORCPT ); Fri, 23 Apr 2021 03:22:01 -0400 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 93068C061574 for ; Fri, 23 Apr 2021 00:21:25 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id l4so72407480ejc.10 for ; Fri, 23 Apr 2021 00:21:25 -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=HWPFD3o28WzQ3Wbp4zpIg+jBG+f0FsnCaqvh4pw8C74=; b=ClRedicbXNPt5Wola1vijO+R+jCrxwAHJDWjT4c+g5reLV7vWoJWOuCywXWrSUVMep 81QwphYlUAdF1+n1Mt1O+Cnr5/Z26MFJvN3h7qMyv9mc0BQqEkrozXoUTJIsY+qr95LC oneKOk5GT8CsKB4bUwlfjYC7UkiPbAQdxdYQZqgX5cQCwf2rzfAGZ8N9Vl3Tr6SjibBC gEuf/dQmdrNgCpt3uRpLyShKYWZSSF8vibzKZuRYg08P9excjxAkiVo+EaIC5AP3GfPI 2V0qGZ57b+jNkfjlxQtP8gPjuKzKmENKqi0sCNDHY/J4BjmoBgNiOK8vaU5XXK3p/uR7 m8Rw== 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=HWPFD3o28WzQ3Wbp4zpIg+jBG+f0FsnCaqvh4pw8C74=; b=Lfb2bxtP35Hh1YY8YgTG3/sUYvfpVYuDeWH2lioRu2i1GNmCCbVIYu9x16quggzh0I Sj9VuOFS9f1C6yXq5UZyJYCip2nIKRv2v+7NsYWyizi3u7AsPJSiuswba+oyyMdUEli+ dI92/D4bx6nQHEy4AFwUEGQQBsLOGxJtr21rq6oCkzjJFwNfvOAZMIecKOulKlTYlJ4B 8KbH7VMBt9a5vJ0NgGgFezyh6rOEodZ+Q8NORkFIW2lBBEVPppoYdD9CWiwx8vYhF7bT +FCz6FM38w1M5g8/urMP1feNgE7EtZN8TgOOxFDg0ljzOAw/ABuQy+bOS9e08hCe7Tr5 Qd9Q== X-Gm-Message-State: AOAM531E8Xsv80F7briVDqg2gv1GFtOgf6GObvGA+WR17Voyu6sVhpAN E8MLiWbZayGEiDGnalc+Pzf1mMKrgg3YNg== X-Google-Smtp-Source: ABdhPJwx87eJ5f6cHeGVIzW7MHsecVKm53+/gpgKDJlg1fuWKPV8VMpAzPmFjRNQ3Ujkz01tGPxV6Q== X-Received: by 2002:a17:907:9852:: with SMTP id jj18mr2672863ejc.382.1619162484071; Fri, 23 Apr 2021 00:21:24 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id e5sm3328892ejq.85.2021.04.23.00.21.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 00:21:23 -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?= , Andreas Schwab , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 02/11] test-lib tests: remove dead GIT_TEST_FRAMEWORK_SELFTEST variable Date: Fri, 23 Apr 2021 09:21:06 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.737.g98b508eba36 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 705d62cc27a..2c6e34b9478 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 Fri Apr 23 07:21:07 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: 12219749 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 56B22C433B4 for ; Fri, 23 Apr 2021 07:21:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 12C80613F6 for ; Fri, 23 Apr 2021 07:21:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241108AbhDWHWE (ORCPT ); Fri, 23 Apr 2021 03:22:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241084AbhDWHWC (ORCPT ); Fri, 23 Apr 2021 03:22:02 -0400 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D9DCC061574 for ; Fri, 23 Apr 2021 00:21:26 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id bx20so55213204edb.12 for ; Fri, 23 Apr 2021 00:21:26 -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=6eAGV+SGgl4/D6wWoMy5/26yub/JJ7qeBPPHXgpF7SY=; b=U1rFOm5pyEjb5D9+gg1DO0SYSuo2eJm8jYGXpI3u+8MRO5tuKNJgDsytaXQlLiT2CC MoFUphnKgkeVzPs07rpo1NElcVm+ZnQl20DlMmFwOOdco45cQgXqxJrG5/7/Oby9Kw0l SFq0EHCJvg7XxQC+qKoUuPyzTmc0hLlxGdsPwXLHYXqTD6XoAa62FON+XzYe8RqJCAhZ rx98TfsrU1Dj+iFRU98mOoQXS4r+26vWxocuxkw81ZWwhiIZhvP9auammnZs63uN+Y1x 0xVkAgMBCw1KaIJDjcl5DrBcMKB7udpFG+1fUuYJvUA0Yw0Dtr1wOlCQl6oQBtnoZc5b e/vA== 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=6eAGV+SGgl4/D6wWoMy5/26yub/JJ7qeBPPHXgpF7SY=; b=eXtdow2Ka/w/fGUfcJEcyMuq0nqVjHCZ8jU2ny3k9E5cdjczAT75YH4ezztxbglBeW y8hOnGtuE9opbw9lSsnOXAL8gaLNDhMUEd7FEITZjT7bTLVN1RcNqv6FjaIolmuszmxY 2xQOlHi3IQHMdXgPGlXyNMdngMfTUEyVCeZJAbAcaSyKgNsNRC1G0ZPhwDetKuUdTTYJ htTz2fEdpeKrnS+bMYUo+sGbFalugjZ9IZyHPNtAMSvyMG35LJF+wq2pYIVdycrdG9IS gs4Rd0okvboN+hq++Af8T1nUHXNgQNQ/IKFrMi8apUxXs4eu9DtFpBpY339zpRt10TrW gMjQ== X-Gm-Message-State: AOAM531vLi76J5cMX5p6UPCsu5iXtTRXvVRn7h8kX3aziOM4rOXNDS3J ij45elUq8j/YFcgUPC+wRCOVlTaM1DIGTw== X-Google-Smtp-Source: ABdhPJy7pwujbeH/ogTM2KCOYfyQV/WdpfoTGDh3eZF7R6yUBZx3ywP3BbVQSoTl80RJq4prJ3634g== X-Received: by 2002:aa7:cb4b:: with SMTP id w11mr2787639edt.216.1619162484927; Fri, 23 Apr 2021 00:21:24 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id e5sm3328892ejq.85.2021.04.23.00.21.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 00:21:24 -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?= , Andreas Schwab , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 03/11] test-lib-functions: reword "test_commit --append" docs Date: Fri, 23 Apr 2021 09:21:07 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.737.g98b508eba36 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 b823c140271..1f787ff0726 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 Fri Apr 23 07:21:08 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: 12219751 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,URIBL_BLOCKED,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 D423FC433ED for ; Fri, 23 Apr 2021 07:21:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ABF3D613C4 for ; Fri, 23 Apr 2021 07:21:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241124AbhDWHWF (ORCPT ); Fri, 23 Apr 2021 03:22:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241042AbhDWHWD (ORCPT ); Fri, 23 Apr 2021 03:22:03 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A5BAC061574 for ; Fri, 23 Apr 2021 00:21:27 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id cq11so12716042edb.0 for ; Fri, 23 Apr 2021 00:21:27 -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=hQkAHZxPbZg1lWB15Ac5eA2xTa2m+/IgB8T1GmhbxV0=; b=VFyWFyIuQCyiGa0E22MeXeqfjI0NBDwms9xk4wQPVW2Q19jwNSKuXWRrpCe3HkKuG9 pwfD8HhSUAXJOsRHzABTgaj9d9rLJhj4ysI9y9dLNyiS7KGYbp06IfCuB+C3k6fcD4ug vnviRw+9tJrsHyjad0yNqTJtjRH8UHWjJnENKMm9Mx2d7Tt4fLtuRwKjmiB0lvctOO7u V1PXwPwXLwoJpVUT1/Xj3sSzpQfuZ/J+HzG92O15QdeTAt5PZnhfzcQ7jLWQ3GdUF/n0 dgxRWX9zDIs5ps6eZgENyLZJFAIPBFJnFKCJuiXeE1WOO0iaor/d3bHW/ycgaKswCtDW 0QwQ== 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=hQkAHZxPbZg1lWB15Ac5eA2xTa2m+/IgB8T1GmhbxV0=; b=swJScG1QyXwj8yyif6DeqKbifjfpJeroLjpZ6EX/0YcJIdZzYFqfusJsdbSA0DVW5Y 3CYFu9vZJRRSIkU01qNRseg7qMATrtogM35Ugw29wv8Up5H6dchL3xlTYSunrTUHgaGZ PhHghr68/EYqw9qbq1M9EwTrHs84okLrFoAVQFA2oaCUqm8sXIurjg44hQhkYRXErRS/ VLdHDxKz4m8exXjmARabls6SI2VsXIyPXwcTltWCbxIrIu7v5pwTE4YxDSrfvSZzFp56 TdDibPamIoOzP+8n7B7QF7HNIDy6IjzIHVqHA2Q6fnXS1h+NVVucHxyrkoJWs0Eom7m3 0l5Q== X-Gm-Message-State: AOAM532kK2/Jrinn6oRFex5kNPFVh5jQ+WODrfdTu3VJx1WJaA+pVT5E IYeVf6u8317hmBsAIVR2SMRAIZGrc0hvhQ== X-Google-Smtp-Source: ABdhPJwaBYbCsadLly8atQ27ggHS0pNjqHbL3Au5OwVGYgIEkMifVeKpr3UuoTvCNvqvm2BlMMGZgA== X-Received: by 2002:a05:6402:2290:: with SMTP id cw16mr2939736edb.162.1619162485728; Fri, 23 Apr 2021 00:21:25 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id e5sm3328892ejq.85.2021.04.23.00.21.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 00:21:25 -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?= , Andreas Schwab , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 04/11] test-lib-functions: document test_commit --no-tag Date: Fri, 23 Apr 2021 09:21:08 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.737.g98b508eba36 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 1f787ff0726..c6d07f4ce32 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 Fri Apr 23 07:21:09 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: 12219753 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,URIBL_BLOCKED,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 AB81AC433B4 for ; Fri, 23 Apr 2021 07:21:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7B6B8613C4 for ; Fri, 23 Apr 2021 07:21:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241176AbhDWHWJ (ORCPT ); Fri, 23 Apr 2021 03:22:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241093AbhDWHWE (ORCPT ); Fri, 23 Apr 2021 03:22:04 -0400 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 0C35EC06174A for ; Fri, 23 Apr 2021 00:21:28 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id n2so72425738ejy.7 for ; Fri, 23 Apr 2021 00:21:27 -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=EVcyhVyfa+/+3jSQtfdgy6Yrq9vDAtx0TJY6PrTOgdU=; b=RbziMKSbmV3SlOq17O1I7vEU5+JM0hQru87hBOtd3L7DmFWvLqh/olk/BdbdL3wA8U HGaYHcjQ4e6K1Qm9Jy8BANJigTxQDHtur/LMkM4RrACWxGs4xmEabvtcQdz/WDBcYlGx vubmcC5nDFAvGlw1IrTz0+XqVnDPbMnbI+UyeorScKQmDXZWApBjjrIMBcWkZzsszqC2 fFnQuKbFQZMnmyzKXX6TM611dCh+XlsjFOaey96JWzXmOLVldOtGQvcAVzYG3wsQOSao 5b3z06db5tx3GIefGccM24hWvhu6k9PFcEJdVnY3xSrHRfBiFcgdlxmHVTz2IWPcA8lS zEpw== 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=EVcyhVyfa+/+3jSQtfdgy6Yrq9vDAtx0TJY6PrTOgdU=; b=WSZ/8/PSim32EKdqmTJAgJyvOoc7pNvYrIx2lRWJ5qynFUPBBremYjWL2IK2y8McH0 7Z+H6gPYMBKBesQfP9dTfKRgndh+zzw/ZIcoklqTzc2ROXTFSAjrv06z24FCG6pbqmHw rwOMATMbzUqfvQ56fXCZ3Ijl6lgXPwx3DytTMtvg08rsA/gMO0hKifQ6nrw3QVwySh+W fxGBbuEmZp1AftssQLv0tpK7tu37eZeFQ5BQHqRFhfg7ZqBn4czlyBD2yOb+iv0/sl3H qP/kU0Tvtsr2fKLFJnPD+vXykz3mOyUyJ6A/SApNfBPFC9lkzV2DPgqUyG1hxUcR+swO n3Dw== X-Gm-Message-State: AOAM531YEtzDeCKdlH670WSr4yn6EzuUn+FxP/YM2QNwndJ9s5FvFRkt 2h2R/jGvETwTdHGmIF77+elQU9G6WsgfbA== X-Google-Smtp-Source: ABdhPJzN3EiZFLdQHcQbvKyIelUaDgrLnTQ2GdqutlQ1ZZLVXB17GiddGYIkrgg8p18oeEROcHXj/w== X-Received: by 2002:a17:906:1114:: with SMTP id h20mr2735639eja.453.1619162486571; Fri, 23 Apr 2021 00:21:26 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id e5sm3328892ejq.85.2021.04.23.00.21.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 00:21:26 -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?= , Andreas Schwab , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 05/11] test-lib functions: add an --annotated option to "test_commit" Date: Fri, 23 Apr 2021 09:21:09 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.737.g98b508eba36 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 6ce62f878c3..17d3cc14050 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 c6d07f4ce32..827c8502b10 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 Fri Apr 23 07:21:10 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: 12219755 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 E316CC433ED for ; Fri, 23 Apr 2021 07:21:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 959EC613D7 for ; Fri, 23 Apr 2021 07:21:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241093AbhDWHWK (ORCPT ); Fri, 23 Apr 2021 03:22:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241122AbhDWHWF (ORCPT ); Fri, 23 Apr 2021 03:22:05 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F17BAC061574 for ; Fri, 23 Apr 2021 00:21:28 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id l4so72407682ejc.10 for ; Fri, 23 Apr 2021 00:21:28 -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=JyTvO720VkeLR2TGP2Iq4F9eggtM9ekpwCalzYbDvMQ=; b=b3+HeGij3n+nrtqiQLgfBf6dl5XPIMHMq6DO5Gfm3DnfKz/ji2x76lxcrp7iOipODA tZ1U6y+uop+7bp4wDs9Sa8vqp8jG814VvJ4dKfWfqoLhJxuLSStdyHYBdOIm8wX2DuWw P0ssKdCq9Ft4riBTgl+VlrdLC+EcF+zL2F0A2a/sENFH8LvI5mTVlhOYVJBRoTWBxele /zVxQrRTcVM2x+J9rL8W9uUtlSr2wlI0XSe69XQ5wST/1k4ARhsYVX+oewZF2OGo3nhS RQ2wwRxhJ528jk37fpeL60kX2gCwyUXLcc34bR6dbU8uRFzW11Q2gd+RXvRBQ8kp+GSo ZBNA== 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=JyTvO720VkeLR2TGP2Iq4F9eggtM9ekpwCalzYbDvMQ=; b=eiDAmYku/Bkbg6Ir9w9jLEbI1i/CGHyKPyQex9Tq2BEU2TfN3sSKFDq+ByMZI6jrZV wHnnRgnHQjuZwI+6laSAcHCdJWM5vnSJr4FXQX6S3/S3YTvXQTe4DhjXgJP+Ps0PbxVi yEXLIbZbdLD8EyCmyWdSWXZgNYFIUj2O7x9Hic7V0Ywx81Oaq0bCgIj2+4eG2A61iVHu /ClypRS0jG5WSqpdpHjqiZrnSefZGcUbytrp5eggoRMj7ATuc+M1ycZQOORWaxTwb4Bx vzw6ZOZWRdUvjUXyEiHTGDUkNPFmsiItNj+odsr2vykkyzHGqSvyR8+zQ3v/ckpC6RnQ 2Sww== X-Gm-Message-State: AOAM530dt0IhAFvlBfc04xTnrSK2PyCzKClC3z7cDTc25gfFXkiN50zT PXhm5zPIG1pKQdu15fvu9g+1AbnlLr1KoA== X-Google-Smtp-Source: ABdhPJwohRGSE0+bE6P9hlSNBhqtPlJlBus1w93XrL4tRF+a2qv1oHQGYtYmPo/j+G33EVWMVSuaMQ== X-Received: by 2002:a17:907:2d89:: with SMTP id gt9mr2726725ejc.122.1619162487357; Fri, 23 Apr 2021 00:21:27 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id e5sm3328892ejq.85.2021.04.23.00.21.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 00:21:26 -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?= , Andreas Schwab , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 06/11] describe tests: convert setup to use test_commit Date: Fri, 23 Apr 2021 09:21:10 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.737.g98b508eba36 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 e89b6747bee..88fddc91424 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 Fri Apr 23 07:21:11 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: 12219757 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,URIBL_BLOCKED,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 8F715C433B4 for ; Fri, 23 Apr 2021 07:21:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 59987613F6 for ; Fri, 23 Apr 2021 07:21:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241208AbhDWHWN (ORCPT ); Fri, 23 Apr 2021 03:22:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241143AbhDWHWG (ORCPT ); Fri, 23 Apr 2021 03:22:06 -0400 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC72AC06174A for ; Fri, 23 Apr 2021 00:21:29 -0700 (PDT) Received: by mail-ed1-x52c.google.com with SMTP id cq11so12716172edb.0 for ; Fri, 23 Apr 2021 00:21:29 -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=zrXIOI4L0plac890N48Qghwz38Dol/MaG/KKajqW4c0=; b=VZv0tNVvLA7BnlXIKP+YF3rCiLbeq5v9JVSUW91zs11QzAbxNQQbvDBPfYKtOP7dLd Xh06cAqcr6IM6IDgMOfQH14ecfID2rxYCV8wZ2+6IoAlQXk1JzMSkwX/hUXq4EN9gkJM XImFblEfBIvM8r5/bJoZ7cwJUzdtasANMvsoc2XeNfSA2sQcVM4wvcbwSHBHuqXnn3Fs yVYm2EKgbg8iu7/C8uHaP13o8xhz8aJS5L9kdVCWIjdOjcVzCyrM/OKSKZgdXUnOCjbc Ds9U1amPDKsG4dWA5Drdha4OeIxIlASDxVPXUoD0O/xBeibrsPHxzfpmy/7D2fCBuzUT IWTg== 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=zrXIOI4L0plac890N48Qghwz38Dol/MaG/KKajqW4c0=; b=GqMWVIBU0nf7RrSQlCi98M8kdcwLugo3Hu8gCVUVh7rD+ly1y5NwCeS4KsJjxG7iEv YWL3NwQt/mA0yQ8bYxIENbpvkaMgfzPqTzta7yIbZnUzkV4cLkEScrmCFcbf3sqUtgF2 LUtLAh1i1nGYkObLZXoOI0o3NjXR+ly/dG91/jc44gxIYvQVfUCcLJXYUtyuZ3RmPBny A36W0Yz1Yzam+EWqPuEWXskR4MK+Qeq+LTotj6PbUGeyqPN3RoDs5WkMW5NdwfNNPBKE sU+2K4leMQ318dJIQsa4vB4xd5nRerD93oVADIcazG1AC/j8XnEXS/+bvuyzpJu2EAxO haJg== X-Gm-Message-State: AOAM533Xl1ehQR7xJXxJ3uJR/JQO6AG498qvA31/4VptRo6uMIDZlQqT WOCAHs0VuII4JLMhAf/Ouc4cC3qUizxklA== X-Google-Smtp-Source: ABdhPJwqyCYOQOfoHu/NEcEHSYLVTeladNglt3L1tsbhMYXnQ9NHZ456GhKbg4sMzIzicUJ8013HJg== X-Received: by 2002:aa7:c789:: with SMTP id n9mr2855087eds.352.1619162488342; Fri, 23 Apr 2021 00:21:28 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id e5sm3328892ejq.85.2021.04.23.00.21.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 00:21:27 -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?= , Andreas Schwab , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 07/11] test-lib functions: add --printf option to test_commit Date: Fri, 23 Apr 2021 09:21:11 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.737.g98b508eba36 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 002e6d3388e..930dce06f0f 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 be6c84c52a2..f691e6d9032 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 275ce5fa15b..6cdee2a2164 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 c906320b60d..a39a626664d 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 a09411327f9..e2c0c510222 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 827c8502b10..701518f5fd3 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 Fri Apr 23 07:21:12 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: 12219759 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 2DE46C43460 for ; Fri, 23 Apr 2021 07:21:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F1D32613F6 for ; Fri, 23 Apr 2021 07:21:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241215AbhDWHWP (ORCPT ); Fri, 23 Apr 2021 03:22:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241133AbhDWHWH (ORCPT ); Fri, 23 Apr 2021 03:22:07 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3986C061756 for ; Fri, 23 Apr 2021 00:21:30 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id u17so72499666ejk.2 for ; Fri, 23 Apr 2021 00:21:30 -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=aCONEBz4ThHDEi5xs1FaYtvLf0qUdL8F0aToP62cN5Q=; b=GrftDUqy/8tV1EweREgS0P+o/oz70+yH+uunqt9Gd0vHO2aaLrDhwaIw0rYDWU+lmW HUucA5tXvaJdJsFNNqUbg7M/KLBU9x/nv1mdK8Qi4WLW90B+pB8q9MbUkF9so4VsRTgo zdTzCMcUeRXytlv6JgU6AAedTrShaaBBXWXVZZRKnvjWCJ6XdHz6K7WA/Ltc3ZA4Vyz7 035iSkbyZSr4mdOTnbFjFTPhApQ3glXJP79IbQf1cMICOakzSXWl93y8GQ8HsojOp2ZP JWko6UZOP4iU+v9Nbqd+Jhc1M9Csz8htwTUotGo0holbspdWGUiZjjRXnP1rBRu2yHMZ dMug== 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=aCONEBz4ThHDEi5xs1FaYtvLf0qUdL8F0aToP62cN5Q=; b=cgQKa7Vdw5It4n1WjEvtEuCcyK/SI1aUw2C1e2v0wHckQx5AgjIU1hcdZ8+y1CQnQp FPusSRn5lVH1DmYn1FY1mabWtjGgRdjdvp3jclanq8bBnZlmRNOMzzoHQuButvwyPbM8 oLyaYEesXfdJCOPnAOXEQWrI8UqSLrHVQV/Zk5i2YmcZIydGogtSvbBmmOeyDpTwbUOR TAShCuPlFnGWZlDm0nEygBMtze5WE5Ygnbevk1thH2+Fm1ouBDZt2cYfG6rahdP57l/u bNIijlojWFYqQcrT0u0xckr1rDMRhpvrhKRO/vcJxQV+YtWUjcAg4AUWelOIggDMMgJ0 QiLg== X-Gm-Message-State: AOAM532+vAAMR6DOFZmmf//ZlBC8zRWhSkYcL+wIj/3RuB9Jk3xEqOGQ kJoJmeDGwmNozMoK17P6dZxhQfnB/ACvHQ== X-Google-Smtp-Source: ABdhPJxGi8AX25mm0p4CT9jv7eM/EDnQssVYrLF41iNeqL46DnId8eAHcc4TFgIc/6Rj194sFSjwZg== X-Received: by 2002:a17:906:7c9:: with SMTP id m9mr2818667ejc.54.1619162489345; Fri, 23 Apr 2021 00:21:29 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id e5sm3328892ejq.85.2021.04.23.00.21.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 00:21:28 -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?= , Andreas Schwab , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 08/11] submodule tests: use symbolic-ref --short to discover branch name Date: Fri, 23 Apr 2021 09:21:12 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.737.g98b508eba36 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 4b714e93083..f7c7df0ca42 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 Fri Apr 23 07:21:13 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: 12219761 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,URIBL_BLOCKED,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 CAC80C433ED for ; Fri, 23 Apr 2021 07:21:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A28F8613B0 for ; Fri, 23 Apr 2021 07:21:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241225AbhDWHWR (ORCPT ); Fri, 23 Apr 2021 03:22:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241172AbhDWHWI (ORCPT ); Fri, 23 Apr 2021 03:22:08 -0400 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE28EC06138C for ; Fri, 23 Apr 2021 00:21:31 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id l4so72407851ejc.10 for ; Fri, 23 Apr 2021 00:21:31 -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=HPSUHzZZL/xBCnSrflKB6XEtFMD8Ya2BEQX9miZhu5Q=; b=Tv0BSbCNXgQQXpaWMP+F1c/Gh4FdgY/YNR5jPP7v9GLGwBx4OtZhPv00FOUwgBH+Cn eSJDt4J0taRRRD5tQf18aXUTiaq1EWi1QC+P7viL5kZbkC9smVGxGQ1E7K4SySaPUgRT DHFBkZDSLzTQVPM6JhJkZ/moSNPpoOkC8wEfJww9sKrc61UZCe4Bvc8BrlYIs0qSml/z TrPSbKMpkblo8AMIptCFLYxev8Wm6Uz1p8IJl1OGzxJ7fjHk1jbdux/iwfml5LuCLA/V 5AZIzsyCHk8TxuQfyujHOTsvqxlr2cWb+4OK2TiTcapaJKcby3Fy8SaVXOzZFIUMr1IG 7ceQ== 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=HPSUHzZZL/xBCnSrflKB6XEtFMD8Ya2BEQX9miZhu5Q=; b=uCQP8y7PmIm8tjNB6SFpJWpSgMPy2bSefRdDlGvnV8nvvWXpHgLj+QE0YEmmJ1oFyc 7tODZNb371D6njpl0T0bTYxz1LZnlho+zYSFd8NjXUTvByIv8J5PsuKGyO0J+oLPCMtq XrDnOlaZj9hlB7xFQFGXL0r0JlHdnQEgwbXsAT1ixV5NhI0DG+Ch2QWzFBkfckhwNDzp 9jqET4c+qwarVX/zu3wcXjvAB3+itLaxYOKg8jqFUqbknk82sjh/HSFLESQOz/y+RmYX byfDj3E/MeMB64fNBpQSinVLjwkNV7Kvagx4tgqEyhh7nKDFc+/t4qX2kk7gq1kogb4W wosQ== X-Gm-Message-State: AOAM5327s5E7XIg/ueZhEQr8otbejBEjBHe9a6yKF+XPTUP86CLfnq/z EaGTUmt1kIhpbigf34kV6xR5lzAlpdRJMQ== X-Google-Smtp-Source: ABdhPJwg5Ip14mRA8GZn9t/WrHI3A0zfB1/RlDcIe5fvFJzMP68K1fNRjedSZndMfYnIkMyrSvphfg== X-Received: by 2002:a17:907:3f9f:: with SMTP id hr31mr2648806ejc.349.1619162490205; Fri, 23 Apr 2021 00:21:30 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id e5sm3328892ejq.85.2021.04.23.00.21.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 00:21:29 -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?= , Andreas Schwab , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 09/11] test-lib: reformat argument list in test_create_repo() Date: Fri, 23 Apr 2021 09:21:13 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.737.g98b508eba36 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 701518f5fd3..7101030f042 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -1250,8 +1250,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 Fri Apr 23 07:21:14 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: 12219763 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,URIBL_BLOCKED,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 4078EC433B4 for ; Fri, 23 Apr 2021 07:21:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0C88B61404 for ; Fri, 23 Apr 2021 07:21:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241166AbhDWHWS (ORCPT ); Fri, 23 Apr 2021 03:22:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241173AbhDWHWJ (ORCPT ); Fri, 23 Apr 2021 03:22:09 -0400 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 A861DC06138D for ; Fri, 23 Apr 2021 00:21:32 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id r9so72455160ejj.3 for ; Fri, 23 Apr 2021 00:21:32 -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=DZduldtTihhi6Qk7geq1tMxUx6hCXehRHu6g0a2726k=; b=c8/KY8nDzMR96uK1mXPUylYUaHLnMAsTLkMSy45sQYutVetGsJZO/TpoNWIVvMSFl5 AIsYoYDbcQsJ1LG3sMQE1w7EQslU9xc9CsG//ASlglhZNBjyT0jLhZp8weZBbEPaIVBI FgEaGDla//G14ZG//r4eUDVhNbYG2gPyz0FX5FJz/yZF9vDtKfJcH49q4ebdiod0P1HH qzeQ6b1/xE0vgxKFwKAjhjcQpRSkfi39Ou1oZsbogHFtVyPF8FgaiqoW80dpOlZYt3Dr hCfLztLW7rZB+RgzybTzoDbx3HnhfjS8vzzHtkqsfh0GKs2azaLpRd93wmzuU7vUqe02 Blmw== 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=DZduldtTihhi6Qk7geq1tMxUx6hCXehRHu6g0a2726k=; b=jlGYOrOZU943lS+4Gk6hmwPVODlnybXML1bNsi6yzDttibXJvLzM8aYio5wyujbmyp b64UlgpOAEdo3o7k+3z4h5skSIENKYFOynVSuSeSsCI/4Jrh9Ame4NGswf67MgZKhzTK RRKzZIApQyEEsCuFS4sVmcYGj5bs3eF80QCUgfZ+c5PrAEcC6HNda+5Rua/66C4b9FlJ s2pmepm2G7KQAq9gq2wsH80TeyK1ZBQFNYuZfx3Pmf2N+0+8UAvROO9NUGvCDYmDBnqW ish4Jif8lejjB0BcHvdn7Zz31AwM74/FEd+DcfbgV/aDJPtZQSdkuuXhrvMi+NrAPRnC JcNQ== X-Gm-Message-State: AOAM5310/1rTeou1fmCDfBfuR2kZ3j3JKTB7BI7YVG5erSGQkyIjVm4n z1mR6JCAXbK4uVaWuzp0GLLGYhzQ6L0+hQ== X-Google-Smtp-Source: ABdhPJwXmvZAQAjex8IjQjB8TAfqojwaCfCxQ0/X8s/elXBtn3ZEOH4NfqT69GV5vltULE0gI10qkQ== X-Received: by 2002:a17:906:1c8f:: with SMTP id g15mr2701422ejh.20.1619162491198; Fri, 23 Apr 2021 00:21:31 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id e5sm3328892ejq.85.2021.04.23.00.21.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 00:21:30 -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?= , Andreas Schwab , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 10/11] test-lib: do not show advice about init.defaultBranch under --verbose Date: Fri, 23 Apr 2021 09:21:14 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.737.g98b508eba36 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 7101030f042..c9f33b79151 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -1251,7 +1251,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 105c424bf56..ab1fe98ccce 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 Fri Apr 23 07:21:15 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: 12219765 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,URIBL_BLOCKED,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 65FC2C433ED for ; Fri, 23 Apr 2021 07:21:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 35FC861404 for ; Fri, 23 Apr 2021 07:21:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241228AbhDWHWU (ORCPT ); Fri, 23 Apr 2021 03:22:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241184AbhDWHWL (ORCPT ); Fri, 23 Apr 2021 03:22:11 -0400 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B77ACC061574 for ; Fri, 23 Apr 2021 00:21:33 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id sd23so63799771ejb.12 for ; Fri, 23 Apr 2021 00:21:33 -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=mNRErmwQsIsJTNbAqkJj+bC35uHmpctkSS4NZgP7hs4=; b=ef8CZPl893MsQ8cCxByHqy1dYs6A1udAEbAoxZFSPwqbT51bZDnJ0THcvVRa5iDFsn 42lRZsXSjMLTwpPVeGl/1Gwra5jSgzIloViEDh3Iq91/53/QWxTYcil/H5YLRT9Eg5U/ XEV5rjaFC6p64MhICUn/VoD5JDDr8kVFSpx5+paoDKcT+/+y86WTB8PopBqwEyBu22fs LKgphZc6bmy3JFUgB7q/Q2cq3zjitKzXkysOGjVQsLCF9h5jrK2kf4rqJn86OIZZjKFo xNo3DML3qGUy5op7iSIQE6o6ZPo/Zgi59wTgK86EMLS36dT37OmqjWIPlp7qd6XyudkM lmFg== 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=mNRErmwQsIsJTNbAqkJj+bC35uHmpctkSS4NZgP7hs4=; b=mgSG56y4AWuBQPrrO1NUYuKXcBbNNQ0sNFlO+F1JWp8vpBXoeoZjN63SRyRSDT2jKS 0zooKNc5RtWub9SUf2OxzgvD9gQ6B4YmYX6m21VmFq5E2khQa0eA7F7IdLJ6qWQlOpM3 qaTEn9TreYq+mPn232SFHo1t8+Hfs8vhqjzTgVWfXUM7b8k3v8S5UrRLvsEwF1rZcTOR NcIjJEXi8Rp2n96nkmOrxeMX0wivX3jlTuQkABLLmTnm+qHDVuAvhVITJiswm/ypNMq4 J6RQEbXUmeHUD6f1cGfJ2HAM+C8UE0n+UB2g9Ec4/iCRkqIut9Ohdm8wjDF0NGqZKnlM d2Ag== X-Gm-Message-State: AOAM531gxIjAiSYjmjev1fnxOAPQ3TCEQkk7oxgEj42OFnm5Bzwr2Uzo 0nMsByBorV8KiSxSpfCO5xllLDRubfoshw== X-Google-Smtp-Source: ABdhPJwTgVTXF43uCmIuEGj/c7PF5pot30I7bg3/yznM6QoyRg/YX0v228fgegZy+UEnR5Cx5jpEQQ== X-Received: by 2002:a17:907:1c08:: with SMTP id nc8mr2726075ejc.378.1619162492126; Fri, 23 Apr 2021 00:21:32 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id e5sm3328892ejq.85.2021.04.23.00.21.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 00:21:31 -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?= , Andreas Schwab , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 11/11] test-lib: split up and deprecate test_create_repo() Date: Fri, 23 Apr 2021 09:21:15 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.737.g98b508eba36 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. This makes us implicitly depend on the default hooks being disabled, which is a good thing. If and when we'd have any on-by-default hooks (I see no reason we ever would) we'd want to see the subtle and not so subtle ways that would break the test suite. 5. We don't need to "cd" to the "$repo" directory at all anymore. In the code being removed here we both "cd"'d to the repository before calling "init", and did so in a subshell. It's not important to do either, so both of those can be removed. We cd'd because this code grew from test-lib.sh code where we'd have done so already, see eedf8f97e58 (Abstract test_create_repo out for use in tests., 2006-02-17), and later "cd"'d inside a subshell since 0d314ce834d to avoid having to keep track of an "old pwd" variable to cd back after the setup. Being in the repository directory made moving the hooks around easier (we wouldn't have to fully qualify the path). Since we're not moving the hooks per #4 above we don't need to "cd" for that reason either. 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 ff06f99649e..5c509db6fc3 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 5bb23cc3a4e..6da8d760e28 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 5d8f401d8ec..9f1a483f426 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 c9f33b79151..213b1988aa4 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -1241,21 +1241,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 ab1fe98ccce..5fd968d11b2 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -1365,7 +1365,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