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

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

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Aug 4, 2022, 07:48 UTC
Message-ID
<220804.86a68ke9d5.gmgdl@evledraar.gmail.com>
In-Reply-To
<20220803205721.3686361-2-emilyshaffer@google.com>
On Wed, Aug 03 2022, Emily Shaffer wrote:
Show 24 quoted lines
> In 5b92477f89 (builtin/gc.c: conditionally avoid pruning objects via
> loose, 2022-05-20) gc learned to respect '--cruft' and 'gc.cruftPacks'.
> '--cruft' is exercised in t5329-pack-objects-cruft.sh, but in a way that
> doesn't check whether a lone gc run generates these cruft packs.
> 'gc.cruftPacks' is never exercised.
>
> Add some tests to exercise these options to gc in the gc test suite.
>
> Signed-off-by: Emily Shaffer <emilyshaffer@google.com>
> ---
>  t/t6500-gc.sh | 36 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 36 insertions(+)
>
> diff --git a/t/t6500-gc.sh b/t/t6500-gc.sh
> index cd6c53360d..e4c2c3583d 100755
> --- a/t/t6500-gc.sh
> +++ b/t/t6500-gc.sh
> @@ -202,6 +202,42 @@ test_expect_success 'one of gc.reflogExpire{Unreachable,}=never does not skip "e
>  	grep -E "^trace: (built-in|exec|run_command): git reflog expire --" trace.out
>  '
>  
> +test_expect_success 'gc --cruft generates a cruft pack' '
> +	git init crufts &&
> +	test_when_finished "rm -fr crufts" &&

Let's "test_when_finished" first, then "git init", the point is to clean up the directory if we fail.

Show 14 quoted lines
> +	(
> +		cd crufts &&
> +		test_commit base &&
> +
> +		test_commit --no-tag foo &&
> +		test_commit --no-tag bar &&
> +		git reset HEAD^^ &&
> +
> +		git gc --cruft &&
> +
> +		cruft=$(basename $(ls .git/objects/pack/pack-*.mtimes) .mtimes) &&
> +		test_path_is_file .git/objects/pack/$cruft.pack
> +	)
> +'
...this...
Show 18 quoted lines
> +test_expect_success 'gc.cruftPacks=true generates a cruft pack' '
> +	git init crufts &&
> +	test_when_finished "rm -fr crufts" &&
> +	(
> +		cd crufts &&
> +		test_commit base &&
> +
> +		test_commit --no-tag foo &&
> +		test_commit --no-tag bar &&
> +		git reset HEAD^^ &&
> +
> +		git -c gc.cruftPacks=true gc &&
> +
> +		cruft=$(basename $(ls .git/objects/pack/pack-*.mtimes) .mtimes) &&
> +		test_path_is_file .git/objects/pack/$cruft.pack
> +	)
> +'
> +
...whole thing seems to be copy/pasted aside from the git options.

If so let's factor this into a trivial helper that invokes git "$@", then call it with "gc --cruft" and "-c ..."?

Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 9 in “let feature.experimental imply gc.cruftPacks=true”
  1. 0/2 let feature.experimental imply gc.cruftPacks=trueEmily Shaffer, Aug 3, 2022
  2. 1/2 gc: add tests for --cruft and friendsEmily Shaffer, Aug 3, 2022
  3. Junio C HamanoAug 3, 2022
  4. Ævar Arnfjörð BjarmasonAug 4, 2022
  5. Junio C HamanoAug 4, 2022
  6. 2/2 config: let feature.experimental imply gc.cruftPacks=trueEmily Shaffer, Aug 3, 2022
  7. Junio C HamanoAug 3, 2022
  8. Derrick StoleeAug 4, 2022
  9. Junio C HamanoAug 4, 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.