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

Re: [PATCH 2/2] config: let feature.experimental imply gc.cruftPacks=true

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 3, 2022, 22:05 UTC
Message-ID
<xmqqfsid7zk4.fsf@gitster.g>
In-Reply-To
<20220803205721.3686361-3-emilyshaffer@google.com>
Emily Shaffer <emilyshaffer@google.com> writes:
> +* `gc.cruftPacks=true` reduces disk space used by unreachable objects during
> +garbage collection.
OK.
Show 21 quoted lines
> diff --git a/builtin/gc.c b/builtin/gc.c
> index eeff2b760e..919cc508c5 100644
> --- a/builtin/gc.c
> +++ b/builtin/gc.c
> @@ -136,6 +136,7 @@ static int gc_config_is_timestamp_never(const char *var)
>  static void gc_config(void)
>  {
>  	const char *value;
> +	int experimental = 0;
>  
>  	if (!git_config_get_value("gc.packrefs", &value)) {
>  		if (value && !strcmp(value, "notbare"))
> @@ -148,6 +149,11 @@ static void gc_config(void)
>  	    gc_config_is_timestamp_never("gc.reflogexpireunreachable"))
>  		prune_reflogs = 0;
>  
> +	/* feature.experimental implies gc.cruftPacks=true */
> +	git_config_get_bool("feature.experimental", &experimental);
> +	if (experimental)
> +		cruft_packs = 1;
> +
I suspect the whole thing can just be:
	git_config_get_bool("feature.experimental", &cruft_packs);

If there is no feature.experimental configuration, the call returns non-zero (we do not check, though) without touching &cruft_packs, if there is feature.experimental configuration, the call returns zero (we do not check, though) and cruft_packs is set to either true (when experimental) or false (otherwise).

And this whole thing happens before we inspect what the more specific configuration gc.cruftPacks says, so...

Show 38 quoted lines
> diff --git a/t/t6500-gc.sh b/t/t6500-gc.sh
> index e4c2c3583d..4ab6750111 100755
> --- a/t/t6500-gc.sh
> +++ b/t/t6500-gc.sh
> @@ -238,6 +238,41 @@ test_expect_success 'gc.cruftPacks=true generates a cruft pack' '
>  	)
>  '
>  
> +test_expect_success 'feature.experimental=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 feature.experimental=true gc &&
> +
> +		cruft=$(basename $(ls .git/objects/pack/pack-*.mtimes) .mtimes) &&
> +		test_path_is_file .git/objects/pack/$cruft.pack
> +	)
> +'
> +
> +test_expect_success 'feature.experimental=false allows explicit cruft packs' '
> +	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 -c feature.experimental=false gc &&
OK.  

What is not tested is setting feature.experimental explicitly to false without touching gc.cruftPacks does not use the cruft pack.

Previous: Emily ShafferNext: Derrick Stolee
Message 7 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.