git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/5] t0001: exercise initialization with ref formats more thoroughly

From
Justin Tobler <jltobler@gmail.com>
Date
Aug 15, 2024, 20:35 UTC
Message-ID
<vivxxi4dylb74fmplbcizsslldsracntksmvw6m4m2yqgf3zp4@itwngidkrswy>
In-Reply-To
<0d3844db32237983a1d85ced1a3b1b25fcd1d6eb.1723708417.git.ps@pks.im>
On 24/08/15 09:59AM, Patrick Steinhardt wrote:
Show 6 quoted lines
> While our object format tests for git-init(1) exercise tests with all
> known formats in t0001, the tests for the ref format don't. This leads
> to some missing test coverage for interesting cases, like whether or not
> a non-default ref storage format causes us to bump the repository format
> version. We also don't test for the precedence of the `--ref-format=`
> and the `GIT_DEFAULT_REF_FORMAT=` environment variable.
Makes sense to plug these test gaps.
Show 36 quoted lines
> Extend the test suite to cover more scenarios related to the ref format.
> 
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
>  t/t0001-init.sh | 48 +++++++++++++++++++++++++++++++++++-------------
>  1 file changed, 35 insertions(+), 13 deletions(-)
> 
> diff --git a/t/t0001-init.sh b/t/t0001-init.sh
> index 49e9bf77c6..2093f5c1ee 100755
> --- a/t/t0001-init.sh
> +++ b/t/t0001-init.sh
> @@ -558,15 +558,6 @@ test_expect_success DEFAULT_REPO_FORMAT 'extensions.refStorage with unknown back
>  	grep "invalid value for ${SQ}extensions.refstorage${SQ}: ${SQ}garbage${SQ}" err
>  '
>  
> -test_expect_success DEFAULT_REPO_FORMAT 'init with GIT_DEFAULT_REF_FORMAT=files' '
> -	test_when_finished "rm -rf refformat" &&
> -	GIT_DEFAULT_REF_FORMAT=files git init refformat &&
> -	echo 0 >expect &&
> -	git -C refformat config core.repositoryformatversion >actual &&
> -	test_cmp expect actual &&
> -	test_must_fail git -C refformat config extensions.refstorage
> -'
> -
>  test_expect_success 'init with GIT_DEFAULT_REF_FORMAT=garbage' '
>  	test_when_finished "rm -rf refformat" &&
>  	cat >expect <<-EOF &&
> @@ -576,15 +567,46 @@ test_expect_success 'init with GIT_DEFAULT_REF_FORMAT=garbage' '
>  	test_cmp expect err
>  '
>  
> -test_expect_success 'init with --ref-format=files' '
> +backends="files reftable"
> +for format in $backends
> +do
> +	test_expect_success DEFAULT_REPO_FORMAT "init with GIT_DEFAULT_REF_FORMAT=$format" '

The `DEFAULT_REPO_FORMAT` prereq is needed here because a non-default repo format also changes the repository format version.

Show 37 quoted lines
> +		test_when_finished "rm -rf refformat" &&
> +		GIT_DEFAULT_REF_FORMAT=$format git init refformat &&
> +
> +		if test $format = files
> +		then
> +			test_must_fail git -C refformat config extensions.refstorage &&
> +			echo 0 >expect
> +		else
> +			git -C refformat config extensions.refstorage &&
> +			echo 1 >expect
> +		fi &&
> +		git -C refformat config core.repositoryformatversion >actual &&
> +		test_cmp expect actual &&
> +
> +		echo $format >expect &&
> +		git -C refformat rev-parse --show-ref-format >actual &&
> +		test_cmp expect actual
> +	'
> +
> +	test_expect_success "init with --ref-format=$format" '
> +		test_when_finished "rm -rf refformat" &&
> +		git init --ref-format=$format refformat &&
> +		echo $format >expect &&
> +		git -C refformat rev-parse --show-ref-format >actual &&
> +		test_cmp expect actual
> +	'
> +done
> +
> +test_expect_success "--ref-format= overrides GIT_DEFAULT_REF_FORMAT" '
>  	test_when_finished "rm -rf refformat" &&
> -	git init --ref-format=files refformat &&
> -	echo files >expect &&
> +	GIT_DEFAULT_REF_FORMAT=files git init --ref-format=reftable refformat &&
> +	echo reftable >expect &&
>  	git -C refformat rev-parse --show-ref-format >actual &&
>  	test_cmp expect actual
>  '

Nice that we now validate that the `--ref-format` option takes precedence over the `GIT_DEFAULT_REF_FORMAT` environment variable.

-Justin
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 3 of 24 in “Introduce configs for default repo format”
  1. 0/5 Introduce configs for default repo formatPatrick Steinhardt, Aug 15, 2024
  2. 1/5 t0001: exercise initialization with ref formats more thoroughlyPatrick Steinhardt, Aug 15, 2024
  3. Justin ToblerAug 15, 2024
  4. 2/5 t0001: delete repositories when object format tests finishPatrick Steinhardt, Aug 15, 2024
  5. 3/5 setup: merge configuration of repository formatsPatrick Steinhardt, Aug 15, 2024
  6. Justin ToblerAug 15, 2024
  7. Patrick SteinhardtAug 16, 2024
  8. 5/5 setup: make ref storage format configurable via configPatrick Steinhardt, Aug 15, 2024
  9. Justin ToblerAug 15, 2024
  10. 4/5 setup: make object format configurable via configPatrick Steinhardt, Aug 15, 2024
  11. Justin ToblerAug 15, 2024
  12. shejialuoAug 15, 2024
  13. brian m. carlsonAug 15, 2024
  14. Junio C HamanoAug 15, 2024
  15. Patrick SteinhardtAug 16, 2024
  16. brian m. carlsonAug 15, 2024
  17. 0/5 Introduce configs for default repo formatPatrick Steinhardt, Aug 16, 2024
  18. 2/5 t0001: delete repositories when object format tests finishPatrick Steinhardt, Aug 16, 2024
  19. 5/5 setup: make ref storage format configurable via configPatrick Steinhardt, Aug 16, 2024
  20. 3/5 setup: merge configuration of repository formatsPatrick Steinhardt, Aug 16, 2024
  21. 1/5 t0001: exercise initialization with ref formats more thoroughlyPatrick Steinhardt, Aug 16, 2024
  22. 4/5 setup: make object format configurable via configPatrick Steinhardt, Aug 16, 2024
  23. Junio C HamanoAug 16, 2024
  24. Justin ToblerAug 16, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.