]> git.ipfire.org Git - thirdparty/git.git/commitdiff
reftable/stack: add env to disable autocompaction
authorJustin Tobler <jltobler@gmail.com>
Mon, 8 Apr 2024 16:16:54 +0000 (16:16 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 8 Apr 2024 19:11:10 +0000 (12:11 -0700)
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 <jltobler@gmail.com>
Acked-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs/reftable-backend.c
t/t0610-reftable-basics.sh

index 0bed6d2ab4844a1eb6b548c77577f3fc13105a81..1cda48c50461a2e15de74e7f6be893471ee6331a 100644 (file)
@@ -18,6 +18,7 @@
 #include "../reftable/reftable-merged.h"
 #include "../setup.h"
 #include "../strmap.h"
+#include "parse.h"
 #include "refs-internal.h"
 
 /*
@@ -247,6 +248,8 @@ static struct ref_store *reftable_be_init(struct repository *repo,
        refs->write_options.block_size = 4096;
        refs->write_options.hash_id = repo->hash_algo->format_id;
        refs->write_options.default_permissions = calc_shared_perm(0666 & ~mask);
+       refs->write_options.disable_auto_compact =
+               !git_env_bool("GIT_TEST_REFTABLE_AUTOCOMPACTION", 1);
 
        /*
         * Set up the main reftable stack that is hosted in GIT_COMMON_DIR.
index 931d888bbbcbc426dcf51a0478842fd4787bee1d..c9e10b34684d4447f8a3a914412e69665739fbbc 100755 (executable)
@@ -299,6 +299,27 @@ test_expect_success 'ref transaction: writes cause auto-compaction' '
        test_line_count = 1 repo/.git/reftable/tables.list
 '
 
+test_expect_success 'ref transaction: env var disables compaction' '
+       test_when_finished "rm -rf repo" &&
+
+       git init repo &&
+       test_commit -C repo A &&
+
+       start=$(wc -l <repo/.git/reftable/tables.list) &&
+       iterations=5 &&
+       expected=$((start + iterations)) &&
+
+       for i in $(test_seq $iterations)
+       do
+               GIT_TEST_REFTABLE_AUTOCOMPACTION=false \
+               git -C repo update-ref branch-$i HEAD || return 1
+       done &&
+       test_line_count = $expected repo/.git/reftable/tables.list &&
+
+       git -C repo update-ref foo HEAD &&
+       test_line_count -lt $expected repo/.git/reftable/tables.list
+'
+
 check_fsync_events () {
        local trace="$1" &&
        shift &&