Subject: Re: [PATCH v3 1/3] reftable/stack: add env to disable autocompaction

From: Junio C Hamano <[email-masked]>
Date: Fri, 29 Mar 2024 14:56:08 -0700

"Justin Tobler via GitGitGadget" <[email-masked]> writes:

> -	if (!add->stack->disable_auto_compact)
> +	if (!add->stack->disable_auto_compact && !git_env_bool("GIT_TEST_REFTABLE_NO_AUTOCOMPACTION", 0))

Fold the line after " &&", i.e.

	if (!add->stack->disable_auto_compact &&
	    !git_env_bool("GIT_TEST_REFTABLE_NO_AUTOCOMPACTION", 0))

> diff --git a/reftable/system.h b/reftable/system.h
> index 5d8b6dede50..05b7c8554af 100644
> --- a/reftable/system.h
> +++ b/reftable/system.h
> @@ -17,6 +17,7 @@ license that can be found in the LICENSE file or at
>  #include "tempfile.h"
>  #include "hash-ll.h" /* hash ID, sizes.*/
>  #include "dir.h" /* remove_dir_recursively, for tests.*/
> +#include "parse.h"
>  
>  int hash_size(uint32_t id);
>  
> diff --git a/t/t0610-reftable-basics.sh b/t/t0610-reftable-basics.sh
> index 686781192eb..434044078ed 100755
> --- a/t/t0610-reftable-basics.sh
> +++ b/t/t0610-reftable-basics.sh
> @@ -299,6 +299,21 @@ test_expect_success 'ref transaction: writes cause auto-compaction' '
>  	test_line_count = 1 repo/.git/reftable/tables.list
>  '
>  
> +test_expect_success 'ref transaction: environment variable disables auto-compaction' '
> +	test_when_finished "rm -rf repo" &&
> +
> +	git init repo &&
> +	test_commit -C repo A &&
> +	for i in $(test_seq 20)
> +	do
> +		GIT_TEST_REFTABLE_NO_AUTOCOMPACTION=true git -C repo update-ref branch-$i HEAD || return 1

Fold the line before "git", i.e.

		GIT_TEST_REFTABLE_NO_AUTOCOMPACTION=true \
		git -C repo update-ref branch-$i HEAD || return 1

> +	done &&
> +	test_line_count = 23 repo/.git/reftable/tables.list &&
> +
> +	git -C repo update-ref foo HEAD &&
> +	test_line_count = 1 repo/.git/reftable/tables.list
> +'
> +
>  check_fsync_events () {
>  	local trace="$1" &&
>  	shift &&