Skip to content

Commit 7c8eb59

Browse files
jltoblergitster
authored andcommitted
reftable/stack: add env to disable autocompaction
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_AUTOCOMPACTION` environment variable that, when set to false, disables autocompaction of reftables. Signed-off-by: Justin Tobler <[email protected]> Acked-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bc91330 commit 7c8eb59

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

refs/reftable-backend.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "../reftable/reftable-merged.h"
1919
#include "../setup.h"
2020
#include "../strmap.h"
21+
#include "parse.h"
2122
#include "refs-internal.h"
2223

2324
/*
@@ -247,6 +248,8 @@ static struct ref_store *reftable_be_init(struct repository *repo,
247248
refs->write_options.block_size = 4096;
248249
refs->write_options.hash_id = repo->hash_algo->format_id;
249250
refs->write_options.default_permissions = calc_shared_perm(0666 & ~mask);
251+
refs->write_options.disable_auto_compact =
252+
!git_env_bool("GIT_TEST_REFTABLE_AUTOCOMPACTION", 1);
250253

251254
/*
252255
* Set up the main reftable stack that is hosted in GIT_COMMON_DIR.

t/t0610-reftable-basics.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,27 @@ test_expect_success 'ref transaction: writes cause auto-compaction' '
299299
test_line_count = 1 repo/.git/reftable/tables.list
300300
'
301301

302+
test_expect_success 'ref transaction: env var disables compaction' '
303+
test_when_finished "rm -rf repo" &&
304+
305+
git init repo &&
306+
test_commit -C repo A &&
307+
308+
start=$(wc -l <repo/.git/reftable/tables.list) &&
309+
iterations=5 &&
310+
expected=$((start + iterations)) &&
311+
312+
for i in $(test_seq $iterations)
313+
do
314+
GIT_TEST_REFTABLE_AUTOCOMPACTION=false \
315+
git -C repo update-ref branch-$i HEAD || return 1
316+
done &&
317+
test_line_count = $expected repo/.git/reftable/tables.list &&
318+
319+
git -C repo update-ref foo HEAD &&
320+
test_line_count -lt $expected repo/.git/reftable/tables.list
321+
'
322+
302323
check_fsync_events () {
303324
local trace="$1" &&
304325
shift &&

0 commit comments

Comments
 (0)