diff mbox series

[v2,1/3] reftable/stack: add env to disable autocompaction

Message ID cb6b152e5c86ab14165e072ac20dfa865b5f3aaa.1711060820.git.gitgitgadget@gmail.com (mailing list archive)
State Superseded
Headers show
Series reftable/stack: use geometric table compaction | expand

Commit Message

Justin Tobler March 21, 2024, 10:40 p.m. UTC
From: Justin Tobler <jltobler@gmail.com>

In future tests it will be neccesary to create repositories with a set
number of tables. To make this easier, introduce the
`GIT_TEST_REFTABLE_NO_AUTOCOMPACTION` environment variable that, when
set, disables autocompaction of reftables.

Signed-off-by: Justin Tobler <jltobler@gmail.com>
---
 reftable/stack.c  | 2 +-
 reftable/system.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

Comments

Patrick Steinhardt March 22, 2024, 1:25 a.m. UTC | #1
On Thu, Mar 21, 2024 at 10:40:17PM +0000, Justin Tobler via GitGitGadget wrote:
> From: Justin Tobler <jltobler@gmail.com>
> 
> In future tests it will be neccesary to create repositories with a set
> number of tables. To make this easier, introduce the
> `GIT_TEST_REFTABLE_NO_AUTOCOMPACTION` environment variable that, when
> set, disables autocompaction of reftables.
> 
> Signed-off-by: Justin Tobler <jltobler@gmail.com>

Might be worth it to demonstrate in a test what this does, also to make
sure that it actually works as expected and doesn't regress. Even though
it may be a bit overboarding to add tests for test-only functionality.
Dunno... ultimately it wouldn't hurt though, I guess?

Patrick

> ---
>  reftable/stack.c  | 2 +-
>  reftable/system.h | 1 +
>  2 files changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/reftable/stack.c b/reftable/stack.c
> index b64e55648aa..2370d93d13b 100644
> --- a/reftable/stack.c
> +++ b/reftable/stack.c
> @@ -681,7 +681,7 @@ int reftable_addition_commit(struct reftable_addition *add)
>  	if (err)
>  		goto done;
>  
> -	if (!add->stack->disable_auto_compact)
> +	if (!add->stack->disable_auto_compact && !git_env_bool("GIT_TEST_REFTABLE_NO_AUTOCOMPACTION", 0))
>  		err = reftable_stack_auto_compact(add->stack);
>  
>  done:
> diff --git a/reftable/system.h b/reftable/system.h
> index 6b74a815143..ec08b728177 100644
> --- a/reftable/system.h
> +++ b/reftable/system.h
> @@ -15,6 +15,7 @@ license that can be found in the LICENSE file or at
>  #include "strbuf.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);
>  
> -- 
> gitgitgadget
>
diff mbox series

Patch

diff --git a/reftable/stack.c b/reftable/stack.c
index b64e55648aa..2370d93d13b 100644
--- a/reftable/stack.c
+++ b/reftable/stack.c
@@ -681,7 +681,7 @@  int reftable_addition_commit(struct reftable_addition *add)
 	if (err)
 		goto done;
 
-	if (!add->stack->disable_auto_compact)
+	if (!add->stack->disable_auto_compact && !git_env_bool("GIT_TEST_REFTABLE_NO_AUTOCOMPACTION", 0))
 		err = reftable_stack_auto_compact(add->stack);
 
 done:
diff --git a/reftable/system.h b/reftable/system.h
index 6b74a815143..ec08b728177 100644
--- a/reftable/system.h
+++ b/reftable/system.h
@@ -15,6 +15,7 @@  license that can be found in the LICENSE file or at
 #include "strbuf.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);