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

Re: [PATCH v2 1/2] gc: add tests for --cruft and friends

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 26, 2022, 21:03 UTC
Message-ID
<xmqqo7tyfgbx.fsf@gitster.g>
In-Reply-To
<35d2c97715008db3957a69a8260e2046c0e5e738.1666815209.git.me@ttaylorr.com>
Taylor Blau <me@ttaylorr.com> writes:
Show 7 quoted lines
> +prepare_cruft_history () {
> +	test_commit base &&
> +
> +	test_commit --no-tag foo &&
> +	test_commit --no-tag bar &&
> +	git reset HEAD^^
> +}

OK. Three pearls on a single strand, then the tip-two gets rewound away.

> +assert_cruft_pack_exists () {
> +	find .git/objects/pack -name "*.mtimes" >mtimes &&
> +	sed -e 's/\.mtimes$/\.pack/g' mtimes >packs &&

Somebody recently made comment that we already depend on the fact that the default action for "find" is "-print". I do not see the need for the 'mtimes' intermediary file. It does not hurt, but it is not needed.

Show 6 quoted lines
> +	test_file_not_empty packs &&
> +	while read pack
> +	do
> +		test_path_is_file "$pack" || return 1
> +	done <packs
> +}

OK. We enumerate .mtimes files and ensure corresponding .pack exists for each of them. That might miss a case where we thought we created a cruft pack (i.e. .pack exists) but somehow failed to create the matching .mtimes file by mistake, but it is hard to tell such a "broken cruft pack" file from a normal pack file, so I think the above is the best we can do.

Show 23 quoted lines
> +test_expect_success 'gc --cruft generates a cruft pack' '
> +	test_when_finished "rm -fr crufts" &&
> +	git init crufts &&
> +	(
> +		cd crufts &&
> +
> +		prepare_cruft_history &&
> +		git gc --cruft &&
> +		assert_cruft_pack_exists
> +	)
> +'
> +
> +test_expect_success 'gc.cruftPacks=true generates a cruft pack' '
> +	test_when_finished "rm -fr crufts" &&
> +	git init crufts &&
> +	(
> +		cd crufts &&
> +
> +		prepare_cruft_history &&
> +		git -c gc.cruftPacks=true gc &&
> +		assert_cruft_pack_exists
> +	)
> +'

We could instead do away without when-finished clean-up and use separate test subdirectory. Consistently doing so may make CI forensic easier. I do not think it is necessary in the test history used here that is too simple to be realisic. If something breaks at CI, it is simple enough to reproduce it manually, so I do not think it is worth a reroll for that.

>  run_and_wait_for_auto_gc () {
>  	# We read stdout from gc for the side effect of waiting until the
>  	# background gc process exits, closing its fd 9.  Furthermore, the
Previous: Taylor BlauNext: Taylor Blau
Message 3 of 11 in “gc: let feature.experimental imply gc.cruftPacks”
  1. 0/2 gc: let feature.experimental imply gc.cruftPacksTaylor Blau, Oct 26, 2022
  2. 1/2 gc: add tests for --cruft and friendsTaylor Blau, Oct 26, 2022
  3. Junio C HamanoOct 26, 2022
  4. 2/2 config: let feature.experimental imply gc.cruftPacks=trueTaylor Blau, Oct 26, 2022
  5. Junio C HamanoOct 26, 2022
  6. Taylor BlauOct 26, 2022
  7. Junio C HamanoOct 26, 2022
  8. 0/2 gc: let feature.experimental imply gc.cruftPacksTaylor Blau, Oct 26, 2022
  9. 1/2 gc: add tests for --cruft and friendsTaylor Blau, Oct 26, 2022
  10. 2/2 config: let feature.experimental imply gc.cruftPacks=trueTaylor Blau, Oct 26, 2022
  11. Derrick StoleeOct 31, 2022

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.